public override Widget build(BuildContext context) { base.build(context); // See AutomaticKeepAliveClientMixin. D.assert(!_directionIsXAxis || WidgetsD.debugCheckHasDirectionality(context)); Widget background = widget.background; if (widget.secondaryBackground != null) { DismissDirection?direction = _dismissDirection; if (direction == DismissDirection.endToStart || direction == DismissDirection.up) { background = widget.secondaryBackground; } } if (_resizeAnimation != null) { // we've been dragged aside, and are now resizing. D.assert(() => { if (_resizeAnimation.status != AnimationStatus.forward) { D.assert(_resizeAnimation.status == AnimationStatus.completed); throw new UIWidgetsError(new List <DiagnosticsNode> { new ErrorSummary("A dismissed Dismissible widget is still part of the tree."), new ErrorHint( "Make sure to implement the onDismissed handler and to immediately remove the Dismissible " + "widget from the application once that handler has fired." ) }); } return(true); }); return(new SizeTransition( sizeFactor: _resizeAnimation, axis: _directionIsXAxis ? Axis.vertical : Axis.horizontal, child: new SizedBox( width: _sizePriorToCollapse.width, height: _sizePriorToCollapse.height, child: background ) )); } Widget content = new SlideTransition( position: _moveAnimation, child: widget.child ); if (background != null) { List <Widget> children = new List <Widget>(); if (!_moveAnimation.isDismissed) { children.Add(Positioned.fill( child: new ClipRect( clipper: new _DismissibleClipper( axis: _directionIsXAxis ? Axis.horizontal : Axis.vertical, moveAnimation: _moveAnimation ), child: background ) )); } children.Add(content); content = new Stack(children: children); } return(new GestureDetector( onHorizontalDragStart: _directionIsXAxis ? (GestureDragStartCallback)_handleDragStart : null, onHorizontalDragUpdate: _directionIsXAxis ? (GestureDragUpdateCallback)_handleDragUpdate : null, onHorizontalDragEnd: _directionIsXAxis ? (GestureDragEndCallback)_handleDragEnd : null, onVerticalDragStart: _directionIsXAxis ? null : (GestureDragStartCallback)_handleDragStart, onVerticalDragUpdate: _directionIsXAxis ? null : (GestureDragUpdateCallback)_handleDragUpdate, onVerticalDragEnd: _directionIsXAxis ? null : (GestureDragEndCallback)_handleDragEnd, behavior: HitTestBehavior.opaque, child: content, dragStartBehavior: widget.dragStartBehavior )); }
public Table( Key key = null, List <TableRow> children = null, Dictionary <int, TableColumnWidth> columnWidths = null, TableColumnWidth defaultColumnWidth = null, TableBorder border = null, TableCellVerticalAlignment defaultVerticalAlignment = TableCellVerticalAlignment.top, TextBaseline?textBaseline = null ) : base(key: key) { children = children ?? new List <TableRow>(); defaultColumnWidth = defaultColumnWidth ?? new FlexColumnWidth(1.0f); this.children = children; this.columnWidths = columnWidths; this.defaultColumnWidth = defaultColumnWidth; this.border = border; this.defaultVerticalAlignment = defaultVerticalAlignment; this.textBaseline = textBaseline; D.assert(() => { if (children.Any((TableRow row) => { return(row.children.Any((Widget cell) => { return cell == null; })); })) { throw new UIWidgetsError( "One of the children of one of the rows of the table was null.\n" + "The children of a TableRow must not be null." ); } return(true); }); D.assert(() => { if (children.Any((TableRow row1) => { return(row1.key != null && children.Any((TableRow row2) => { return row1 != row2 && row1.key == row2.key; })); })) { throw new UIWidgetsError( "Two or more TableRow children of this Table had the same key.\n" + "All the keyed TableRow children of a Table must have different Keys." ); } return(true); }); D.assert(() => { if (children.isNotEmpty()) { int cellCount = this.children.First().children.Count; if (children.Any((TableRow row) => { return(row.children.Count != cellCount); })) { throw new UIWidgetsError( "Table contains irregular row lengths.\n" + "Every TableRow in a Table must have the same number of children, so that every cell is filled. " + "Otherwise, the table will contain holes." ); } } return(true); }); this._rowDecorations = null; if (children.Any((TableRow row) => { return(row.decoration != null); })) { this._rowDecorations = new List <Decoration>(); foreach (TableRow row in children) { this._rowDecorations.Add(row.decoration); } } D.assert(() => { List <Widget> flatChildren = new List <Widget>(); foreach (TableRow row in children) { flatChildren.AddRange(row.children); } if (WidgetsD.debugChildrenHaveDuplicateKeys(this, flatChildren)) { throw new UIWidgetsError( "Two or more cells in this Table contain widgets with the same key.\n" + "Every widget child of every TableRow in a Table must have different keys. The cells of a Table are " + "flattened out for processing, so separate cells cannot have duplicate keys even if they are in " + "different rows." ); } return(true); }); }
public _TheatreElement(RenderObjectWidget widget) : base(widget) { D.assert(!WidgetsD.debugChildrenHaveDuplicateKeys(widget, ((_Theatre)widget).offstage)); }
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 ) )); }