I'm trying to understand well the Flutter Lifecycle and I'm not sure that is normal that events like PUSH a view occurs twice. I'm searching for a event that occurs one time only when the view is showed. For example: ViewA is showed eventImSearchingOn occurs one only time. ViewA open ViewB, ViewA is deactivate. ViewB go back to ViewA and eventImSearchingOn occurs one only time.
The log of the code that I've tried:
InitState SplashScreenUI
ChangeDependencies SplashScreenUI
PUSH SplashScreenUI
InitState SplashScreenUI
ChangeDependencies SplashScreenUI
PUSH SplashScreenUI
Main Class
@override
Widget build(BuildContext context) {
return StoreProvider<AppState>(
store: widget.store,
child: MaterialApp(
...
....
initialRoute: '/SplashScreen',
home: SplashScreenUI(),
navigatorKey: Keys.navKey,
navigatorObservers: [Keys.routeObserver],
routes: <String, WidgetBuilder>{
'/Home': (BuildContext context) => HomePageUI(),
'/Login': (BuildContext context) => LoginPageUI(),
'/Routine': (BuildContext context) => RoutineUI(),
'/Notifications': (BuildContext context) => NotificationsUI(),
'/Chat': (BuildContext context) => ChatUI(),
'/Profile': (BuildContext context) => ProfileUI(),
'/ProfileForm': (BuildContext context) => ProfileFormUI(),
'/Interview': (BuildContext context) => InterviewUI(),
'/BodyCheck': (BuildContext context) => BodyCheckUI(),
'/SplashScreen': (BuildContext context) => SplashScreenUI(),
SplashScreen Class
class _SplashScreenUIState extends State<SplashScreenUI> with RouteAware{
_SplashScreenUIState();
@override
void initState() {
print("InitState SplashScreenUI");
super.initState();
store.dispatch(CheckLogIn());
}
@override
void didChangeDependencies() {
print("ChangeDependencies SplashScreenUI");
super.didChangeDependencies();
Keys.routeObserver.subscribe(this, ModalRoute.of(context));
}
@override
void deactivate() {
print("Deactivate SplashScreenUI");
super.deactivate();
}
@override
void dispose() {
print("Dispose SplashScreenUI");
Keys.routeObserver.unsubscribe(this);
super.dispose();
}
@override
void didPush() {
print("PUSH SplashScreenUI");
}
@override
void didPopNext() {
print("POP SplashScreenUI");
}