Use case
I am building a design system outside of material. I don't desire to use MaterialApp or Theme widget to define the UI. I would like the ability to use ThemeExtensions without depending on material's Theme[Data].
Proposal
I would like
ThemeExtension to be defined and exported from package:flutter/widgets.dart
- a new encapsulation of ThemeExtensions in an InheritedWidget or InheritedModel
- a new
.of static method that "feels" some where between ThemeData.extension and in a typical style of InheritedWidget.of
- the ability to introduce ThemeExtensions in a
WidgetsApp (and thus available in CupertinoApp) if not in it's own InheritedWidget
example:
import 'package:flutter/widgets.dart';
void main() {
return runApp(
// new: some inherited model or widget for ThemeExtensions
ThemeExtensions(
child: WidgetsApp(home: Home(), ...),
extensions: const [
MyColor(brandColor: Color(0xFFE53935)),
],
),
);
}
class Home extends StatelessWidget {
@override
Widget build(BuildContext context) {
// new: lookup my extension MyColor with ".of"
final myColor = ThemeExtension.of<MyColor>(context);
return const ColoredBox(color: myColor.brandColor);
}
}
some possibly related issues:
Use case
I am building a design system outside of material. I don't desire to use
MaterialApporThemewidget to define the UI. I would like the ability to useThemeExtensions without depending onmaterial'sTheme[Data].Proposal
I would like
ThemeExtensionto be defined and exported frompackage:flutter/widgets.dart.ofstatic method that "feels" some where betweenThemeData.extensionand in a typical style ofInheritedWidget.ofWidgetsApp(and thus available inCupertinoApp) if not in it's own InheritedWidgetexample:
some possibly related issues:
Themea UbiquitousInheritedWidget #102993Containerequivalent that inherits from a theme #154740