flutter_device_preview icon indicating copy to clipboard operation
flutter_device_preview copied to clipboard

Prerelease theming issues

Open davidmartos96 opened this issue 3 years ago • 2 comments

@aloisdeniel I was trying out the prerelease version and I found that the new changes with the appBuilder theme is causing issues when handling those properties inside the app.

image

On my case the issue is with the brightness, because I use different themes inside the app, each one with the correct brightness. The new appBuilder is overriding the brightness property. Analogously, if someone is setting the visualDensity, it will be overriden as well, although that may be more rare than handling the brightness.

My suggestion would be to include a third option to the Dark/Light switch to don't override it or a global option to not override the MaterialApp theme

davidmartos96 avatar Oct 10 '20 11:10 davidmartos96

I don't know, because the default value is Brightness.system which means that it is whether one or the other based on the system settings. I will think about adding an option to override this behaviour. Thanks for the feedback!

Anyway, in the meantime, you should be able to override the default behaviour like this :

MaterialApp(
   builder: (context, child) {
       return DevicePreview.appBuilder(context, 
           child: Builder(builder: (context) {
                 return Theme.of(context).copyWith(
                      brightness: Brightness.light,
                 );
           }
       );
   }
);

aloisdeniel avatar Oct 10 '20 12:10 aloisdeniel

Yes, in the meantime customizing the DevicePreview.appBuilder by overriding again the theme seems like the only option. When I saw the weird theme issue I was having, I thought it was because of the Flutter 1.22 update, but it turned out to be device_preview :sweat_smile:

davidmartos96 avatar Oct 10 '20 12:10 davidmartos96