Skip to content

Commit 6e20d5e

Browse files
committed
Fixed the toast position was incorrect when the soft keyboard show or hide.
1 parent 42fa2b0 commit 6e20d5e

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

lib/src/toast.dart

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -330,19 +330,25 @@ class __ToastContainerState extends State<_ToastContainer>
330330
var mediaQueryData = MediaQueryData.fromWindow(ui.window);
331331
Widget container = w;
332332

333-
print("on change");
334-
333+
var edgeInsets = EdgeInsets.only(bottom: mediaQueryData.viewInsets.bottom);
335334
if (offset > 0) {
335+
var padding = EdgeInsets.only(top: offset) + edgeInsets;
336+
336337
container = AnimatedPadding(
337338
duration: _opacityDuration,
338-
padding: EdgeInsets.only(top: offset) +
339-
EdgeInsets.only(bottom: mediaQueryData.viewInsets.bottom),
339+
padding: padding,
340340
child: container,
341341
);
342342
} else if (offset < 0) {
343343
container = AnimatedPadding(
344344
duration: _opacityDuration,
345-
padding: EdgeInsets.only(bottom: offset.abs()),
345+
padding: EdgeInsets.only(bottom: offset.abs()) + edgeInsets,
346+
child: container,
347+
);
348+
} else {
349+
container = AnimatedPadding(
350+
duration: _opacityDuration,
351+
padding: edgeInsets,
346352
child: container,
347353
);
348354
}

0 commit comments

Comments
 (0)