From d1cc715ebbc93f2ae8f169037911015483773c5e Mon Sep 17 00:00:00 2001 From: yangyxd Date: Mon, 21 Feb 2022 15:19:39 +0800 Subject: [PATCH] Add useRootNavigator argument to Picker.showModal() --- lib/Picker.dart | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/lib/Picker.dart b/lib/Picker.dart index b403bbd..59419f6 100644 --- a/lib/Picker.dart +++ b/lib/Picker.dart @@ -169,10 +169,13 @@ class Picker { /// Display modal picker Future showModal(BuildContext context, - [ThemeData? themeData, bool isScrollControlled = false]) async { + [ThemeData? themeData, + bool isScrollControlled = false, + bool useRootNavigator = false]) async { return await showModalBottomSheet( context: context, //state.context, isScrollControlled: isScrollControlled, + useRootNavigator: useRootNavigator, builder: (BuildContext context) { return makePicker(themeData, true); }); @@ -215,7 +218,8 @@ class Picker { actions.add(TextButton( style: _getButtonStyle(ButtonTheme.of(context)), onPressed: () async { - if (onConfirmBefore != null && !(await onConfirmBefore!(this, selecteds))) { + if (onConfirmBefore != null && + !(await onConfirmBefore!(this, selecteds))) { return; // Cancel; } Navigator.pop>(context, selecteds); @@ -451,7 +455,8 @@ class PickerWidgetState extends State<_PickerWidget> { items.add(DefaultTextStyle( style: picker.cancelTextStyle ?? theme!.textTheme.button!.copyWith( - color: theme!.colorScheme.secondary, fontSize: Picker.DefaultTextSize), + color: theme!.colorScheme.secondary, + fontSize: Picker.DefaultTextSize), child: picker.cancel!)); } else { String? _cancelText = @@ -479,7 +484,8 @@ class PickerWidgetState extends State<_PickerWidget> { items.add(DefaultTextStyle( style: picker.confirmTextStyle ?? theme!.textTheme.button!.copyWith( - color: theme!.colorScheme.secondary, fontSize: Picker.DefaultTextSize), + color: theme!.colorScheme.secondary, + fontSize: Picker.DefaultTextSize), child: picker.confirm!)); } else { String? _confirmText = @@ -1132,7 +1138,12 @@ class DateTimePickerAdapter extends PickerAdapter { final int? minuteInterval; /// Year, month, day suffix - final String? yearSuffix, monthSuffix, daySuffix, hourSuffix, minuteSuffix, secondSuffix; + final String? yearSuffix, + monthSuffix, + daySuffix, + hourSuffix, + minuteSuffix, + secondSuffix; /// use two-digit year, 2019, displayed as 19 final bool twoDigitYear; @@ -1432,7 +1443,8 @@ class DateTimePickerAdapter extends PickerAdapter { if (minuteInterval == null || minuteInterval! < 2) _text = "${intToStr(index)}${_checkStr(minuteSuffix)}"; else - _text = "${intToStr(index * minuteInterval!)}${_checkStr(minuteSuffix)}"; + _text = + "${intToStr(index * minuteInterval!)}${_checkStr(minuteSuffix)}"; break; case 6: List? _ampm = strAMPM ?? PickerLocalizations.of(context).ampm;