Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Sample code demonstrating back navigation bug in Flutter 1.10.5
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Cupertino Page Transition test'),
),
body: ListView(
children: List.generate(
40,
(int index) {
return ListTile(
title: Text('Item $index'),
onTap: () => Navigator.of(context).push(CupertinoPageDemo.route()),
);
},
),
),
);
}
}
class CupertinoPageDemo extends StatelessWidget {
static Route<dynamic> route() {
return CupertinoPageRoute(
builder: (BuildContext context) {
return CupertinoPageDemo();
},
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: const Text('Second Page'),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment