@@ -8,10 +8,10 @@ extension ModalBottomSheetExtension on BuildContext {
88 required Duration initialValue,
99 required CupertinoTimerPickerMode mode,
1010 required Function (Duration value) onSaved,
11- Function ? onDisposed,
11+ VoidCallback ? onDisposed,
1212 }) {
1313 showModalBottomSheet <void >(
14- isDismissible: false ,
14+ isDismissible: true ,
1515 context: this ,
1616 builder: (BuildContext context) {
1717 final textTheme = Theme .of (context).textTheme;
@@ -41,18 +41,20 @@ extension ModalBottomSheetExtension on BuildContext {
4141 Expanded (
4242 flex: 1 ,
4343 child: ElevatedButton (
44- onPressed: () {
45- //calling order matters
46- Navigator .pop (context);
47- onDisposed? .call ();
48- },
49- style: ButtonStyle (
50- backgroundColor: WidgetStatePropertyAll (
51- Color .fromARGB (255 , 220 , 227 , 255 )),
52- foregroundColor: WidgetStatePropertyAll (
53- Color .fromARGB (255 , 92 , 121 , 251 )),
44+ onPressed: () {
45+ //calling order matters
46+ Navigator .pop (context);
47+ },
48+ style: ButtonStyle (
49+ backgroundColor: WidgetStatePropertyAll (
50+ Color .fromARGB (255 , 220 , 227 , 255 ),
5451 ),
55- child: Text (AppLocalizations .of (this )! .cancel)),
52+ foregroundColor: WidgetStatePropertyAll (
53+ Color .fromARGB (255 , 92 , 121 , 251 ),
54+ ),
55+ ),
56+ child: Text (AppLocalizations .of (this )! .cancel),
57+ ),
5658 ),
5759 SizedBox (width: 20.0 ),
5860 Expanded (
@@ -61,7 +63,6 @@ extension ModalBottomSheetExtension on BuildContext {
6163 onPressed: () {
6264 Navigator .pop (context);
6365 onSaved (duration);
64- onDisposed? .call ();
6566 },
6667 child: Text (AppLocalizations .of (this )! .ok),
6768 ),
@@ -73,17 +74,19 @@ extension ModalBottomSheetExtension on BuildContext {
7374 ),
7475 );
7576 },
76- );
77+ ).whenComplete (() {
78+ onDisposed? .call ();
79+ });
7780 }
7881
7982 void showCupertinoMinutePickerModal ({
8083 required String title,
8184 required Duration initialValue,
8285 required Function (Duration value) onSaved,
83- Function ? onDisposed,
86+ VoidCallback ? onDisposed,
8487 }) {
8588 showModalBottomSheet <void >(
86- isDismissible: false ,
89+ isDismissible: true ,
8790 context: this ,
8891 builder: (BuildContext context) {
8992 final textTheme = Theme .of (context).textTheme;
@@ -92,8 +95,10 @@ extension ModalBottomSheetExtension on BuildContext {
9295 borderRadius: BorderRadius .vertical (top: Radius .circular (20.0 )),
9396 child: Container (
9497 color: Theme .of (context).colorScheme.surface,
95- padding:
96- const EdgeInsets .symmetric (horizontal: 29.0 , vertical: 28.0 ),
98+ padding: const EdgeInsets .symmetric (
99+ horizontal: 29.0 ,
100+ vertical: 28.0 ,
101+ ),
97102 child: SizedBox (
98103 height: 334 ,
99104 child: Column (
@@ -106,16 +111,19 @@ extension ModalBottomSheetExtension on BuildContext {
106111 width: 69.0 ,
107112 child: CupertinoPicker (
108113 scrollController: FixedExtentScrollController (
109- initialItem: initialValue.inMinutes),
114+ initialItem: initialValue.inMinutes,
115+ ),
110116 looping: true ,
111117 itemExtent: 32 ,
112118 onSelectedItemChanged: (int value) {
113119 minutes = value;
114120 },
115121 children: List .generate (
116- 60 ,
117- (index) => Text (
118- (index < 10 ? '0' : '' ) + index.toString ())),
122+ 60 ,
123+ (index) => Text (
124+ (index < 10 ? '0' : '' ) + index.toString (),
125+ ),
126+ ),
119127 ),
120128 ),
121129 ),
@@ -127,18 +135,20 @@ extension ModalBottomSheetExtension on BuildContext {
127135 Expanded (
128136 flex: 1 ,
129137 child: ElevatedButton (
130- onPressed: () {
131- //calling order matters
132- Navigator .pop (context);
133- onDisposed ? . call ();
134- },
135- style : ButtonStyle (
136- backgroundColor : WidgetStatePropertyAll (
137- Color . fromARGB ( 255 , 220 , 227 , 255 ) ),
138- foregroundColor: WidgetStatePropertyAll (
139- Color .fromARGB (255 , 92 , 121 , 251 ) ),
138+ onPressed: () {
139+ //calling order matters
140+ Navigator .pop (context);
141+ },
142+ style : ButtonStyle (
143+ backgroundColor : WidgetStatePropertyAll (
144+ Color . fromARGB ( 255 , 220 , 227 , 255 ),
145+ ),
146+ foregroundColor: WidgetStatePropertyAll (
147+ Color .fromARGB (255 , 92 , 121 , 251 ),
140148 ),
141- child: Text (AppLocalizations .of (this )! .cancel)),
149+ ),
150+ child: Text (AppLocalizations .of (this )! .cancel),
151+ ),
142152 ),
143153 SizedBox (width: 20.0 ),
144154 Expanded (
@@ -147,7 +157,6 @@ extension ModalBottomSheetExtension on BuildContext {
147157 onPressed: () {
148158 Navigator .pop (context);
149159 onSaved (Duration (minutes: minutes));
150- onDisposed? .call ();
151160 },
152161 child: Text (AppLocalizations .of (this )! .ok),
153162 ),
@@ -160,18 +169,20 @@ extension ModalBottomSheetExtension on BuildContext {
160169 ),
161170 );
162171 },
163- );
172+ ).whenComplete (() {
173+ onDisposed? .call ();
174+ });
164175 }
165176
166177 void showCupertinoDatePickerModal ({
167178 required String title,
168179 required DateTime initialValue,
169180 required Function (DateTime value) onSaved,
170181 required CupertinoDatePickerMode mode,
171- Function ? onDisposed,
182+ VoidCallback ? onDisposed,
172183 }) {
173184 showModalBottomSheet <void >(
174- isDismissible: false ,
185+ isDismissible: true ,
175186 context: this ,
176187 builder: (BuildContext context) {
177188 final textTheme = Theme .of (context).textTheme;
@@ -203,18 +214,20 @@ extension ModalBottomSheetExtension on BuildContext {
203214 Expanded (
204215 flex: 1 ,
205216 child: ElevatedButton (
206- onPressed: () {
207- //calling order matters
208- Navigator .pop (context);
209- onDisposed ? . call ();
210- },
211- style : ButtonStyle (
212- backgroundColor : WidgetStatePropertyAll (
213- Color . fromARGB ( 255 , 220 , 227 , 255 ) ),
214- foregroundColor: WidgetStatePropertyAll (
215- Color .fromARGB (255 , 92 , 121 , 251 ) ),
217+ onPressed: () {
218+ //calling order matters
219+ Navigator .pop (context);
220+ },
221+ style : ButtonStyle (
222+ backgroundColor : WidgetStatePropertyAll (
223+ Color . fromARGB ( 255 , 220 , 227 , 255 ),
224+ ),
225+ foregroundColor: WidgetStatePropertyAll (
226+ Color .fromARGB (255 , 92 , 121 , 251 ),
216227 ),
217- child: Text (AppLocalizations .of (this )! .cancel)),
228+ ),
229+ child: Text (AppLocalizations .of (this )! .cancel),
230+ ),
218231 ),
219232 SizedBox (width: 20.0 ),
220233 Expanded (
@@ -223,7 +236,6 @@ extension ModalBottomSheetExtension on BuildContext {
223236 onPressed: () {
224237 Navigator .pop (context);
225238 onSaved (dateTime);
226- onDisposed? .call ();
227239 },
228240 child: Text (AppLocalizations .of (this )! .ok),
229241 ),
@@ -235,6 +247,8 @@ extension ModalBottomSheetExtension on BuildContext {
235247 ),
236248 );
237249 },
238- );
250+ ).whenComplete (() {
251+ onDisposed? .call ();
252+ });
239253 }
240254}
0 commit comments