-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #431 from remonke/remove-willpopscope
Remove WillPopScope
- Loading branch information
Showing
6 changed files
with
70 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:reactive_forms/reactive_forms.dart'; | ||
|
||
class ReactiveFormPopScope extends StatelessWidget { | ||
final bool Function(FormGroup formGroup)? canPop; | ||
final void Function(FormGroup formGroup, bool didPop)? onPopInvoked; | ||
final Widget child; | ||
|
||
const ReactiveFormPopScope({ | ||
super.key, | ||
this.canPop, | ||
this.onPopInvoked, | ||
required this.child, | ||
}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return ReactiveFormConsumer( | ||
builder: (context, formGroup, _) { | ||
return PopScope( | ||
canPop: canPop != null ? canPop!(formGroup) : true, | ||
onPopInvoked: onPopInvoked != null | ||
? (didPop) => onPopInvoked!(formGroup, didPop) | ||
: null, | ||
child: child, | ||
); | ||
}, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters