@@ -164,21 +164,18 @@ ToastFuture showToast(
164
164
_ToastTheme .of (context).textDirection ??
165
165
TextDirection .ltr;
166
166
167
- Widget widget = Align (
168
- alignment: position.align,
169
- child: Container (
170
- margin: const EdgeInsets .all (50.0 ),
171
- decoration: BoxDecoration (
172
- color: backgroundColor,
173
- borderRadius: BorderRadius .circular (radius),
174
- ),
175
- padding: textPadding,
176
- child: ClipRect (
177
- child: Text (
178
- msg,
179
- style: textStyle,
180
- textAlign: textAlign,
181
- ),
167
+ Widget widget = Container (
168
+ margin: const EdgeInsets .all (50.0 ),
169
+ decoration: BoxDecoration (
170
+ color: backgroundColor,
171
+ borderRadius: BorderRadius .circular (radius),
172
+ ),
173
+ padding: textPadding,
174
+ child: ClipRect (
175
+ child: Text (
176
+ msg,
177
+ style: textStyle,
178
+ textAlign: textAlign,
182
179
),
183
180
),
184
181
);
@@ -218,6 +215,11 @@ ToastFuture showToastWidget(
218
215
219
216
GlobalKey <__ToastContainerState > key = GlobalKey ();
220
217
218
+ widget = Align (
219
+ child: widget,
220
+ alignment: position.align,
221
+ );
222
+
221
223
entry = OverlayEntry (builder: (ctx) {
222
224
return IgnorePointer (
223
225
child: _ToastContainer (
@@ -326,20 +328,27 @@ class __ToastContainerState extends State<_ToastContainer>
326
328
}
327
329
328
330
var mediaQueryData = MediaQueryData .fromWindow (ui.window);
329
- Widget container = AnimatedContainer (
330
- padding: EdgeInsets .only (bottom: mediaQueryData.viewInsets.bottom),
331
- duration: _opacityDuration,
332
- child: w,
333
- );
331
+ Widget container = w;
334
332
333
+ var edgeInsets = EdgeInsets .only (bottom: mediaQueryData.viewInsets.bottom);
335
334
if (offset > 0 ) {
336
- container = Padding (
337
- padding: EdgeInsets .only (top: offset),
335
+ var padding = EdgeInsets .only (top: offset) + edgeInsets;
336
+
337
+ container = AnimatedPadding (
338
+ duration: _opacityDuration,
339
+ padding: padding,
338
340
child: container,
339
341
);
340
342
} else if (offset < 0 ) {
341
- container = Padding (
342
- padding: EdgeInsets .only (bottom: offset.abs ()),
343
+ container = AnimatedPadding (
344
+ duration: _opacityDuration,
345
+ padding: EdgeInsets .only (bottom: offset.abs ()) + edgeInsets,
346
+ child: container,
347
+ );
348
+ } else {
349
+ container = AnimatedPadding (
350
+ duration: _opacityDuration,
351
+ padding: edgeInsets,
343
352
child: container,
344
353
);
345
354
}
@@ -368,6 +377,11 @@ class ToastPosition {
368
377
369
378
static const top =
370
379
const ToastPosition (align: Alignment .topCenter, offset: 75.0 );
380
+
381
+ @override
382
+ String toString () {
383
+ return "ToastPosition [ align = $align , offset = $offset ] " ;
384
+ }
371
385
}
372
386
373
387
class _ToastTheme extends InheritedWidget {
0 commit comments