Last updated:
0 purchases
route life
if you wan to listen route lifecycle in widget, this is a way.
Usage #
1.import route_life.dart
import 'package:route_life/route_life.dart';
copied to clipboard
2.set navigatorObservers
RouteLifeObserver routeLifeObserver = RouteLifeObserver();
MaterialApp(
navigatorObservers: [
routeLifeObserver
],
);
copied to clipboard
with RouteLifeMixin or AppLifeMixin
class _GamePageState extends State<GamePage> with RouteLifeMixin,AppLifeMixin{
@override
void initState() {
super.initState();
_playGamePageMusic();
}
@override
void dispose() {
_stopGamePageMusic();
super.dispose();
}
@override
void onRoutePause(Route nextRoute) {
_pauseGamePageMusic();
}
@override
void onRouteResume(Route nextRoute) {
_resumeGamePageMusic();
}
@override
void onAppLifeChanged(bool resume) {
if(!isRouteShowing){
return;
}
if(resume){
_resumeGamePageMusic();
}else{
_pauseGamePageMusic();
}
}
}
copied to clipboard
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.