基础组件库
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 
 

56 wiersze
1.7 KiB

  1. import 'package:connectivity/connectivity.dart';
  2. import 'package:flutter/cupertino.dart';
  3. import 'package:flutter/material.dart';
  4. import 'package:zhiying_base_widget/pages/home_page/home_page.dart';
  5. import 'package:zhiying_comm/util/application.dart';
  6. import 'package:zhiying_comm/zhiying_comm.dart';
  7. // 启动页,页面初始化等操作~跟原生启动页保持一致,防止白屏问题
  8. class LaunchPage extends StatefulWidget {
  9. final WidgetBuilder builder;
  10. const LaunchPage({Key key, this.builder}) : super(key: key);
  11. @override
  12. _LaunchPageState createState() => _LaunchPageState();
  13. }
  14. class _LaunchPageState extends State<LaunchPage> {
  15. @override
  16. void initState() {
  17. Connectivity().checkConnectivity().then((connectivityResult) {
  18. if (connectivityResult == ConnectivityResult.mobile ||
  19. connectivityResult == ConnectivityResult.wifi) {
  20. // I am connected to a wifi network.
  21. Logger.debug('ConnectivityResult.wifi');
  22. print('ConnectivityResult.wifi');
  23. Application.init().then((_) {
  24. if (widget.builder != null) {
  25. Navigator.of(context)
  26. .pushReplacement(CupertinoPageRoute(builder: widget.builder));
  27. } else {
  28. Navigator.of(context).pushReplacement(
  29. CupertinoPageRoute(builder: (context) => HomePage()));
  30. }
  31. }).catchError((err) {
  32. Logger.error(err);
  33. });
  34. } else {
  35. Logger.error('未知网络,APP初始化失败');
  36. print('unknow');
  37. }
  38. });
  39. super.initState();
  40. }
  41. @override
  42. Widget build(BuildContext context) {
  43. return Image.asset(
  44. 'assets/images/launch_image/launch_image.png',
  45. package: 'zhiying_base_widget',
  46. fit: BoxFit.cover,
  47. );
  48. }
  49. }