Created
November 8, 2021 22:30
-
-
Save Lootwig/c3194e856a44cad3f1ed4804fc561a49 to your computer and use it in GitHub Desktop.
Navigator resets when inspector is used to select widget
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(X()); | |
class X extends StatelessWidget { | |
const X({Key? key}) : super(key: key); | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
builder: (context, child) { | |
return Navigator( | |
onPopPage: (route, dynamic result) { | |
return route.didPop(result); | |
}, | |
pages: [ | |
MaterialPage<void>( | |
child: FirstPage(), | |
), | |
], | |
); | |
}, | |
); | |
} | |
} | |
class FirstPage extends StatelessWidget { | |
const FirstPage({ | |
Key? key, | |
}) : super(key: key); | |
@override | |
Widget build(BuildContext context) { | |
return Center( | |
child: GestureDetector( | |
child: Text('1'), | |
onTap: () => Navigator.of(context).push<void>( | |
MaterialPageRoute( | |
builder: (context) { | |
return const Text('2'); | |
}, | |
), | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment