flutter_device_preview
flutter_device_preview copied to clipboard
Prerelease theming issues
@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.
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
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,
);
}
);
}
);
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: