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;
   }
)
相关推荐
恋猫de小郭7 小时前
Android Keep Rules 解读,直接影响 Google Play 上架和曝光
android·前端·flutter
恋猫de小郭1 天前
Flutter A2UI 1.0 ,原来的 genui 也正式换成了这一套 SDK 了
android·前端·flutter
LinXunFeng1 天前
A2UI 1.0 详解:让 AI 生成 Flutter 界面,还不怕它乱写
前端·flutter·agent
好的佩奇2 天前
Dart 之元数据与注解
android·flutter·dart
恋猫de小郭4 天前
Jetpack Compose 1.13 发布,憋了这么久终有交代了
android·前端·flutter
好的佩奇5 天前
蓝牙之设备角色与连接
android·flutter·蓝牙
SoaringHeart6 天前
Flutter最佳实践:用 flutter_html 渲染富文本
前端·flutter
恋猫de小郭6 天前
Flutter 3.50.0 Release 的第一个崩溃,修好了,还没 hotfix
android·前端·flutter
程序员老刘7 天前
跨平台开发地图 | 2026年11月
flutter·ai编程·客户端
传奇开心果编程7 天前
【Flutter踩坑排雷】第30课:异常未捕获坑|未捕获异常直接闪退,全局兜底故障处理
android·flutter·ios·移动开发·dart·ui框架·声明式ui