public ShapeBorder resolve(HashSet <MaterialState> states)
 {
     return(new _OutlineBorder(
                shape: shape,
                side: side.copyWith(color: MaterialStateProperty <Color> .resolveAs(side.color, states)
                                    )
                ));
 }
示例#2
0
 public static S resolveAs_MaterialStateProperty <S>(S value, HashSet <MaterialState> states)
 {
     if (value is MaterialStateProperty <S> materialStateProperty)
     {
         MaterialStateProperty <S> property = materialStateProperty;
         return(property.resolve(states));
     }
     return(value);
 }
        public static ShapeBorder resolveAs <ShapeBorder>(ShapeBorder value, HashSet <MaterialState> states)
        {
            if (value is MaterialStateProperty <ShapeBorder> materialStateProperty)
            {
                MaterialStateProperty <ShapeBorder> property = materialStateProperty;
                return(property.resolve(states));
            }

            return(value);
        }
示例#4
0
        public static T resolveAs <T>(T value, HashSet <MaterialState> states)
        {
            if (value is MaterialStateProperty <T> materialStateProperty)
            {
                MaterialStateProperty <T> property = materialStateProperty;
                return(property.resolve(states));
            }

            return(value);
        }
示例#5
0
        public static Color resolveAs <Color>(Color value, HashSet <MaterialState> states)
        {
            if (value is MaterialStateProperty <Color> materialStateProperty)
            {
                MaterialStateProperty <Color> property = materialStateProperty;
                return(property.resolve(states));
            }

            return(value);
        }
示例#6
0
        public override Widget build(BuildContext context)
        {
            Color effectiveTextColor = MaterialStateProperty <Color> .resolveAs <Color>(widget.textStyle?.color, _states);

            ShapeBorder effectiveShape = MaterialStateProperty <Color> .resolveAs <ShapeBorder>(widget.shape, _states);

            Offset             densityAdjustment    = widget.visualDensity.baseSizeAdjustment;
            BoxConstraints     effectiveConstraints = widget.visualDensity.effectiveConstraints(widget.constraints);
            EdgeInsetsGeometry padding = widget.padding.add(
                EdgeInsets.only(
                    left: densityAdjustment.dx,
                    top: densityAdjustment.dy,
                    right: densityAdjustment.dx,
                    bottom: densityAdjustment.dy
                    )
                ).clamp(EdgeInsets.zero, EdgeInsetsGeometry.infinity) as EdgeInsets;

            Widget result = new ConstrainedBox(
                constraints: effectiveConstraints,
                child: new Material(
                    elevation: _effectiveElevation,
                    textStyle: widget.textStyle?.copyWith(color: effectiveTextColor),
                    shape: effectiveShape,
                    color: widget.fillColor,
                    type: widget.fillColor == null ? MaterialType.transparency : MaterialType.button,
                    animationDuration: widget.animationDuration,
                    clipBehavior: widget.clipBehavior,
                    child: new InkWell(
                        focusNode: widget.focusNode,
                        canRequestFocus: widget.enabled,
                        onFocusChange: _handleFocusedChanged,
                        autofocus: widget.autofocus,
                        onHighlightChanged: _handleHighlightChanged,
                        splashColor: widget.splashColor,
                        highlightColor: widget.highlightColor,
                        focusColor: widget.focusColor,
                        hoverColor: widget.hoverColor,
                        onHover: _handleHoveredChanged,
                        onTap: widget.onPressed == null
                            ? (GestureTapCallback)null
                            : () => {
                if (widget.onPressed != null)
                {
                    widget.onPressed();
                }
            },
                        onLongPress: widget.onLongPress,
                        enableFeedback: widget.enableFeedback,
                        customBorder: effectiveShape,
                        child: IconTheme.merge(
                            data: new IconThemeData(color: effectiveTextColor),
                            child: new Container(
                                padding: padding,
                                child: new Center(
                                    widthFactor: 1.0f,
                                    heightFactor: 1.0f,
                                    child: widget.child)
                                )
                            )
                        )
                    )
                );

            Size minSize = null;

            switch (widget.materialTapTargetSize)
            {
            case MaterialTapTargetSize.padded:
                minSize = new Size(
                    material_.kMinInteractiveDimension + densityAdjustment.dx,
                    material_.kMinInteractiveDimension + densityAdjustment.dy
                    );
                D.assert(minSize.width >= 0.0f);
                D.assert(minSize.height >= 0.0f);
                break;

            case MaterialTapTargetSize.shrinkWrap:
                minSize = Size.zero;
                break;
            }

            return(new _InputPadding(
                       minSize: minSize,
                       child: result
                       ));
        }