Skip to content

Instantly share code, notes, and snippets.

@Lootwig
Created November 8, 2021 22:30
Show Gist options
  • Save Lootwig/c3194e856a44cad3f1ed4804fc561a49 to your computer and use it in GitHub Desktop.
Save Lootwig/c3194e856a44cad3f1ed4804fc561a49 to your computer and use it in GitHub Desktop.
Navigator resets when inspector is used to select widget
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