Skip to content

Instantly share code, notes, and snippets.

@shivanchalaeologic
Last active August 11, 2020 13:38
Show Gist options
  • Save shivanchalaeologic/a4ae57023337415312eebc6f79988de3 to your computer and use it in GitHub Desktop.
Save shivanchalaeologic/a4ae57023337415312eebc6f79988de3 to your computer and use it in GitHub Desktop.
import 'package:flutter/material.dart';
import 'package:flutter_route_obser/main.dart';
class PageTwo extends StatefulWidget {
@override
_PageTwoState createState() => _PageTwoState();
}
class _PageTwoState extends State<PageTwo> with RouteAware {
@override
void didChangeDependencies() {
super.didChangeDependencies();
routeObserver.subscribe(this, ModalRoute.of(context));
}
@override
void dispose() {
routeObserver.unsubscribe(this);
super.dispose();
}
@override
void didPush() {
print('didPush Page2');
}
@override
void didPopNext() {
print('didPopNext Page2');
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(),
body: Column(
children: <Widget>[
Center(
child: Text("PAGE TWO"),
),
],
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment