Skip to content

MacosThemeData should implement value equality #505

@craigdfoster

Description

@craigdfoster

The MacosThemeData class does not implement value equality as ThemeData from the Material package does.

This causes _InheritedMacosTheme.updateShouldNotify to return true on every widget tree rebuild if, for example, the light theme and dark theme are instantiated the way they are in the MacosUI sample project.

class _InheritedMacosTheme extends InheritedWidget {
  // ignore: use_super_parameters
  const _InheritedMacosTheme({
    Key? key,
    required this.theme,
    required super.child,
  }) : super(key: key);

  final MacosTheme theme;

  /// Will always return true when MacosThemeData objects are instantiated inline in MyApp example below
  @override
  bool updateShouldNotify(_InheritedMacosTheme old) =>
      theme.data != old.theme.data;
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return MacosApp(
      theme: MacosThemeData.light(),
      darkTheme: MacosThemeData.dark(),
      themeMode: ThemeMode.system,
    );
  }
}

Steps To Reproduce

See Flutter-Bounty-Hunters/super_editor#1568

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions