Ejemplo n.º 1
0
        public static ThemeData of(BuildContext context, bool shadowThemeOnly = false)
        {
            _InheritedTheme inheritedTheme =
                (_InheritedTheme)context.inheritFromWidgetOfExactType(typeof(_InheritedTheme));

            if (shadowThemeOnly)
            {
                if (inheritedTheme == null || inheritedTheme.theme.isMaterialAppTheme)
                {
                    return(null);
                }

                return(inheritedTheme.theme.data);
            }

            //todo:xingwei.zhu: material Localizations
            return(inheritedTheme?.theme?.data ?? _kFallbackTheme);
        }
Ejemplo n.º 2
0
        public static ThemeData of(BuildContext context, bool shadowThemeOnly = false)
        {
            _InheritedTheme inheritedTheme = context.dependOnInheritedWidgetOfExactType <_InheritedTheme>();

            if (shadowThemeOnly)
            {
                if (inheritedTheme == null || inheritedTheme.theme.isMaterialAppTheme)
                {
                    return(null);
                }

                return(inheritedTheme.theme.data);
            }

            MaterialLocalizations localizations = MaterialLocalizations.of(context);
            ScriptCategory        category      = ScriptCategory.englishLike;
            ThemeData             theme         = inheritedTheme?.theme?.data ?? _kFallbackTheme;

            return(ThemeData.localize(theme, theme.typography.geometryThemeFor(category)));
        }
Ejemplo n.º 3
0
        public override Widget wrap(BuildContext context, Widget child)
        {
            _InheritedTheme ancestorTheme = context.findAncestorWidgetOfExactType <_InheritedTheme>();

            return(ReferenceEquals(this, ancestorTheme) ? child : new Theme(data: theme.data, child: child));
        }