showSelectLocaleDialog function
Future<void>
showSelectLocaleDialog(
- BuildContext context, {
- String title = 'Select language',
- double? width,
- double? height,
- SliverGridDelegate? gridDelegate,
- dynamic setLocaleCallBack()?,
Show popup dialog to select Language.
Implementation
Future<void> showSelectLocaleDialog(
BuildContext context, {
String title = 'Select language',
double? width,
double? height,
SliverGridDelegate? gridDelegate,
Function(BuildContext)? setLocaleCallBack,
}) {
final size = MediaQuery.of(context).size;
return showDialog<void>(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: Text(title),
content: SizedBox(
width: width ?? size.width * 0.6,
height: height ?? size.height * 0.6,
child: LocaleSwitcher.grid(
gridDelegate: gridDelegate,
setLocaleCallBack: (context) {
setLocaleCallBack?.call(context);
Navigator.of(context).pop();
},
),
),
actions: <Widget>[
Row(
children: [
const Spacer(),
TextButton(
style: TextButton.styleFrom(
textStyle: Theme.of(context).textTheme.labelLarge,
),
child:
Text(MaterialLocalizations.of(context).cancelButtonLabel),
onPressed: () {
Navigator.of(context).pop();
},
),
const Spacer(),
],
)
],
);
},
);
}