问题描述

我使用的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;
   }
)
11-19 16:27