Codelessly / ResponsiveFramework

Easily make Flutter apps responsive. Automatically adapt UI to different screen sizes. Responsiveness made simple. Demo: https://gallery.codelessly.com/flutterwebsites/minimal/
https://codelessly.com
MIT License
1.28k stars 151 forks source link

Command "Inspect Widget" resets state when using ResponsiveWrapper #91

Closed Eerey closed 1 year ago

Eerey commented 2 years ago

Whenever I enable/disable "Inspect Widget" the entire app state is reset. Here is how I use ResponsiveWrapper (see below). I appreciate any help :)


class MainApp extends StatelessWidget {
  const MainApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) => MainBlocProvider(
        child: Builder(builder: (context) {
          final appRouter = CUSTOMER_VIEW ? customerRouter : router;
          return MaterialApp.router(
            debugShowCheckedModeBanner: false,
            // scrollBehavior: CupertinoScrollBehavior(),
            routeInformationParser: appRouter.routeInformationParser,
            routerDelegate: appRouter.routerDelegate,
            builder: (context, child) => MainResponsiveBuilder(
              child: child ?? NoMainChildErrorPage(),
            ),
          );
        }),
      );
}

class MainResponsiveBuilder extends StatelessWidget {
  const MainResponsiveBuilder({Key? key, required this.child})
      : super(key: key);
  final Widget child;

  @override
  Widget build(BuildContext context) => ResponsiveWrapper.builder(
        BouncingScrollWrapper.builder(context, child),
        minWidth: 1024,
        defaultScale: true,
        mediaQueryData: MediaQuery.of(context).copyWith(textScaleFactor: 1),
        alignment: Alignment.center,
        defaultScaleFactor: 1,
        defaultScaleLandscape: true,
        breakpoints: [
          const ResponsiveBreakpoint.resize(450, name: MOBILE),
          const ResponsiveBreakpoint.autoScale(1000, name: DESKTOP),
          const ResponsiveBreakpoint.autoScale(1200,
              scaleFactor: 0.7, name: DESKTOP),
          const ResponsiveBreakpoint.autoScale(2000,
              scaleFactor: 1.5, name: "4K"),
        ],
      );
}
abigotado commented 2 years ago

I think the problem is not in the responsive_framework library, but in the router. I have the same problem in the app with router, but without responsive_framework.