Flutter在MaterialApp中的builder初始化多个包

问题描述

我使用的flutter_easyloading 和responsive_framework这两个插件都需要在Material中的builder进行初始化。以前的单个写法为

GetMaterialApp(
 builder:EasyLoading.init()
)

GetMaterialApp(
  builder: (context, child) => ResponsiveBreakpoints.builder(
        child: child!,
        breakpoints: [
          const Breakpoint(start: 0, end: 450, name: MOBILE),
          const Breakpoint(start: 451, end: 800, name: TABLET),
          const Breakpoint(start: 801, end: 1920, name: DESKTOP),
          const Breakpoint(start: 1921, end: double.infinity, name: '4K'),
        ],
      ),
)

解决办法

final easyload = EasyLoading.init();
MaterialApp(
   title: 'xxxx',
   builder: (context, child) {
    child = easyload(context, child);
    child =  ResponsiveBreakpoints.builder(
          child: child!,
          breakpoints: [
              const Breakpoint(start: 0, end: 450, name: MOBILE),
              const Breakpoint(start: 451, end: 800, name: TABLET),
          ],
    );
    return child;
   }
)
相关推荐
XMJ20024 小时前
flutter插件:录制系统播放的声音
java·flutter
我码玄黄5 小时前
Flutter踩坑:原生安卓页面向Flutter通信
android·flutter
问道飞鱼5 小时前
【前端知识】Vue组件Vuex详细介绍
前端·vue.js·flutter·vuex
web守墓人5 小时前
【flutter】flutter2升级到3.
flutter
cungudafa8 小时前
【IOS】Undefined symbol: _OBJC_CLASS_$_PAGFile
flutter·ios
我码玄黄10 小时前
Flutter踩坑:原生IOS页面向Flutter通信
前端·flutter·ios
problc19 小时前
Flutter中的Material Theme完全指南:从入门到实战
android·flutter
绘绘~1 天前
android studio new flutter project-运行第一个flutter项目
android·flutter·android studio