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;
   }
)
相关推荐
阅文作家助手开发团队_山神14 小时前
第四章(下) Delta 到 HTML 转换:块级与行内样式渲染深度解析
flutter
MaoJiu15 小时前
Flutter造轮子系列:flutter_permission_kit
flutter·swiftui
阅文作家助手开发团队_山神19 小时前
第四章(下):Delta 到 HTML 转换的核心方法解析
flutter
xiaoyan201521 小时前
flutter3.32+deepseek+dio+markdown搭建windows版流式输出AI模板
flutter·openai·deepseek
阅文作家助手开发团队_山神1 天前
第四章(上):HTML 到 Delta 转换的核心方法解析
flutter
stringwu1 天前
Flutter高效开发利器:Riverpod框架简介及实践指南
flutter
耳東陈1 天前
Flutter开箱即用一站式解决方案2.0-全局无需Context的Toast
flutter
阅文作家助手开发团队_山神2 天前
第三章: Flutter-quill 数据格式Delta
flutter
阅文作家助手开发团队_山神2 天前
第二章:Document 模块与 DOM 树详解
flutter
程序员老刘2 天前
20%的选择决定80%的成败
flutter·架构·客户端