Skip to content

Commit

Permalink
Hot fix #100 : auto pop bug
Browse files Browse the repository at this point in the history
  • Loading branch information
koukibadr committed Apr 2, 2023
1 parent d611064 commit a40f770
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## [2.6.6] - 02/04/2023

- Add dismiss toast callback (hot fix for this [issue](https://github.com/koukibadr/Motion-Toast/issues/100) )

## [2.6.5] - 11/02/2023

- Fix material3 support issue for bottom toasts
Expand Down
22 changes: 21 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ In order to add motion toast to your project add this line to your `pubspec.yaml

```yaml
dependencies:
motion_toast: ^2.6.5
motion_toast: ^2.6.6
```


Expand Down Expand Up @@ -501,6 +501,26 @@ MotionToast(
```

- **Dismiss the toast from your UI screen**



```dart
MotionToast toast = MotionToast(
icon: Icons.zoom_out,
primaryColor: Colors.orange[500]!,
secondaryColor: Colors.grey,
backgroundType: BackgroundType.solid,
title: Text('Two Color Motion Toast'),
description: Text('Another motion toast example'),
displayBorder: true,
displaySideBar: false,
).show(context);
toast.dismiss();
```


## Contribution

Expand Down
9 changes: 9 additions & 0 deletions lib/motion_toast.dart
Original file line number Diff line number Diff line change
Expand Up @@ -431,9 +431,12 @@ class MotionToast extends StatefulWidget {
/// default `= true`
final bool displaySideBar;

late BuildContext _context;

/// Display the created motion toast based on the [position] attribute
/// [context]: the actual context of the application
void show(BuildContext context) {
_context = context;
Navigator.of(context).push(
PageRouteBuilder<Widget>(
fullscreenDialog: false,
Expand All @@ -444,6 +447,12 @@ class MotionToast extends StatefulWidget {
),
);
}

void dismiss() {
Navigator.of(_context).pop();
onClose?.call();
}

}

class _MotionToastState extends State<MotionToast>
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: motion_toast
description: 'A beautiful designed toast with animations, contains multiple built in designs and let you design your toast'
version: 2.6.5
version: 2.6.6
homepage: 'https://github.com/koukibadr/Motion-Toast'
environment:
sdk: '>=2.12.0 <3.0.0'
Expand Down

0 comments on commit a40f770

Please sign in to comment.