Skip to content

Instantly share code, notes, and snippets.

@micimize
Last active February 6, 2020 03:23
Show Gist options
  • Save micimize/62bdb23c610dbe89a858e0fec70fce18 to your computer and use it in GitHub Desktop.
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.
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"),
),
),
),
);
}
}
@micimize
Copy link
Author

micimize commented Feb 6, 2020

minimal reproduction of flutter/flutter#49952

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment