Browse Source

1、智能弹窗除了分享页不显示

tags/0.0.14+2^0
PH2 3 years ago
parent
commit
3742c0d4ed
2 changed files with 2 additions and 45 deletions
  1. +1
    -1
      example/lib/main.dart
  2. +1
    -44
      lib/pages/home_page/home_page.dart

+ 1
- 1
example/lib/main.dart View File

@@ -112,7 +112,7 @@ class _MyAppState extends State<MyApp> {
child: child,
);
},
navigatorObservers: [lifeObserver],
// navigatorObservers: [lifeObserver],
theme: ThemeData(
fontFamily: 'PingFang',
primaryColor: HexColor.fromHex('#FF4242'),


+ 1
- 44
lib/pages/home_page/home_page.dart View File

@@ -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();
}

Loading…
Cancel
Save