Last active
February 6, 2020 03:23
-
-
Save micimize/62bdb23c610dbe89a858e0fec70fce18 to your computer and use it in GitHub Desktop.
'package:flutter/src/widgets/will_pop_scope.dart': Failed assertion: line 59 pos 12: '_route == ModalRoute.of(context)': is not true.
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
import 'package:flutter/material.dart'; | |
void main() => runApp(FormPopExample()); | |
class FormPopExample extends StatefulWidget { | |
@override | |
_FormPopExampleState createState() => _FormPopExampleState(); | |
} | |
class _FormPopExampleState extends State<FormPopExample> { | |
GlobalKey<NavigatorState> navState; | |
@override | |
void initState() { | |
super.initState(); | |
navState = GlobalKey<NavigatorState>(); | |
} | |
Widget pageContent( | |
BuildContext context, | |
Widget content, | |
) => | |
Navigator( | |
key: navState, | |
onGenerateRoute: (route) { | |
return; | |
}, | |
); | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
home: Scaffold( | |
appBar: AppBar(leading: BackButton(), title: Text('form pop')), | |
body: Builder( | |
builder: (context) => RaisedButton( | |
onPressed: () => Navigator.of(context).push( | |
MaterialPageRoute<Object>( | |
maintainState: true, | |
builder: (context) => FormPop(), | |
), | |
), | |
child: Hero( | |
tag: 'form', | |
child: Text('push form'), | |
), | |
), | |
), | |
), | |
); | |
} | |
} | |
class FormPop extends StatefulWidget { | |
@override | |
_FormPopState createState() => _FormPopState(); | |
} | |
class _FormPopState extends State<FormPop> { | |
final _formKey = GlobalKey<FormState>(); | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar(leading: BackButton(), title: Text('form pop')), | |
body: Hero( | |
tag: 'form', | |
child: Form( | |
key: _formKey, | |
child: Container( | |
child: Text("wooweee look at me"), | |
), | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
minimal reproduction of flutter/flutter#49952