main.dart 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import 'dart:io';
  2. import 'package:flutter/material.dart';
  3. import 'package:flutter/services.dart';
  4. import 'package:provider/provider.dart';
  5. import 'package:video/model/refreshModel.dart';
  6. import 'package:video/model/urlModel.dart';
  7. import 'package:video/providers/providerManager.dart';
  8. import 'package:video/utils/router.dart' as router;
  9. import 'screen/loading.dart';
  10. void main() {
  11. runApp(MyApp());
  12. if (Platform.isAndroid) {
  13. // 以下两行 设置android状态栏为透明的沉浸。写在组件渲染之后,是为了在渲染后进行set赋值,覆盖状态栏,写在渲染之前MaterialApp组件会覆盖掉这个值。
  14. SystemUiOverlayStyle systemUiOverlayStyle =
  15. SystemUiOverlayStyle(statusBarColor: Colors.transparent);
  16. SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle);
  17. }
  18. }
  19. class MyApp extends StatelessWidget {
  20. @override
  21. Widget build(BuildContext context) {
  22. return MultiProvider(
  23. providers: providers, //监听共享实例
  24. child: Consumer2<UrlInfo, Refresh>(
  25. builder: (context, themeModel, localeModel, child) {
  26. return MaterialApp(
  27. debugShowCheckedModeBanner: false,
  28. title: '电影',
  29. theme: ThemeData(
  30. primarySwatch: Colors.blueGrey,
  31. ),
  32. onGenerateRoute: router.generateRoute,
  33. home: new LoadingPage(),
  34. );
  35. },
  36. ),
  37. );
  38. }
  39. }