DataRow _getBlankRowFor(int index) { return(DataRow.byIndex( index: index, cells: LinqUtils <DataCell, DataColumn> .SelectList(widget.columns, ((DataColumn column) => DataCell.empty)) )); }
void _initControllers() { _destinationControllers = LinqUtils <AnimationController, NavigationRailDestination> .SelectList(widget.destinations, ((destination) => { var result = new AnimationController( duration: ThemeUtils.kThemeAnimationDuration, vsync: this ); result.addListener(_rebuild); return(result); })); _destinationAnimations = LinqUtils <Animation <float>, AnimationController> .SelectList(_destinationControllers, ((AnimationController controller) => controller.view)); _destinationControllers[widget.selectedIndex ?? 0].setValue(1.0f); _extendedController = new AnimationController( duration: ThemeUtils.kThemeAnimationDuration, vsync: this, value: widget.extended ?? false ? 1.0f : 0.0f ); _extendedAnimation = new CurvedAnimation( parent: _extendedController, curve: Curves.easeInOut ); _extendedController.addListener(() => { _rebuild(); }); }
public override IEnumerable <FocusNode> sortDescendants(IEnumerable <FocusNode> descendants) { FocusTraversalPolicy secondaryPolicy = secondary ?? new ReadingOrderTraversalPolicy(); IEnumerable <FocusNode> sortedDescendants = secondaryPolicy.sortDescendants(descendants); List <FocusNode> unordered = new List <FocusNode>(); List <_OrderedFocusInfo> ordered = new List <_OrderedFocusInfo>(); foreach (FocusNode node in sortedDescendants) { FocusOrder order = FocusTraversalOrder.of(node.context, nullOk: true); if (order != null) { ordered.Add(new _OrderedFocusInfo(node: node, order: order)); } else { unordered.Add(node); } } FocusTravesalUtils.mergeSort <_OrderedFocusInfo>(ordered, compare: (_OrderedFocusInfo a, _OrderedFocusInfo b) => { D.assert( a.order.GetType() == b.order.GetType(), () => $"When sorting nodes for determining focus order, the order ({a.order}) of " + $"node {a.node}, isn't the same type as the order ({b.order}) of {b.node}. " + "Incompatible order types can't be compared. Use a FocusTraversalGroup to group " + "similar orders together." ); return(a.order.CompareTo(b.order)); }); return(LinqUtils <FocusNode, _OrderedFocusInfo> .SelectList(ordered, ((_OrderedFocusInfo info) => info.node)).Concat(unordered)); }
public virtual string toStringShallow( string joiner = ", ", DiagnosticLevel minLevel = DiagnosticLevel.debug ) { if (foundation_.kReleaseMode) { return(toString()); } string shallowString = ""; D.assert(() => { var result = new StringBuilder(); result.Append(toString()); result.Append(joiner); DiagnosticPropertiesBuilder builder = new DiagnosticPropertiesBuilder(); debugFillProperties(builder); result.Append(string.Join(joiner, LinqUtils <string, DiagnosticsNode> .SelectList(LinqUtils <DiagnosticsNode> .WhereList(builder.properties, (n => !n.isFiltered(minLevel))), (n => n.ToString()))) ); shallowString = result.ToString(); return(true); }); return(shallowString); }
internal static Future <Dictionary <Type, object> > _loadAll( Locale locale, IEnumerable <LocalizationsDelegate> allDelegates) { Dictionary <Type, object> output = new Dictionary <Type, object>(); List <_Pending> pendingList = null; HashSet <Type> types = new HashSet <Type>(); List <LocalizationsDelegate> delegates = new List <LocalizationsDelegate>(); foreach (LocalizationsDelegate del in allDelegates) { if (!types.Contains(del.type) && del.isSupported(locale)) { types.Add(del.type); delegates.Add(del); } } foreach (LocalizationsDelegate del in delegates) { Future <object> inputValue = del.load(locale).to <object>(); object completedValue = null; Future <object> futureValue = inputValue.then_(value => { completedValue = value; return(FutureOr.value(completedValue)); }).to <object>(); if (completedValue != null) { Type type = del.type; D.assert(!output.ContainsKey(type)); output[type] = completedValue; } else { pendingList = pendingList ?? new List <_Pending>(); pendingList.Add(new _Pending(del, futureValue)); } } if (pendingList == null) { return(new SynchronousFuture <Dictionary <Type, object> >(output)); } return(Future.wait <object>(LinqUtils <Future <object>, _Pending> .SelectList(pendingList, (p => p.futureValue))) .then(values => { var list = (List <object>)values; D.assert(list.Count == pendingList.Count); for (int i = 0; i < list.Count; i += 1) { Type type = pendingList[i].del.type; D.assert(!output.ContainsKey(type)); output[type] = list[i]; } return output; }).to <Dictionary <Type, object> >()); }
public static string toStringList <T>(this IList <T> it) { if (it == null) { return(null); } return("{ " + string.Join(", ", LinqUtils <string, T> .SelectList(it, (item => item.ToString()))) + " }"); }
public override List <DiagnosticsNode> debugDescribeChildren() { int count = 1; return(LinqUtils <DiagnosticsNode, FocusNode> .SelectList(_children, (FocusNode child) => { return child.toDiagnosticsNode(name: $"Child {count++}"); })); }
public override Gradient scale(float factor) { return(new RadialGradient( center: center, radius: radius, colors: LinqUtils <Color> .SelectList(colors, (color => Color.lerp(null, color, factor))), stops: stops, tileMode: tileMode )); }
public override Gradient scale(float factor) { return(new LinearGradient( begin: begin, end: end, colors: LinqUtils <Color> .SelectList(colors, (color => Color.lerp(null, color, factor))), stops: stops, tileMode: tileMode )); }
public override Widget build(BuildContext context) { ButtonThemeData parentButtonTheme = ButtonTheme.of(context); ButtonBarThemeData barTheme = ButtonBarTheme.of(context); ButtonThemeData buttonTheme = parentButtonTheme.copyWith( textTheme: buttonTextTheme ?? barTheme?.buttonTextTheme ?? ButtonTextTheme.primary, minWidth: buttonMinWidth ?? barTheme?.buttonMinWidth ?? 64.0f, height: buttonHeight ?? barTheme?.buttonHeight ?? 36.0f, padding: buttonPadding ?? barTheme?.buttonPadding ?? EdgeInsets.symmetric(horizontal: 8.0f), alignedDropdown: buttonAlignedDropdown ?? barTheme?.buttonAlignedDropdown ?? false, layoutBehavior: layoutBehavior ?? barTheme?.layoutBehavior ?? ButtonBarLayoutBehavior.padded ); float paddingUnit = buttonTheme.padding.horizontal / 4.0f; Widget child = ButtonTheme.fromButtonThemeData( data: buttonTheme, child: new _ButtonBarRow( mainAxisAlignment: alignment ?? barTheme?.alignment ?? MainAxisAlignment.end, mainAxisSize: mainAxisSize ?? barTheme?.mainAxisSize ?? MainAxisSize.max, overflowDirection: overflowDirection ?? barTheme?.overflowDirection ?? VerticalDirection.down, children: LinqUtils <Widget> .SelectList(children, ((Widget childWidget) => { return((Widget) new Padding( padding: EdgeInsets.symmetric(horizontal: paddingUnit), child: childWidget )); })), overflowButtonSpacing: overflowButtonSpacing ) ); switch (buttonTheme.layoutBehavior) { case ButtonBarLayoutBehavior.padded: return(new Padding( padding: EdgeInsets.symmetric( vertical: 2.0f * paddingUnit, horizontal: paddingUnit ), child: child )); case ButtonBarLayoutBehavior.constrained: return(new Container( padding: EdgeInsets.symmetric(horizontal: paddingUnit), constraints: new BoxConstraints(minHeight: 52.0f), alignment: Alignment.center, child: child )); } D.assert(false); return(null); }
public override Gradient scale(float factor) { return(new SweepGradient( center: center, startAngle: startAngle, endAngle: endAngle, colors: LinqUtils <Color> .SelectList(colors, (color => Color.lerp(null, color, factor))), stops: stops, tileMode: tileMode )); }
protected List <float> _impliedStops() { if (stops != null) { return(stops); } D.assert(colors.Count >= 2, () => "colors list must have at least two colors"); float separation = 1.0f / (colors.Count - 1); return(LinqUtils <float, int> .SelectList(Enumerable.Range(0, colors.Count), (i => i *separation))); }
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) { base.debugFillProperties(properties); if (_focusedChildren.isEmpty()) { return; } List <string> childList = new List <string>(); _focusedChildren.Reverse(); childList = LinqUtils <string, FocusNode> .SelectList(_focusedChildren, (FocusNode child) => { return(child.toStringShort()); }); properties.add(new EnumerableProperty <string>("focusedChildren", childList, defaultValue: new List <string>())); }
public override List <DiagnosticsNode> debugDescribeChildren() { if (children == null) { return(new List <DiagnosticsNode>()); } return(LinqUtils <DiagnosticsNode, InlineSpan> .SelectList(children, ((child) => { if (child != null) { return child.toDiagnosticsNode(); } else { return DiagnosticsNode.message("<null child>"); } }))); }
Widget contents() { var children = LinqUtils <Widget, ToDoItem> .SelectList(this.items, (ToDoItem item) => { return((Widget) new Text( item.content, style: new TextStyle( fontSize: 18, height: 1.5f ) )); }); return(new Flexible( child: new ListView( physics: new AlwaysScrollableScrollPhysics(), children: children.ToList() ) )); }
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) { base.debugFillProperties(properties); if (_recognizers == null) { properties.add(DiagnosticsNode.message("DISPOSED")); } else { List <string> gestures = LinqUtils <string, GestureRecognizer> .SelectList(_recognizers.Values, (recognizer => recognizer.debugDescription)); properties.add(new EnumerableProperty <string>("gestures", gestures, ifEmpty: "<none>")); properties.add(new EnumerableProperty <GestureRecognizer>("recognizers", _recognizers.Values, level: DiagnosticLevel.fine)); } properties.add(new EnumProperty <HitTestBehavior?>("behavior", widget.behavior, defaultValue: foundation_.kNullDefaultValue)); }
protected void reportError( DiagnosticsNode context = null, Exception exception = null, InformationCollector informationCollector = null, bool silent = false) { _currentError = new UIWidgetsErrorDetails( exception: exception, library: "image resource service", context: context, informationCollector: informationCollector, silent: silent ); var localErrorListeners = LinqUtils <ImageErrorListener> .WhereList( LinqUtils <ImageErrorListener, ImageStreamListener> .SelectList(_listeners, (l => l.onError)), (l => l != null)); if (localErrorListeners.isEmpty()) { UIWidgetsError.reportError(_currentError); } else { foreach (var errorListener in localErrorListeners) { try { errorListener(exception); } catch (Exception ex) { UIWidgetsError.reportError( new UIWidgetsErrorDetails( context: new ErrorDescription("when reporting an error to an image listener"), library: "image resource service", exception: ex ) ); } } } }
protected void setImage(ImageInfo image) { _currentImage = image; if (_listeners.isEmpty()) { return; } var localListeners = LinqUtils <ImageStreamListener> .SelectList(_listeners, (l => l)); foreach (var listener in localListeners) { try { listener.onImage(image, false); } catch (Exception ex) { reportError( context: new ErrorDescription("by an image listener"), exception: ex ); } } }
public static TextDirection commonDirectionalityOf(List <_ReadingOrderSortData> list) { IEnumerable <HashSet <Directionality> > allAncestors = LinqUtils <HashSet <Directionality>, _ReadingOrderSortData> .SelectList(list, ((_ReadingOrderSortData member) => new HashSet <Directionality>(member.directionalAncestors))); HashSet <Directionality> common = null; foreach (HashSet <Directionality> ancestorSet in allAncestors) { common = common ?? ancestorSet; common = FocusTravesalUtils.intersaction(common, ancestorSet); } if (common.isEmpty()) { return(list.First().directionality); } foreach (var com in list.First().directionalAncestors) { if (common.Contains(com)) { return(com.textDirection); } } return(common.First().textDirection); }
DataRow _getProgressIndicatorRowFor(int index) { bool haveProgressIndicator = false; List <DataCell> cells = LinqUtils <DataCell, DataColumn> .SelectList(widget.columns, ((DataColumn column) => { if (!column.numeric) { haveProgressIndicator = true; return(new DataCell(new CircularProgressIndicator())); } return(DataCell.empty); })); if (!haveProgressIndicator) { haveProgressIndicator = true; cells[0] = new DataCell(new CircularProgressIndicator()); } return(DataRow.byIndex( index: index, cells: cells )); }
public override Widget build(BuildContext context) { D.assert(material_.debugCheckHasMaterial(context)); D.assert(material_.debugCheckHasMaterialLocalizations(context)); Orientation?newOrientation = _getOrientation(context); _lastOrientation = _lastOrientation ?? newOrientation; if (newOrientation != _lastOrientation) { _removeDropdownRoute(); _lastOrientation = newOrientation; } List <Widget> items = null; if (_enabled) { items = widget.selectedItemBuilder == null ? new List <Widget>(widget.items) : widget.selectedItemBuilder(context); } else { items = widget.selectedItemBuilder == null ? new List <Widget>() : widget.selectedItemBuilder(context); } int hintIndex = 0; if (widget.hint != null || (!_enabled && widget.disabledHint != null)) { Widget displayedHint = _enabled ? widget.hint : widget.disabledHint ?? widget.hint; if (widget.selectedItemBuilder == null) { displayedHint = new _DropdownMenuItemContainer(child: displayedHint); } hintIndex = items.Count; items.Add(new DefaultTextStyle( style: _textStyle.copyWith(color: Theme.of(context).hintColor), child: new IgnorePointer( child: displayedHint ) )); } EdgeInsetsGeometry padding = ButtonTheme.of(context).alignedDropdown ? material_._kAlignedButtonPadding : material_._kUnalignedButtonPadding; int index = _enabled ? (_selectedIndex ?? hintIndex) : hintIndex; Widget innerItemsWidget = null; if (items.isEmpty()) { innerItemsWidget = new Container(); } else { innerItemsWidget = new IndexedStack( index: index, alignment: AlignmentDirectional.centerStart, children: widget.isDense ? items : LinqUtils <Widget> .SelectList(items, (Widget item) => { return(widget.itemHeight != null ? new SizedBox(height: widget.itemHeight, child: item) : (Widget) new Column(mainAxisSize: MainAxisSize.min, children: new List <Widget>() { item })); })); } Icon defaultIcon = new Icon(Icons.arrow_drop_down); Widget result = new DefaultTextStyle( style: _textStyle, child: new Container( decoration: _showHighlight ?? false ? new BoxDecoration( color: widget.focusColor ?? Theme.of(context).focusColor, borderRadius: BorderRadius.all(Radius.circular(4.0f)) ) : null, padding: padding, height: widget.isDense ? _denseButtonHeight : null, child: new Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisSize: MainAxisSize.min, children: new List <Widget> { widget.isExpanded ? new Expanded(child: innerItemsWidget) : (Widget)innerItemsWidget, new IconTheme( data: new IconThemeData( color: _iconColor, size: widget.iconSize ), child: widget.icon ?? defaultIcon ) } ) ) ); if (!DropdownButtonHideUnderline.at(context)) { float bottom = widget.isDense || widget.itemHeight == null ? 0.0f : 8.0f; result = new Stack( children: new List <Widget> { result, new Positioned( left: 0.0f, right: 0.0f, bottom: bottom, child: widget.underline ?? new Container( height: 1.0f, decoration: new BoxDecoration( border: new Border( bottom: new BorderSide(color: new Color(0xFFBDBDBD), width: 0.0f)) ) ) ) } ); } return(new Focus( canRequestFocus: _enabled, focusNode: focusNode, autofocus: widget.autofocus, child: new GestureDetector( onTap: _enabled ? (GestureTapCallback)_handleTap : null, behavior: HitTestBehavior.opaque, child: result ) )); }
public override string ToString() { return(string.Join(" + ", (LinqUtils <string, ShapeBorder> .SelectList(((IList <ShapeBorder>)borders).Reverse(), ((border) => border.ToString()))) )); }
public override string ToString() { return ($"HitTestResult({(_path.isEmpty() ? "<empty path>" : string.Join(", ", LinqUtils<string,HitTestEntry>.SelectList(_path, (x => x.ToString())) ))})"); }
public override ShapeBorder scale(float t) { return(new _CompoundBorder( LinqUtils <ShapeBorder> .SelectList(borders, (border => border.scale(t))) )); }
public override Widget build(BuildContext context) { D.assert(material_.debugCheckHasMaterialLocalizations(context)); ThemeData themeData = Theme.of(context); MaterialLocalizations localizations = MaterialLocalizations.of(context); List <Widget> headerWidgets = new List <Widget>(); float startPadding = 24.0f; if (_selectedRowCount == 0) { headerWidgets.Add(new Expanded(child: widget.header)); if (widget.header is ButtonBar) { startPadding = 12.0f; } } else { headerWidgets.Add(new Expanded( child: new Text(localizations.selectedRowCountTitle(_selectedRowCount)) )); } if (widget.actions != null) { headerWidgets.AddRange( LinqUtils <Widget> .SelectList(widget.actions, ((Widget action) => { return(new Padding( padding: EdgeInsetsDirectional.only( start: 24.0f - 8.0f * 2.0f), child: action )); })) ); } TextStyle footerTextStyle = themeData.textTheme.caption; List <Widget> footerWidgets = new List <Widget>(); if (widget.onRowsPerPageChanged != null) { List <Widget> availableRowsPerPage = LinqUtils <Widget, int> .SelectList( LinqUtils <int> .WhereList(widget.availableRowsPerPage, ((int value) => value <= _rowCount || value == widget.rowsPerPage)), (int value) => { return((Widget) new DropdownMenuItem <int>( value: value, child: new Text($"{value}") )); }); footerWidgets.AddRange(new List <Widget>() { new Container(width: 14.0f), // to match trailing padding in case we overflow and end up scrolling new Text(localizations.rowsPerPageTitle), new ConstrainedBox( constraints: new BoxConstraints(minWidth: 64.0f), // 40.0 for the text, 24.0 for the icon child: new Align( alignment: AlignmentDirectional.centerEnd, child: new DropdownButtonHideUnderline( child: new DropdownButton <int>( items: availableRowsPerPage.Cast <DropdownMenuItem <int> >().ToList(), value: widget.rowsPerPage, onChanged: widget.onRowsPerPageChanged, style: footerTextStyle, iconSize: 24.0f ) ) ) ), }); } footerWidgets.AddRange(new List <Widget>() { new Container(width: 32.0f), new Text( localizations.pageRowsInfoTitle( _firstRowIndex + 1, _firstRowIndex + widget.rowsPerPage, _rowCount, _rowCountApproximate ) ), new Container(width: 32.0f), new IconButton( icon: new Icon(Icons.chevron_left), padding: EdgeInsets.zero, tooltip: localizations.previousPageTooltip, onPressed: _firstRowIndex <= 0 ? (VoidCallback)null : _handlePrevious), new Container(width: 24.0f), new IconButton( icon: new Icon(Icons.chevron_right), padding: EdgeInsets.zero, tooltip: localizations.nextPageTooltip, onPressed: (!_rowCountApproximate && (_firstRowIndex + widget.rowsPerPage >= _rowCount)) ? (VoidCallback)null : _handleNext ), new Container(width: 14.0f), }); return(new LayoutBuilder( builder: (BuildContext _context, BoxConstraints constraints) => { return new Card( child: new Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: new List <Widget> { new DefaultTextStyle( style: _selectedRowCount > 0 ? themeData.textTheme.subtitle1.copyWith(color: themeData.accentColor) : themeData.textTheme.headline6.copyWith(fontWeight: FontWeight.w400), child: IconTheme.merge( data: new IconThemeData( opacity: 0.54f ), child: new Ink( height: 64.0f, color: _selectedRowCount > 0 ? themeData.secondaryHeaderColor : null, child: new Padding( padding: EdgeInsetsDirectional.only( start: startPadding, end: 14.0f), child: new Row( mainAxisAlignment: MainAxisAlignment.end, children: headerWidgets ) ) ) ) ), new SingleChildScrollView( scrollDirection: Axis.horizontal, dragStartBehavior: widget.dragStartBehavior, child: new ConstrainedBox( constraints: new BoxConstraints(minWidth: constraints.minWidth), child: new DataTable( key: _tableKey, columns: widget.columns, sortColumnIndex: widget.sortColumnIndex, sortAscending: widget.sortAscending, onSelectAll: widget.onSelectAll, dataRowHeight: widget.dataRowHeight, headingRowHeight: widget.headingRowHeight, horizontalMargin: widget.horizontalMargin, columnSpacing: widget.columnSpacing, rows: _getRows(_firstRowIndex, widget.rowsPerPage) ) ) ), new DefaultTextStyle( style: footerTextStyle, child: IconTheme.merge( data: new IconThemeData( opacity: 0.54f ), child: new Container( height: 56.0f, child: new SingleChildScrollView( dragStartBehavior: widget.dragStartBehavior, scrollDirection: Axis.horizontal, reverse: true, child: new Row( children: footerWidgets ) ) ) ) ) } ) ); } )); }
void _applyFocusChange() { _haveScheduledUpdate = false; FocusNode previousFocus = _primaryFocus; if (_primaryFocus == null && _markedForFocus == null) { _markedForFocus = rootScope; } D.assert(FocusManagerUtils._focusDebug($"Refreshing focus state. Next focus will be {_markedForFocus}")); if (_markedForFocus != null && _markedForFocus != _primaryFocus) { HashSet <FocusNode> previousPath = previousFocus?.ancestors != null ? new HashSet <FocusNode>(previousFocus.ancestors) : new HashSet <FocusNode>(); HashSet <FocusNode> nextPath = new HashSet <FocusNode>(_markedForFocus.ancestors); foreach (FocusNode node in FocusTravesalUtils.difference(nextPath, previousPath)) { _dirtyNodes.Add(node); } foreach (FocusNode node in FocusTravesalUtils.difference(previousPath, nextPath)) { _dirtyNodes.Add(node); } _primaryFocus = _markedForFocus; _markedForFocus = null; } if (previousFocus != _primaryFocus) { D.assert(FocusManagerUtils._focusDebug($"Updating focus from {previousFocus} to {_primaryFocus}")); if (previousFocus != null) { _dirtyNodes.Add(previousFocus); } if (_primaryFocus != null) { _dirtyNodes.Add(_primaryFocus); } } D.assert(FocusManagerUtils._focusDebug($"Notifying {_dirtyNodes.Count} dirty nodes:", LinqUtils <string, FocusNode> .SelectList(_dirtyNodes, ((FocusNode node) => { return(node.toString()); })) )); foreach (FocusNode node in _dirtyNodes) { node._notify(); } _dirtyNodes.Clear(); if (previousFocus != _primaryFocus) { notifyListeners(); } D.assert(() => { if (FocusManagerUtils._kDebugFocus) { FocusManagerUtils.debugDumpFocusTree(); } return(true); }); }
public override string ToString() { TextTreeRenderer renderer = new TextTreeRenderer(wrapWidth: 400000000); return(string.Join("\n", LinqUtils <string, DiagnosticsNode> .SelectList(diagnostics, ((DiagnosticsNode node) => renderer.render(node).TrimEnd())))); }
public override string ToString() { return($"StorageEntryIdentifier({string.Join(":", LinqUtils<string, PageStorageKey>.SelectList(keys, (x => x.ToString())))})"); }
public override Widget build(BuildContext context) { D.assert(!_debugInteractive || material_.debugCheckHasMaterial(context)); ThemeData theme = Theme.of(context); BoxDecoration _kSelectedDecoration = new BoxDecoration( border: new Border(bottom: Divider.createBorderSide(context, width: dividerThickness)), // The backgroundColor has to be transparent so you can see the ink on the material color: (Theme.of(context).brightness == Brightness.light) ? _grey100Opacity : _grey300Opacity ); BoxDecoration _kUnselectedDecoration = new BoxDecoration( border: new Border(bottom: Divider.createBorderSide(context, width: dividerThickness)) ); bool displayCheckboxColumn = showCheckboxColumn && rows.Any((DataRow row) => row.onSelectChanged != null); bool allChecked = displayCheckboxColumn && !rows.Any((DataRow row) => row.onSelectChanged != null && !row.selected); List <TableColumnWidth> tableColumns = new List <TableColumnWidth>(new TableColumnWidth[columns.Count + (displayCheckboxColumn ? 1 : 0)]); List <TableRow> tableRows = LinqUtils <TableRow, int> .SelectList(Enumerable.Range(0, rows.Count + 1), (index) => { return(new TableRow( key: index == 0 ? _headingRowKey : rows[index - 1].key, decoration: index > 0 && rows[index - 1].selected ? _kSelectedDecoration : _kUnselectedDecoration, children: new List <Widget>(new Widget[tableColumns.Count]) )); }); int rowIndex; int displayColumnIndex = 0; if (displayCheckboxColumn) { tableColumns[0] = new FixedColumnWidth(horizontalMargin + Checkbox.width + horizontalMargin / 2.0f); tableRows[0].children[0] = _buildCheckbox( color: theme.accentColor, isChecked: allChecked, onCheckboxChanged: _check => _handleSelectAll(_check ?? false) ); rowIndex = 1; foreach (DataRow row in rows) { tableRows[rowIndex].children[0] = _buildCheckbox( color: theme.accentColor, isChecked: row.selected, onRowTap: () => { if (row.onSelectChanged != null) { row.onSelectChanged(!row.selected); } }, onCheckboxChanged: _select => row.onSelectChanged(_select ?? false) ); rowIndex += 1; } displayColumnIndex += 1; } for (int dataColumnIndex = 0; dataColumnIndex < columns.Count; dataColumnIndex += 1) { DataColumn column = columns[dataColumnIndex]; float paddingStart; if (dataColumnIndex == 0 && displayCheckboxColumn) { paddingStart = horizontalMargin / 2.0f; } else if (dataColumnIndex == 0 && !displayCheckboxColumn) { paddingStart = horizontalMargin; } else { paddingStart = columnSpacing / 2.0f; } float paddingEnd; if (dataColumnIndex == columns.Count - 1) { paddingEnd = horizontalMargin; } else { paddingEnd = columnSpacing / 2.0f; } EdgeInsetsDirectional padding = EdgeInsetsDirectional.only( start: paddingStart, end: paddingEnd ); if (dataColumnIndex == _onlyTextColumn) { tableColumns[displayColumnIndex] = new IntrinsicColumnWidth(flex: 1.0f); } else { tableColumns[displayColumnIndex] = new IntrinsicColumnWidth(); } var currentColumnIndex = dataColumnIndex; tableRows[0].children[displayColumnIndex] = _buildHeadingCell( context: context, padding: padding, label: column.label, tooltip: column.tooltip, numeric: column.numeric, onSort: column.onSort != null ? () => column.onSort(currentColumnIndex, sortColumnIndex != currentColumnIndex || !sortAscending) : (VoidCallback)null, sorted: dataColumnIndex == sortColumnIndex, ascending: sortAscending ); rowIndex = 1; foreach (DataRow row in rows) { DataCell cell = row.cells[dataColumnIndex]; var curRow = row; tableRows[rowIndex].children[displayColumnIndex] = _buildDataCell( context: context, padding: padding, label: cell.child, numeric: column.numeric, placeholder: cell.placeholder, showEditIcon: cell.showEditIcon, onTap: cell.onTap, onSelectChanged: () => { if (curRow.onSelectChanged != null) { curRow.onSelectChanged(!curRow.selected); } }); rowIndex += 1; } displayColumnIndex += 1; } return(new Table( columnWidths: LinqUtils <int, TableColumnWidth> .SelectDictionary(tableColumns, ((TableColumnWidth x) => tableColumns.IndexOf(x))), children: tableRows )); }