main.dart 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import 'dart:io';
  2. import 'package:fluro/fluro.dart';
  3. import 'package:flutter/material.dart';
  4. import 'package:flutter/services.dart';
  5. import 'package:provide/provide.dart';
  6. import 'package:flutter_note/routers/application.dart';
  7. import 'package:flutter_note/routers/routers.dart';
  8. import 'package:flutter_note/shop_app.dart';
  9. import 'package:flutter_note/provide/cart_count_provide.dart';
  10. import 'package:flutter_note/provide/cart_provide.dart';
  11. import 'package:flutter_note/provide/home_provide.dart';
  12. import 'package:flutter_note/provide/page_index_provide.dart';
  13. import 'package:flutter_note/provide/goods_detail_provide.dart';
  14. import 'package:flutter_note/provide/mall_goods_provide.dart';
  15. import 'package:flutter_note/provide/sub_category_provide.dart';
  16. //程序入口
  17. void main() {
  18. final providers = Providers()
  19. ..provide(Provider.function((_) => HomeProvide())) // 主页面
  20. ..provide(Provider.function((_) => PageIndexProvide())) // 主页面 tab 切换
  21. ..provide(Provider.function((_) => CartCountProvide())) // 详情页面购物车数量修改
  22. ..provide(Provider.function((_) => SubCategoryProvide())) // 分类页面切换
  23. ..provide(Provider.function((_) => MallGoodsProvide())) // 分类页面刷新加载
  24. ..provide(Provider.function((_) => GoodsDetailProvide())) // 商品详情页面
  25. ..provide(Provider.function((_) => CartProvide())); // 购物车持久化
  26. final Router router = Router();
  27. Routers.configureRouters(router);
  28. Application.router = router;
  29. // 强制竖屏
  30. SystemChrome.setPreferredOrientations([DeviceOrientation.portraitDown, DeviceOrientation.portraitUp]).then((_) {
  31. runApp(ProviderNode(child: ShopApp(), providers: providers));
  32. // android 下透明状态栏
  33. if (Platform.isAndroid) {
  34. SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(statusBarColor: Colors.transparent));
  35. }
  36. });
  37. }