123456789101112131415161718192021222324252627282930313233343536373839 |
- /*
- * @Author: XianKaiQun
- * @Date: 2020-09-08 11:18:16
- * @LastEditors: XianKaiQun
- * @LastEditTime: 2020-09-08 16:13:03
- * @Description:
- */
- import 'package:flutter/widgets.dart';
- import 'package:wisdom_cli/wisdom_ui.dart';
- ///主题
- class WTheme extends InheritedTheme {
- final WThemeData? data;
- final Widget child;
- WTheme({Key? key, this.data, required this.child}) : super(key: key, child: child);
- static WThemeData of(BuildContext context) {
- final WThemeData themeData =
- _getInheritedWThemeData(context).resolve(context);
- return themeData;
- }
- @override
- bool updateShouldNotify(WTheme oldWidget) {
- return oldWidget.data != data;
- }
- @override
- Widget wrap(BuildContext context, Widget child) {
- final WTheme? theme = context.findAncestorWidgetOfExactType<WTheme>();
- return identical(this, theme) ? child : WTheme(data: data, child: child);
- }
- static WThemeData _getInheritedWThemeData(BuildContext context) {
- final WTheme? theme = context.dependOnInheritedWidgetOfExactType<WTheme>();
- return theme?.data ?? WThemeData.fallback();
- }
- }
|