@@ -14,6 +14,25 @@ enum EasyLoadingStyle {
1414 custom,
1515}
1616
17+ /// toast position
18+ enum EasyLoadingToastPosition {
19+ top,
20+ center,
21+ bottom,
22+ }
23+
24+ /// loading mask type
25+ /// [none] default mask type, allow user interactions while loading is displayed
26+ /// [clear] don't allow user interactions while loading is displayed
27+ /// [black] don't allow user interactions while loading is displayed
28+ /// [custom] while mask type is custom, maskColor should not be null
29+ enum EasyLoadingMaskType {
30+ none,
31+ clear,
32+ black,
33+ custom,
34+ }
35+
1736/// loading indicator type. see [https://github.com/jogboms/flutter_spinkit#-showcase]
1837enum EasyLoadingIndicatorType {
1938 fadingCircle,
@@ -41,18 +60,6 @@ enum EasyLoadingIndicatorType {
4160 squareCircle,
4261}
4362
44- /// loading mask type
45- /// [none] default mask type, allow user interactions while loading is displayed
46- /// [clear] don't allow user interactions while loading is displayed
47- /// [black] don't allow user interactions while loading is displayed
48- /// [custom] while mask type is custom, maskColor should not be null
49- enum EasyLoadingMaskType {
50- none,
51- clear,
52- black,
53- custom,
54- }
55-
5663class EasyLoading {
5764 /// loading style, default [EasyLoadingStyle.dark] .
5865 EasyLoadingStyle loadingStyle;
@@ -63,6 +70,9 @@ class EasyLoading {
6370 /// loading mask type, default [EasyLoadingMaskType.none] .
6471 EasyLoadingMaskType maskType;
6572
73+ /// toast position, default [EasyLoadingToastPosition.center] .
74+ EasyLoadingToastPosition toastPosition;
75+
6676 /// textAlign of status, default [TextAlign.center] .
6777 TextAlign textAlign;
6878
@@ -126,13 +136,13 @@ class EasyLoading {
126136 OverlayEntry overlayEntry;
127137 Widget _w;
128138
129- GlobalKey <LoadingContainerState > _key;
130- GlobalKey <ProgressState > _progressKey;
139+ GlobalKey <EasyLoadingContainerState > _key;
140+ GlobalKey <EasyLoadingProgressState > _progressKey;
131141 Timer _timer;
132142
133143 Widget get w => _w;
134- GlobalKey <LoadingContainerState > get key => _key;
135- GlobalKey <ProgressState > get progressKey => _progressKey;
144+ GlobalKey <EasyLoadingContainerState > get key => _key;
145+ GlobalKey <EasyLoadingProgressState > get progressKey => _progressKey;
136146 Timer get timer => _timer;
137147
138148 factory EasyLoading () => _getInstance ();
@@ -189,8 +199,9 @@ class EasyLoading {
189199 'progress value should be 0.0 ~ 1.0' ,
190200 );
191201 if (_getInstance ()._progressKey == null || _getInstance ().w == null ) {
192- GlobalKey <ProgressState > _progressKey = GlobalKey <ProgressState >();
193- Widget w = Progress (
202+ GlobalKey <EasyLoadingProgressState > _progressKey =
203+ GlobalKey <EasyLoadingProgressState >();
204+ Widget w = EasyLoadingProgress (
194205 key: _progressKey,
195206 value: value,
196207 );
@@ -265,10 +276,12 @@ class EasyLoading {
265276 static void showToast (
266277 String status, {
267278 Duration duration,
279+ EasyLoadingToastPosition toastPosition,
268280 }) {
269281 _getInstance ()._show (
270282 status: status,
271283 duration: duration ?? EasyLoadingTheme .displayDuration,
284+ toastPosition: toastPosition ?? EasyLoadingTheme .toastPosition,
272285 );
273286 }
274287
@@ -293,12 +306,18 @@ class EasyLoading {
293306 Widget w,
294307 String status,
295308 Duration duration,
309+ EasyLoadingToastPosition toastPosition = EasyLoadingToastPosition .center,
296310 }) {
297311 assert (
298312 _getInstance ().overlayEntry != null ,
299313 'overlayEntry should not be null' ,
300314 );
301315
316+ assert (
317+ toastPosition != null ,
318+ 'toastPosition should not be null' ,
319+ );
320+
302321 if (_getInstance ().loadingStyle == EasyLoadingStyle .custom) {
303322 assert (
304323 _getInstance ().backgroundColor != null ,
@@ -328,12 +347,14 @@ class EasyLoading {
328347 _cancelTimer ();
329348 _getInstance ()._progressKey = null ;
330349
331- GlobalKey <LoadingContainerState > _key = GlobalKey <LoadingContainerState >();
332- _getInstance ()._w = LoadingContainer (
350+ GlobalKey <EasyLoadingContainerState > _key =
351+ GlobalKey <EasyLoadingContainerState >();
352+ _getInstance ()._w = EasyLoadingContainer (
333353 key: _key,
334354 status: status,
335355 indicator: w,
336356 animation: _getInstance ()._w == null ,
357+ toastPosition: toastPosition,
337358 );
338359 _markNeedsBuild ();
339360 _getInstance ()._key = _key;
@@ -346,11 +367,11 @@ class EasyLoading {
346367
347368 void _dismiss (bool animation) {
348369 if (animation) {
349- LoadingContainerState loadingContainerState =
370+ EasyLoadingContainerState easyLoadingContainerState =
350371 _getInstance ().key? .currentState;
351- if (loadingContainerState != null ) {
372+ if (easyLoadingContainerState != null ) {
352373 final Completer <void > completer = Completer <void >();
353- loadingContainerState .dismiss (completer);
374+ easyLoadingContainerState .dismiss (completer);
354375 completer.future.then ((value) {
355376 _reset ();
356377 });
0 commit comments