Пример #1
0
 public ShapeBorder resolve(HashSet <MaterialState> states)
 {
     return(new _OutlineBorder(
                shape: shape,
                side: side.copyWith(color: MaterialStateProperty <Color> .resolveAsMaterialStateProperty(side.color, states)
                                    )
                ));
 }
Пример #2
0
        public override Widget build(BuildContext context)
        {
            Color effectiveTextColor = MaterialStateProperty <Color> .resolveAsMaterialStateProperty <Color>(widget.textStyle?.color, _states);

            ShapeBorder effectiveShape = MaterialStateProperty <Color> .resolveAsMaterialStateProperty <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.infinityEdgeInsetsGeometry) 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
                       ));
        }