import 'package:flutter/material.dart'; import 'package:zhiying_comm/zhiying_comm.dart'; class FNNavigatorObserver extends NavigatorObserver { factory FNNavigatorObserver() => _getInstance(); static FNNavigatorObserver get instance => _getInstance(); static FNNavigatorObserver _instance; NavigatorObserver curContext; FNNavigatorObserver._(); static FNNavigatorObserver _getInstance() { if (_instance == null) { _instance = new FNNavigatorObserver._(); } return _instance; } String topRouteName = ""; void didPush(Route route, Route previousRoute) { notifyHide(previousRoute); notifyShow(route); } void didPop(Route route, Route previousRoute) { notifyHide(route); notifyShow(previousRoute); } void didRemove(Route route, Route previousRoute) { notifyHide(route); notifyShow(previousRoute); } /// The [Navigator] replaced `oldRoute` with `newRoute`. void didReplace({Route newRoute, Route oldRoute}) { notifyHide(oldRoute); notifyShow(newRoute); } void notifyShow(Route route) {} void notifyHide(Route route) {} }