瀏覽代碼

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

tags/0.0.14+2^0
PH2 3 年之前
父節點
當前提交
3742c0d4ed
共有 2 個檔案被更改,包括 2 行新增45 行删除
  1. +1
    -1
      example/lib/main.dart
  2. +1
    -44
      lib/pages/home_page/home_page.dart

+ 1
- 1
example/lib/main.dart 查看文件

@@ -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 查看文件

@@ -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…
取消
儲存