public override Widget build(BuildContext context, int index) { D.assert(children != null); if (index < 0 || index >= children.Count) { return(null); } Widget child = children[index]; D.assert( child != null, () => "The sliver's children must not contain null values, but a null value was found at index $index" ); Key key = child.key != null? new _SaltedValueKey(child.key) : null; if (addRepaintBoundaries) { child = new RepaintBoundary(child: child); } if (addAutomaticKeepAlives) { child = new AutomaticKeepAlive(child: child); } return(new KeyedSubtree(child: child, key: key)); }
public override Widget build(BuildContext context, int index) { D.assert(builder != null); if (index < 0 || (childCount != null && index >= childCount)) { return(null); } Widget child = builder(context, index); if (child == null) { return(null); } Key key = child.key != null ? new _SaltedValueKey(child.key) : null; if (addRepaintBoundaries) { child = new RepaintBoundary(child: child); } if (addAutomaticKeepAlives) { child = new AutomaticKeepAlive(child: child); } return(new KeyedSubtree(child: child, key: key)); }
public override Widget build(BuildContext context, int index) { D.assert(this.builder != null); if (index < 0 || (this.childCount != null && index >= this.childCount)) { return(null); } Widget child = this.builder(context, index); if (child == null) { return(null); } if (this.addRepaintBoundaries) { child = RepaintBoundary.wrap(child, index); } if (this.addAutomaticKeepAlives) { child = new AutomaticKeepAlive(child: child); } return(child); }
public override Widget build(BuildContext context) { base.build(context); D.assert(() => { return(_controller._textSpan.visitChildren((InlineSpan span) => span is TextSpan)); }, () => "SelectableText only supports TextSpan; Other type of InlineSpan is not allowed"); D.assert(WidgetsD.debugCheckHasMediaQuery(context)); D.assert(WidgetsD.debugCheckHasDirectionality(context)); D.assert( !(widget.style != null && widget.style.inherit == false && (widget.style.fontSize == null || widget.style.textBaseline == null)), () => "inherit false style must supply fontSize and textBaseline" ); ThemeData themeData = Theme.of(context); FocusNode focusNode = _effectiveFocusNode; TextSelectionControls textSelectionControls; bool paintCursorAboveText; bool cursorOpacityAnimates; Offset cursorOffset = Offset.zero; Color cursorColor = widget.cursorColor; Radius cursorRadius = widget.cursorRadius; switch (themeData.platform) { case RuntimePlatform.IPhonePlayer: case RuntimePlatform.OSXEditor: case RuntimePlatform.OSXPlayer: forcePressEnabled = true; textSelectionControls = CupertinoTextFieldUtils.cupertinoTextSelectionControls; paintCursorAboveText = true; cursorOpacityAnimates = true; cursorColor = cursorColor ?? CupertinoTheme.of(context).primaryColor; cursorRadius = cursorRadius ?? Radius.circular(2.0f); cursorOffset = new Offset(SelectableTextUtils.iOSHorizontalOffset / MediaQuery.of(context).devicePixelRatio, 0); break; default: forcePressEnabled = false; textSelectionControls = _MaterialTextSelectionControls.materialTextSelectionControls; paintCursorAboveText = false; cursorOpacityAnimates = false; cursorColor = cursorColor ?? themeData.cursorColor; break; } DefaultTextStyle defaultTextStyle = DefaultTextStyle.of(context); TextStyle effectiveTextStyle = widget.style; if (widget.style == null || widget.style.inherit) { effectiveTextStyle = defaultTextStyle.style.merge(widget.style); } if (MediaQuery.boldTextOverride(context)) { effectiveTextStyle = effectiveTextStyle.merge(new TextStyle(fontWeight: FontWeight.bold)); } Widget child = new RepaintBoundary( child: new EditableText( key: editableTextKey, style: effectiveTextStyle, readOnly: true, textWidthBasis: widget.textWidthBasis ?? defaultTextStyle.textWidthBasis, showSelectionHandles: _showSelectionHandles, showCursor: widget.showCursor, controller: _controller, focusNode: focusNode, strutStyle: widget.strutStyle ?? new StrutStyle(), textAlign: widget.textAlign ?? defaultTextStyle.textAlign ?? TextAlign.start, textDirection: widget.textDirection, textScaleFactor: widget.textScaleFactor, autofocus: widget.autofocus, forceLine: false, toolbarOptions: widget.toolbarOptions, minLines: widget.minLines, maxLines: widget.maxLines ?? defaultTextStyle.maxLines, selectionColor: themeData.textSelectionColor, selectionControls: widget.selectionEnabled ? textSelectionControls : null, onSelectionChanged: _handleSelectionChanged, onSelectionHandleTapped: _handleSelectionHandleTapped, rendererIgnoresPointer: true, cursorWidth: widget.cursorWidth, cursorRadius: cursorRadius, cursorColor: cursorColor, cursorOpacityAnimates: cursorOpacityAnimates, cursorOffset: cursorOffset, paintCursorAboveText: paintCursorAboveText, backgroundCursorColor: CupertinoColors.inactiveGray, enableInteractiveSelection: widget.enableInteractiveSelection, dragStartBehavior: widget.dragStartBehavior, scrollPhysics: widget.scrollPhysics ) ); return(_selectionGestureDetectorBuilder.buildGestureDetector( behavior: HitTestBehavior.translucent, child: child )); }
public override Widget build(BuildContext context) { base.build(context); // See AutomaticKeepAliveClientMixin. D.assert(MaterialD.debugCheckHasMaterial(context)); D.assert(WidgetsD.debugCheckHasDirectionality(context)); ThemeData themeData = Theme.of(context); TextStyle style = this.widget.style ?? themeData.textTheme.subhead; Brightness keyboardAppearance = this.widget.keyboardAppearance ?? themeData.primaryColorBrightness; TextEditingController controller = this._effectiveController; FocusNode focusNode = this._effectiveFocusNode; List <TextInputFormatter> formatters = this.widget.inputFormatters ?? new List <TextInputFormatter>(); if (this.widget.maxLength != null && this.widget.maxLengthEnforced) { formatters.Add(new LengthLimitingTextInputFormatter(this.widget.maxLength)); } Widget child = new RepaintBoundary( child: new EditableText( key: this._editableTextKey, controller: controller, focusNode: focusNode, keyboardType: this.widget.keyboardType, textInputAction: this.widget.textInputAction, textCapitalization: this.widget.textCapitalization, style: style, textAlign: this.widget.textAlign, textDirection: this.widget.textDirection, autofocus: this.widget.autofocus, obscureText: this.widget.obscureText, autocorrect: this.widget.autocorrect, maxLines: this.widget.maxLines, selectionColor: themeData.textSelectionColor, selectionControls: this.widget.enableInteractiveSelection ? MaterialUtils.materialTextSelectionControls : null, onChanged: this.widget.onChanged, onEditingComplete: this.widget.onEditingComplete, onSubmitted: this.widget.onSubmitted, onSelectionChanged: this._handleSelectionChanged, inputFormatters: formatters, rendererIgnoresPointer: true, cursorWidth: this.widget.cursorWidth, cursorRadius: this.widget.cursorRadius, cursorColor: this.widget.cursorColor ?? Theme.of(context).cursorColor, scrollPadding: this.widget.scrollPadding, keyboardAppearance: keyboardAppearance, enableInteractiveSelection: this.widget.enableInteractiveSelection ) ); if (this.widget.decoration != null) { child = new AnimatedBuilder( animation: ListenableUtils.merge(new List <Listenable> { focusNode, controller }), builder: (_context, _child) => { return(new InputDecorator( decoration: this._getEffectiveDecoration(), baseStyle: this.widget.style, textAlign: this.widget.textAlign, isFocused: focusNode.hasFocus, isEmpty: controller.value.text.isEmpty(), child: _child )); }, child: child ); } return(new IgnorePointer( ignoring: !(this.widget.enabled ?? this.widget.decoration?.enabled ?? true), child: new GestureDetector( behavior: HitTestBehavior.translucent, onTapDown: this._handleTapDown, onTap: this._handleTap, onTapCancel: this._handleTapCancel, onLongPress: this._handleLongPress, child: child ) )); }
public override Widget build(BuildContext context) { base.build(context); // See AutomaticKeepAliveClientMixin. D.assert(MaterialD.debugCheckHasMaterial(context)); D.assert(WidgetsD.debugCheckHasDirectionality(context)); D.assert( !(this.widget.style != null && this.widget.style.inherit == false && (this.widget.style.fontSize == null || this.widget.style.textBaseline == null)), "inherit false style must supply fontSize and textBaseline" ); ThemeData themeData = Theme.of(context); TextStyle style = themeData.textTheme.subhead.merge(this.widget.style); Brightness keyboardAppearance = this.widget.keyboardAppearance ?? themeData.primaryColorBrightness; TextEditingController controller = this._effectiveController; FocusNode focusNode = this._effectiveFocusNode; List <TextInputFormatter> formatters = this.widget.inputFormatters ?? new List <TextInputFormatter>(); if (this.widget.maxLength != null && this.widget.maxLengthEnforced) { formatters.Add(new LengthLimitingTextInputFormatter(this.widget.maxLength)); } bool forcePressEnabled = false; TextSelectionControls textSelectionControls = MaterialUtils.materialTextSelectionControls;; bool paintCursorAboveText = false; bool cursorOpacityAnimates = false; Offset cursorOffset = null; Color cursorColor = this.widget.cursorColor ?? themeData.cursorColor; Radius cursorRadius = this.widget.cursorRadius; Widget child = new RepaintBoundary( child: new EditableText( key: this._editableTextKey, controller: controller, focusNode: focusNode, keyboardType: this.widget.keyboardType, textInputAction: this.widget.textInputAction, textCapitalization: this.widget.textCapitalization, style: style, textAlign: this.widget.textAlign, textDirection: this.widget.textDirection, autofocus: this.widget.autofocus, obscureText: this.widget.obscureText, autocorrect: this.widget.autocorrect, maxLines: this.widget.maxLines, selectionColor: themeData.textSelectionColor, selectionControls: this.widget.selectionEnabled ? textSelectionControls : null, onChanged: this.widget.onChanged, onSelectionChanged: this._handleSelectionChanged, onEditingComplete: this.widget.onEditingComplete, onSubmitted: this.widget.onSubmitted, inputFormatters: formatters, rendererIgnoresPointer: true, cursorWidth: this.widget.cursorWidth, cursorRadius: cursorRadius, cursorColor: cursorColor, cursorOpacityAnimates: cursorOpacityAnimates, cursorOffset: cursorOffset, paintCursorAboveText: paintCursorAboveText, backgroundCursorColor: new Color(0xFF8E8E93),// TODO: CupertinoColors.inactiveGray, scrollPadding: this.widget.scrollPadding, keyboardAppearance: keyboardAppearance, enableInteractiveSelection: this.widget.enableInteractiveSelection == true, dragStartBehavior: this.widget.dragStartBehavior ) ); if (this.widget.decoration != null) { child = new AnimatedBuilder( animation: ListenableUtils.merge(new List <Listenable> { focusNode, controller }), builder: (_context, _child) => { return(new InputDecorator( decoration: this._getEffectiveDecoration(), baseStyle: this.widget.style, textAlign: this.widget.textAlign, isFocused: focusNode.hasFocus, isEmpty: controller.value.text.isEmpty(), child: _child )); }, child: child ); } return(new IgnorePointer( ignoring: !(this.widget.enabled ?? this.widget.decoration?.enabled ?? true), child: new TextSelectionGestureDetector( onTapDown: this._handleTapDown, // onForcePressStart: forcePressEnabled ? this._handleForcePressStarted : null, // TODO: Remove this when force press is added onSingleTapUp: this._handleSingleTapUp, onSingleTapCancel: this._handleSingleTapCancel, onSingleLongTapStart: this._handleLongPress, onDragSelectionStart: this._handleDragSelectionStart, onDragSelectionUpdate: this._handleDragSelectionUpdate, behavior: HitTestBehavior.translucent, child: child ) )); }
public override Widget build(BuildContext context) { D.assert(material_.debugCheckHasMaterial(context)); D.assert(WidgetsD.debugCheckHasDirectionality(context)); D.assert( !(widget.style != null && widget.style.inherit == false && (widget.style.fontSize == null || widget.style.textBaseline == null)), () => "inherit false style must supply fontSize and textBaseline" ); ThemeData themeData = Theme.of(context); TextStyle style = themeData.textTheme.subtitle1.merge(widget.style); Brightness keyboardAppearance = widget.keyboardAppearance ?? themeData.primaryColorBrightness; TextEditingController controller = _effectiveController; FocusNode focusNode = _effectiveFocusNode; List <TextInputFormatter> formatters = widget.inputFormatters ?? new List <TextInputFormatter>(); if (widget.maxLength != null && widget.maxLengthEnforced) { formatters.Add(new LengthLimitingTextInputFormatter(widget.maxLength)); } TextSelectionControls textSelectionControls = MaterialUtils.materialTextSelectionControls; ; bool paintCursorAboveText = false; bool cursorOpacityAnimates = false; Offset cursorOffset = null; Color cursorColor = widget.cursorColor ?? themeData.cursorColor; Radius cursorRadius = widget.cursorRadius; _forcePressEnabled = false; textSelectionControls = _MaterialTextSelectionControls.materialTextSelectionControls; paintCursorAboveText = false; cursorOpacityAnimates = false; cursorColor = cursorColor ?? themeData.cursorColor; Widget child = new RepaintBoundary( child: new EditableText( key: editableTextKey, readOnly: widget.readOnly, toolbarOptions: widget.toolbarOptions, showCursor: widget.showCursor, showSelectionHandles: _showSelectionHandles, controller: controller, focusNode: focusNode, keyboardType: widget.keyboardType, textInputAction: widget.textInputAction, textCapitalization: widget.textCapitalization, style: style, strutStyle: widget.strutStyle, textAlign: widget.textAlign, textDirection: widget.textDirection, 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: themeData.textSelectionColor, selectionControls: widget.selectionEnabled ? textSelectionControls : null, onChanged: widget.onChanged, onSelectionChanged: _handleSelectionChanged, onEditingComplete: widget.onEditingComplete, onSubmitted: widget.onSubmitted, onSelectionHandleTapped: _handleSelectionHandleTapped, inputFormatters: formatters, rendererIgnoresPointer: true, cursorWidth: widget.cursorWidth.Value, cursorRadius: cursorRadius, cursorColor: cursorColor, selectionHeightStyle: widget.selectionHeightStyle, selectionWidthStyle: widget.selectionWidthStyle, cursorOpacityAnimates: cursorOpacityAnimates, cursorOffset: cursorOffset, paintCursorAboveText: paintCursorAboveText, backgroundCursorColor: CupertinoColors.inactiveGray, scrollPadding: widget.scrollPadding, keyboardAppearance: keyboardAppearance, enableInteractiveSelection: widget.enableInteractiveSelection == true, dragStartBehavior: widget.dragStartBehavior, scrollController: widget.scrollController, scrollPhysics: widget.scrollPhysics ) ); if (widget.decoration != null) { child = new AnimatedBuilder( animation: ListenableUtils.merge(new List <Listenable> { focusNode, controller }), builder: (_context, _child) => { return(new InputDecorator( decoration: _getEffectiveDecoration(), baseStyle: widget.style, textAlign: widget.textAlign, textAlignVertical: widget.textAlignVertical, isHovering: _isHovering, isFocused: focusNode.hasFocus, isEmpty: controller.value.text.isEmpty(), expands: widget.expands, child: _child )); }, child: child ); } void onEnter(PointerEnterEvent pEvent) { _handleHover(true); } void onExit(PointerExitEvent pEvent) { _handleHover(false); } return(new IgnorePointer( ignoring: !_isEnabled, child: new MouseRegion( onEnter: onEnter, onExit: onExit, child: new AnimatedBuilder( animation: controller, builder: (BuildContext buildContext, Widget buildChild) => { return buildChild; }, child: _selectionGestureDetectorBuilder.buildGestureDetector( behavior: HitTestBehavior.translucent, child: child ) ) ) )); }