|
|
@@ -51,7 +51,7 @@ class HomePage extends StatefulWidget { |
|
|
|
_HomePageState createState() => _HomePageState(); |
|
|
|
} |
|
|
|
|
|
|
|
class _HomePageState extends LifeState<HomePage> with WidgetsBindingObserver, TickerProviderStateMixin, AutomaticKeepAliveClientMixin { |
|
|
|
class _HomePageState extends State<HomePage> with WidgetsBindingObserver, TickerProviderStateMixin, AutomaticKeepAliveClientMixin { |
|
|
|
int _currentIndex = 0; |
|
|
|
List<Map<String, dynamic>> _data = List(); |
|
|
|
static const EventChannel _eventChannel = const EventChannel('JAVA_TO_FLUTTER'); |
|
|
@@ -453,46 +453,3 @@ class _HomePageState extends LifeState<HomePage> with WidgetsBindingObserver, Ti |
|
|
|
// TODO: implement wantKeepAlive |
|
|
|
bool get wantKeepAlive => true; |
|
|
|
} |
|
|
|
|
|
|
|
final RouteObserver<Route> lifeObserver = RouteObserver(); |
|
|
|
|
|
|
|
abstract class LifeState<T extends StatefulWidget> extends State<T> with RouteAware { |
|
|
|
@override |
|
|
|
void initState() { |
|
|
|
super.initState(); |
|
|
|
} |
|
|
|
|
|
|
|
@override |
|
|
|
void didChangeDependencies() { |
|
|
|
lifeObserver.subscribe(this, ModalRoute.of(context)); |
|
|
|
super.didChangeDependencies(); |
|
|
|
} |
|
|
|
|
|
|
|
@override |
|
|
|
void dispose() { |
|
|
|
lifeObserver.unsubscribe(this); |
|
|
|
super.dispose(); |
|
|
|
} |
|
|
|
|
|
|
|
void didPop() { |
|
|
|
onPaused(); |
|
|
|
} |
|
|
|
|
|
|
|
void didPopNext() { |
|
|
|
onResume(); |
|
|
|
print("回到首页"); |
|
|
|
setState(() {}); |
|
|
|
} |
|
|
|
|
|
|
|
void didPush() { |
|
|
|
onResume(); |
|
|
|
} |
|
|
|
|
|
|
|
void didPushNext() { |
|
|
|
onPaused(); |
|
|
|
} |
|
|
|
|
|
|
|
void onResume(); |
|
|
|
|
|
|
|
void onPaused(); |
|
|
|
} |