|
|
@@ -50,13 +50,19 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver, Ticker |
|
|
|
int _currentIndex = 0; |
|
|
|
List<Map<String, dynamic>> _data = List(); |
|
|
|
static const EventChannel _eventChannel = const EventChannel('JAVA_TO_FLUTTER'); |
|
|
|
StreamSubscription streamSubscription; |
|
|
|
|
|
|
|
@override |
|
|
|
void initState() { |
|
|
|
|
|
|
|
///初始化一些数据 |
|
|
|
initAsync(); |
|
|
|
|
|
|
|
//如果登出则重新打开首页 |
|
|
|
streamSubscription = EventUtil.instance.on<LogOut>().listen((event) { |
|
|
|
Navigator.maybePop(context); |
|
|
|
Navigator.pushReplacementNamed(context, "/homePage"); |
|
|
|
}); |
|
|
|
|
|
|
|
super.initState(); |
|
|
|
} |
|
|
|
|
|
|
@@ -64,10 +70,11 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver, Ticker |
|
|
|
initAsync() async { |
|
|
|
try { |
|
|
|
WidgetsBinding.instance.addObserver(this); |
|
|
|
|
|
|
|
///渲染完第一帧后调用 |
|
|
|
WidgetsBinding.instance.addPostFrameCallback((timeStamp) { |
|
|
|
int delay=((num.tryParse(AppConfigModel.appStartDelay)??0.5)*1000).toInt(); |
|
|
|
Timer(Duration(milliseconds: delay), (){ |
|
|
|
int delay = ((num.tryParse(AppConfigModel.appStartDelay) ?? 0.5) * 1000).toInt(); |
|
|
|
Timer(Duration(milliseconds: delay), () { |
|
|
|
NativeUtil.notifyInitSuccess(); |
|
|
|
}); |
|
|
|
}); |
|
|
@@ -137,6 +144,7 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver, Ticker |
|
|
|
@override |
|
|
|
void dispose() { |
|
|
|
WidgetsBinding.instance.removeObserver(this); |
|
|
|
streamSubscription.cancel(); |
|
|
|
super.dispose(); |
|
|
|
} |
|
|
|
|
|
|
@@ -262,8 +270,6 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver, Ticker |
|
|
|
/// 3、活动弹窗 |
|
|
|
/// |
|
|
|
Future _showPolicy() async { |
|
|
|
|
|
|
|
|
|
|
|
// 通知弹窗 |
|
|
|
String isShowNotiPermission = await SharedPreferencesUtil.getStringValue(Constants.isShowNotiPermission); |
|
|
|
if (isShowNotiPermission == null || isShowNotiPermission != '1') { |
|
|
@@ -329,8 +335,7 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver, Ticker |
|
|
|
void showAlert(String text, BuildContext context) { |
|
|
|
showDialog( |
|
|
|
context: context, |
|
|
|
builder: (BuildContext context) => |
|
|
|
CupertinoAlertDialog(title: new Text("提示"), content: new Text(text), actions: <Widget>[ |
|
|
|
builder: (BuildContext context) => CupertinoAlertDialog(title: new Text("提示"), content: new Text(text), actions: <Widget>[ |
|
|
|
new FlatButton( |
|
|
|
child: new Text("OK"), |
|
|
|
onPressed: () { |
|
|
@@ -339,5 +344,4 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver, Ticker |
|
|
|
) |
|
|
|
])); |
|
|
|
} |
|
|
|
|
|
|
|
} |