modal_bottom_sheet
modal_bottom_sheet copied to clipboard
bug: IconTheme is overridden when using CupertinoScaffold
Hey,
Thanks for this package, it helps us a lot with modals & bottom sheets on our projects.
I noticed what I believe is a bug when using a CupertinoScaffold
in my app. My app has a custom IconTheme
, with a fixed size to 20, a fixed color, ... If I get the IconTheme
from anywhere in my app with the following, everything is fine.
final iconTheme = IconTheme.of(context);
final size = iconTheme.size;
print(size); //Result is 20
When I add a CupertinoScaffold
on top of it, then getting the icon theme size is not ok anymore:
final iconTheme = IconTheme.of(context);
final size = iconTheme.size;
print(size); //Result is 24
After a bit of investigation, I believe it's due to the _CupertinoModalTransition
adding a CupertinoTheme
, that adds an IconTheme
in it's build method with a fixed CupertinoIconThemeData
: flutter/lib/src/cupertino/theme.dart
file, line 121 to 126:
@override
Widget build(BuildContext context) {
return _InheritedCupertinoTheme(
theme: this,
child: IconTheme(
data: CupertinoIconThemeData(color: data.primaryColor),
child: child,
),
);
}
To fix this temporarily, I am overriding the IconTheme
under the CupertinoScaffold
with my previous IconTheme
but it's more a hack than a fix:
@override
Widget build(BuildContext context) {
final iconTheme = IconTheme.of(context);
return CupertinoScaffold(
body: IconTheme(
data: iconTheme,
child: child,
),
);
}
Any idea how to fix this properly? I would be glad to help if someone has an idea for a clean fix.