Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: IconTheme is overridden when using CupertinoScaffold #346

Open
Cteq3132 opened this issue May 3, 2023 · 0 comments
Open

bug: IconTheme is overridden when using CupertinoScaffold #346

Cteq3132 opened this issue May 3, 2023 · 0 comments

Comments

@Cteq3132
Copy link

Cteq3132 commented May 3, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant