public CupertinoDynamicColor resolveFrom(BuildContext context, bool nullOk = true) { Brightness brightness = _isPlatformBrightnessDependent ? CupertinoTheme.brightnessOf(context, nullOk: nullOk) ?? Brightness.light : Brightness.light; bool isHighContrastEnabled = _isHighContrastDependent && (MediaQuery.of(context, nullOk: nullOk)?.highContrast ?? false); CupertinoUserInterfaceLevelData level = _isInterfaceElevationDependent ? CupertinoUserInterfaceLevel.of(context, nullOk: nullOk) ?? CupertinoUserInterfaceLevelData.baselayer : CupertinoUserInterfaceLevelData.baselayer; Color resolved = null; switch (brightness) { case Brightness.light: switch (level) { case CupertinoUserInterfaceLevelData.baselayer: resolved = isHighContrastEnabled ? highContrastColor : color; break; case CupertinoUserInterfaceLevelData.elevatedlayer: resolved = isHighContrastEnabled ? highContrastElevatedColor : elevatedColor; break; } break; case Brightness.dark: switch (level) { case CupertinoUserInterfaceLevelData.baselayer: resolved = isHighContrastEnabled ? darkHighContrastColor : darkColor; break; case CupertinoUserInterfaceLevelData.elevatedlayer: resolved = isHighContrastEnabled ? darkHighContrastElevatedColor : darkElevatedColor; break; } break; } Element _debugContext = null; D.assert(() => { _debugContext = context as Element; return(true); } ); return(new CupertinoDynamicColor( debugLabel: _debugLabel, effectiveColor: resolved, color: color, darkColor: darkColor, highContrastColor: highContrastColor, darkHighContrastColor: darkHighContrastColor, elevatedColor: color, darkElevatedColor: darkColor, highContrastElevatedColor: highContrastColor, darkHighContrastElevatedColor: darkHighContrastColor, debugResolveContext: null )); }
public override Widget build(BuildContext context) { base.build(context); D.assert(WidgetsD.debugCheckHasDirectionality(context)); TextEditingController controller = _effectiveController; List <TextInputFormatter> formatters = widget.inputFormatters ?? new List <TextInputFormatter>(); bool enabled = widget.enabled ?? true; Offset cursorOffset = new Offset( CupertinoTextFieldUtils._iOSHorizontalCursorOffsetPixels / MediaQuery.of(context).devicePixelRatio, 0); if (widget.maxLength != null && widget.maxLengthEnforced) { formatters.Add(new LengthLimitingTextInputFormatter(widget.maxLength)); } CupertinoThemeData themeData = CupertinoTheme.of(context); TextStyle resolvedStyle = widget.style?.copyWith( color: CupertinoDynamicColor.resolve(widget.style?.color, context), backgroundColor: CupertinoDynamicColor.resolve(widget.style?.backgroundColor, context) ); TextStyle textStyle = themeData.textTheme.textStyle.merge(resolvedStyle); TextStyle resolvedPlaceholderStyle = widget.placeholderStyle?.copyWith( color: CupertinoDynamicColor.resolve(widget.placeholderStyle?.color, context), backgroundColor: CupertinoDynamicColor.resolve(widget.placeholderStyle?.backgroundColor, context) ); TextStyle placeholderStyle = textStyle.merge(resolvedPlaceholderStyle); Brightness?keyboardAppearance = widget.keyboardAppearance ?? CupertinoTheme.brightnessOf(context); Color cursorColor = CupertinoDynamicColor.resolve(widget.cursorColor, context) ?? themeData.primaryColor; Color disabledColor = CupertinoDynamicColor.resolve(CupertinoTextFieldUtils._kDisabledBackground, context); Color decorationColor = CupertinoDynamicColor.resolve(widget.decoration?.color, context); BoxBorder border = widget.decoration?.border; Border resolvedBorder = border as Border; if (border is Border) { BorderSide resolveBorderSide(BorderSide side) { return(side == BorderSide.none ? side : side.copyWith(color: CupertinoDynamicColor.resolve(side.color, context))); } resolvedBorder = (Border)(border == null || border.GetType() != typeof(Border) ? border : new Border( top: resolveBorderSide(((Border)border).top), left: resolveBorderSide(((Border)border).left), bottom: resolveBorderSide(((Border)border).bottom), right: resolveBorderSide(((Border)border).right) )); } BoxDecoration effectiveDecoration = widget.decoration?.copyWith( border: resolvedBorder, color: enabled ? decorationColor : (decorationColor == null ? disabledColor : decorationColor) ); Widget paddedEditable = new Padding( padding: widget.padding, child: new RepaintBoundary( child: new EditableText( key: editableTextKey, controller: controller, readOnly: widget.readOnly, toolbarOptions: widget.toolbarOptions, showCursor: widget.showCursor, showSelectionHandles: _showSelectionHandles, focusNode: _effectiveFocusNode, keyboardType: widget.keyboardType, textInputAction: widget.textInputAction, textCapitalization: widget.textCapitalization, style: textStyle, strutStyle: widget.strutStyle, textAlign: widget.textAlign, autofocus: widget.autofocus, obscureText: widget.obscureText, autocorrect: widget.autocorrect, smartDashesType: widget.smartDashesType, smartQuotesType: widget.smartQuotesType, enableSuggestions: widget.enableSuggestions, maxLines: widget.maxLines, minLines: widget.minLines, expands: widget.expands, selectionColor: CupertinoTheme.of(context).primaryColor.withOpacity(0.2f), selectionControls: widget.selectionEnabled ? CupertinoTextFieldUtils.cupertinoTextSelectionControls : null, onChanged: widget.onChanged, onSelectionChanged: _handleSelectionChanged, onEditingComplete: widget.onEditingComplete, onSubmitted: widget.onSubmitted, inputFormatters: formatters, rendererIgnoresPointer: true, cursorWidth: widget.cursorWidth, cursorRadius: widget.cursorRadius, cursorColor: cursorColor, cursorOpacityAnimates: true, cursorOffset: cursorOffset, paintCursorAboveText: true, backgroundCursorColor: CupertinoDynamicColor.resolve(CupertinoColors.inactiveGray, context), selectionHeightStyle: widget.selectionHeightStyle, selectionWidthStyle: widget.selectionWidthStyle, scrollPadding: widget.scrollPadding, keyboardAppearance: keyboardAppearance, dragStartBehavior: widget.dragStartBehavior, scrollController: widget.scrollController, scrollPhysics: widget.scrollPhysics, enableInteractiveSelection: widget.enableInteractiveSelection ) ) ); return(new IgnorePointer( ignoring: !enabled, child: new Container( decoration: effectiveDecoration, child: _selectionGestureDetectorBuilder.buildGestureDetector( behavior: HitTestBehavior.translucent, child: new Align( alignment: new Alignment(-1.0f, _textAlignVertical.y), widthFactor: 1.0f, heightFactor: 1.0f, child: _addTextDependentAttachments(paddedEditable, textStyle, placeholderStyle) ) ) ) )); }