Skip to content

Commit

Permalink
Fix bug - Unhandled Exception: type 'Future<bool?>' is not a subtype …
Browse files Browse the repository at this point in the history
…of type 'FutureOr<bool>' in type cast

Fix letsar#209
  • Loading branch information
codespair committed May 3, 2021
1 parent 017f181 commit 768fa88
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ class _MyHomePageState extends State<MyHomePage> {
onWillDismiss: (item.index != 10)
? null
: (actionType) {
return showDialog<bool>(
return showDialog<bool?>(
context: context,
builder: (context) {
return AlertDialog(
Expand All @@ -204,8 +204,8 @@ class _MyHomePageState extends State<MyHomePage> {
],
);
},
) as FutureOr<bool>;
} as FutureOr<bool> Function(SlideActionType?)?,
);
} as Future<bool?> Function(SlideActionType?)?,
onDismissed: (actionType) {
_showSnackBar(
context,
Expand Down Expand Up @@ -254,9 +254,9 @@ class _MyHomePageState extends State<MyHomePage> {
],
);
},
) as FutureOr<bool>);
));

if (dismiss) {
if (dismiss!) {
state!.dismiss();
}
},
Expand Down
4 changes: 2 additions & 2 deletions lib/src/widgets/slidable.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ typedef DismissSlideActionCallback = void Function(SlideActionType? actionType);
/// given [actionType].
///
/// Used by [SlideToDismissDelegate.onWillDismiss].
typedef SlideActionWillBeDismissed = FutureOr<bool> Function(
typedef SlideActionWillBeDismissed = Future<bool?> Function(
SlideActionType? actionType);

/// Signature for the builder callback used to create slide actions.
Expand Down Expand Up @@ -840,7 +840,7 @@ class SlidableState extends State<Slidable>
_overallMoveController.value == _overallMoveController.upperBound &&
!_dragUnderway) {
if (widget.dismissal!.onWillDismiss == null ||
await widget.dismissal!.onWillDismiss!(actionType)) {
await widget.dismissal!.onWillDismiss!(actionType) == true) {
_startResizeAnimation();
} else {
_dismissing = false;
Expand Down

0 comments on commit 768fa88

Please sign in to comment.