add a new PopScope.onPopWithResultInvoke widget to replace PopScope.onPopInvoke (#147016)
same as https://github.com/flutter/flutter/pull/139164, but make it a soft transition
This commit is contained in:
@@ -48,7 +48,7 @@ class CupertinoNavigationDemo extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return PopScope(
|
||||
return PopScope<Object?>(
|
||||
// Prevent swipe popping of this page. Use explicit exit buttons only.
|
||||
canPop: false,
|
||||
child: DefaultTextStyle(
|
||||
|
||||
@@ -110,7 +110,7 @@ class FullScreenDialogDemoState extends State<FullScreenDialogDemo> {
|
||||
bool _hasName = false;
|
||||
late String _eventName;
|
||||
|
||||
Future<void> _handlePopInvoked(bool didPop) async {
|
||||
Future<void> _handlePopInvoked(bool didPop, Object? result) async {
|
||||
if (didPop) {
|
||||
return;
|
||||
}
|
||||
@@ -175,7 +175,7 @@ class FullScreenDialogDemoState extends State<FullScreenDialogDemo> {
|
||||
),
|
||||
body: Form(
|
||||
canPop: !_saveNeeded && !_hasLocation && !_hasName,
|
||||
onPopInvoked: _handlePopInvoked,
|
||||
onPopInvokedWithResult: _handlePopInvoked,
|
||||
child: Scrollbar(
|
||||
child: ListView(
|
||||
primary: true,
|
||||
|
||||
@@ -143,7 +143,7 @@ class TextFormFieldDemoState extends State<TextFormFieldDemo> {
|
||||
return null;
|
||||
}
|
||||
|
||||
Future<void> _handlePopInvoked(bool didPop) async {
|
||||
Future<void> _handlePopInvoked(bool didPop, Object? result) async {
|
||||
if (didPop) {
|
||||
return;
|
||||
}
|
||||
@@ -192,7 +192,7 @@ class TextFormFieldDemoState extends State<TextFormFieldDemo> {
|
||||
key: _formKey,
|
||||
autovalidateMode: _autovalidateMode,
|
||||
canPop: _formKey.currentState == null || !_formWasEdited || _formKey.currentState!.validate(),
|
||||
onPopInvoked: _handlePopInvoked,
|
||||
onPopInvokedWithResult: _handlePopInvoked,
|
||||
child: Scrollbar(
|
||||
child: SingleChildScrollView(
|
||||
primary: true,
|
||||
|
||||
@@ -355,7 +355,7 @@ class ExpandingBottomSheetState extends State<ExpandingBottomSheet> with TickerP
|
||||
|
||||
// Closes the cart if the cart is open, otherwise exits the app (this should
|
||||
// only be relevant for Android).
|
||||
void _handlePopInvoked(bool didPop) {
|
||||
void _handlePopInvoked(bool didPop, Object? result) {
|
||||
if (didPop) {
|
||||
return;
|
||||
}
|
||||
@@ -370,9 +370,9 @@ class ExpandingBottomSheetState extends State<ExpandingBottomSheet> with TickerP
|
||||
duration: const Duration(milliseconds: 225),
|
||||
curve: Curves.easeInOut,
|
||||
alignment: FractionalOffset.topLeft,
|
||||
child: PopScope(
|
||||
child: PopScope<Object?>(
|
||||
canPop: !_isOpen,
|
||||
onPopInvoked: _handlePopInvoked,
|
||||
onPopInvokedWithResult: _handlePopInvoked,
|
||||
child: AnimatedBuilder(
|
||||
animation: widget.hideController,
|
||||
builder: _buildSlideAnimation,
|
||||
|
||||
@@ -326,9 +326,9 @@ class _GalleryHomeState extends State<GalleryHome> with SingleTickerProviderStat
|
||||
backgroundColor: isDark ? _kFlutterBlue : theme.primaryColor,
|
||||
body: SafeArea(
|
||||
bottom: false,
|
||||
child: PopScope(
|
||||
child: PopScope<Object?>(
|
||||
canPop: _category == null,
|
||||
onPopInvoked: (bool didPop) {
|
||||
onPopInvokedWithResult: (bool didPop, Object? result) {
|
||||
if (didPop) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user