public IconTheme( Key key = null, IconThemeData data = null, Widget child = null ) : base(key: key, child: child) { D.assert(data != null); D.assert(child != null); this.data = data; }
static IconThemeData _getInheritedIconThemeData(BuildContext context) { IconTheme iconTheme = (IconTheme)context.inheritFromWidgetOfExactType(typeof(IconTheme)); if (iconTheme != null) { return(iconTheme.data); } return(IconThemeData.fallback()); }
public static IconThemeData of(BuildContext context) { IconThemeData iconThemeData = _getInheritedIconThemeData(context).resolve(context); return(iconThemeData.isConcrete ? iconThemeData : iconThemeData.copyWith( size: iconThemeData.size ?? IconThemeData.fallback().size, color: iconThemeData.color ?? IconThemeData.fallback().color, opacity: iconThemeData.opacity ?? IconThemeData.fallback().opacity )); }
public static Widget merge( Key key = null, IconThemeData data = null, Widget child = null ) { return(new Builder( builder: context => new IconTheme( key: key, data: _getInheritedIconThemeData(context).merge(data), child: child ) )); }
public override Widget build(BuildContext context) { IconThemeData iconTheme = IconTheme.of(context); float iconSize = this.size ?? iconTheme.size.Value; if (this.icon == null) { return(new SizedBox(width: iconSize, height: iconSize)); } float iconOpacity = iconTheme.opacity.Value; Color iconColor = this.color ?? iconTheme.color; if (iconOpacity != 1.0) { iconColor = iconColor.withOpacity(iconColor.opacity * iconOpacity); } Widget iconWidget = new RichText( overflow: TextOverflow.visible, text: new TextSpan( text: new string(new[] { (char)this.icon.codePoint }), style: new TextStyle( inherit: false, color: iconColor, fontSize: iconSize, fontFamily: this.icon.fontFamily ) ) ); return(new SizedBox( width: iconSize, height: iconSize, child: new Center( child: iconWidget ) )); }
static IconThemeData _getInheritedIconThemeData(BuildContext context) { IconTheme iconTheme = (IconTheme)context.dependOnInheritedWidgetOfExactType <IconTheme>(); return(iconTheme?.data ?? IconThemeData.fallback()); }
public override Widget build(BuildContext context) { D.assert(this.textDirection != null || WidgetsD.debugCheckHasDirectionality(context)); TextDirection textDirection = this.textDirection ?? Directionality.of(context); IconThemeData iconTheme = IconTheme.of(context); float iconSize = size ?? iconTheme.size.Value; if (icon == null) { return(new SizedBox(width: iconSize, height: iconSize)); } float iconOpacity = iconTheme.opacity.Value; Color iconColor = color ?? iconTheme.color; if (iconOpacity != 1.0) { iconColor = iconColor.withOpacity(iconColor.opacity * iconOpacity); } Widget iconWidget = new RichText( overflow: TextOverflow.visible, // Never clip. textDirection: textDirection, // Since we already fetched it for the assert... text: new TextSpan( text: new string(new[] { (char)icon.codePoint }), style: new TextStyle( inherit: false, color: iconColor, fontSize: iconSize, fontFamily: icon.fontFamily ) ) ); var matrix = Matrix4.identity(); matrix.scale(-1.0f, 1.0f, 1.0f); if (icon.matchTextDirection) { switch (textDirection) { case TextDirection.rtl: iconWidget = new Transform( transform: matrix, alignment: Alignment.center, transformHitTests: false, child: iconWidget ); break; case TextDirection.ltr: break; } } return(new SizedBox( width: iconSize, height: iconSize, child: new Center( child: iconWidget ) )); }
public static IconThemeData of(BuildContext context) { IconThemeData iconThemeData = _getInheritedIconThemeData(context); return(iconThemeData.isConcrete ? iconThemeData : IconThemeData.fallback().merge(iconThemeData)); }