Does flutter have a method like Activity.resume()
which can tell developer the user has gone back to the activity.
When I pick the data from internet in
I don't think flutter app lifecycle callbacks are going to help you here. You can try this logic.
In 1st page (when navigating to 2nd page)
Navigator.push(context, MaterialPageRoute(builder: (context) => Page2())).then((value) {
print("Value returned form Page 2 = $value");
};
In 2nd page (when navigating back to 1st page)
Navigator.pop(context, returnedValue);
Lifecycle callback
void main() => runApp(HomePage());
class HomePage extends StatefulWidget {
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State with WidgetsBindingObserver {
@override
void initState() {
super.initState();
WidgetsBinding.instance.addObserver(this);
}
@override
void didChangeAppLifecycleState(AppLifecycleState state) {
super.didChangeAppLifecycleState(state);
print("Current state = $state");
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: Text("Lifecycle")),
body: Center(child: Text("Center"),),
),
);
}
@override
void dispose() {
WidgetsBinding.instance.removeObserver(this);
super.dispose();
}
}