Open mdccxv opened 3 years ago
I second this. Patiently waiting for a fix
Same here, any solution available?
@JonathanRhein I ended up using just a regular showModalBottomSheet
instead of Get.bottomSheet
. Didn't find a solution though
@mdccxv Thank you! Yes, I will have to do the same which is a bit unfortunate... let's hope there comes a fix soon :-) How do you make the modalBottomSheet reactive to theme changes without using setState()
or a StatefulBuilder
in this case? showModalBottomSheet
cannot be wrapped with GetBuilder
in order to be updated on update()
...
@JonathanRhein Get.changeThemeMode
works well provided you have set up theme
and darkTheme
in your GetMaterialApp
. It works globally on all the widgets in your app, including modalBottomSheet you're calling the change from.
That is what I did and all other widgets are updated accordingly when I call Get.changeThemeMode
, but for some reason it does not change the backgroundColor
property of showModalBottomSheet
. So I specified a Container
in the builder
of the showModalBottomSheet
to contain all rest of my bottomSheet
and made this Container's color property the theme
dependent color (using Get.context.theme.scaffoldBackgroundColor
) and it works now. Don't understand though why using backgroundColor
of showModalBottomSheet
does not work... but thank you for your help @mdccxv!!
In this example I am checking if Dark mode is available and setting Container background color accordingly. In next example I just used container inside Bottom sheet without any additional theme configuration (second screencast).
Get.bottomSheet(
Container(
child: Wrap(
children: [
ListTile(
leading: const Icon(Icons.wb_sunny_outlined),
title: Text('Light Theme'),
onTap: () => {Get.changeTheme(ThemeData.light())},
),
ListTile(
leading: const Icon(Icons.wb_sunny),
title: Text('Dark Theme'),
onTap: () => {Get.changeTheme(ThemeData.dark())},
)
],
),
),
backgroundColor:
Get.isDarkMode ? Colors.black : Colors.white);
},
Result:
any updates on this issue??
Also having the same issue with this setup... haven't found a fix if anyone has one please share!
any updates for this issue ?
Any updates on this issue ?
Any updates on this issue?
My solution: Wrap the Get.bottomSheet() function
// [Bottom sheet content not reacting to theme change](https://github.com/jonataslaw/getx/issues/1084)
Future<T?> showAppBottomSheet<T>(
Widget bottomsheet, {
RouteSettings? settings,
}) {
return Get.bottomSheet<T>(
Builder(builder: (context) {
final ThemeData data;
switch (MediaQuery.of(context).platformBrightness) {
case Brightness.dark:
data = darkTheme();
break;
case Brightness.light:
data = lightTheme();
break;
}
return Theme(data: data, child: bottomsheet);
}),
backgroundColor: Colors.transparent,
isScrollControlled: true,
settings: settings,
);
}
I am also facing the same issue with using Get.bottomSheet
. The above solution isn't effective when using a bottom navigation bar. Could you please provide an alternative solution?
Describe the bug I am using
Get.bottomSheet
to contain a widget with some app settings, including a toggle for light/dark theme.Get.changeTheme
is used for theme change. When the theme is toggled the screen underneath the bottom sheet changes appearance, but the bottom sheet does not.Reproduction code
To Reproduce
Expected behavior Theme change should apply to the content of bottom sheet
Flutter Version: 1.22.6
Getx Version: 3.24.0
Describe on which device you found the bug: iPhone 12 Pro Max