TableColumnControlHandlesPopupRoute.realtime constructor

TableColumnControlHandlesPopupRoute.realtime({
  1. required BuildContext controlCellBuildContext,
  2. required int columnIndex,
  3. required Listenable? tableViewChanged,
  4. required ColumnResizeCallback? onColumnResize,
  5. required ColumnMoveCallback? onColumnMove,
  6. required ColumnTranslateCallback? onColumnTranslate,
  7. int leadingImmovableColumnCount = 0,
  8. int trailingImmovableColumnCount = 0,
  9. Color? barrierColor,
  10. ResizeHandleBuilder resizeHandleBuilder = _defaultResizeHandleBuilder,
  11. DragHandleBuilder dragHandleBuilder = _defaultDragHandleBuilder,
  12. PopupBuilder? popupBuilder,
  13. EdgeInsets popupPadding = const EdgeInsets.all(16.0),
  14. Duration transitionDuration = const Duration(milliseconds: 200),
  15. ColumnTranslationDurationFunctor columnTranslationDuration = _defaultColumnTranslationDuration,
  16. Curve columnTranslationCurve = Curves.fastOutSlowIn,
})

Creates TableColumnControlHandlesPopupRoute that updates columns in realtime as soon as the gesture happens. Although this results in a better user experience, depending on the complexity of a table and the end platform, frequent rebuilds can cause performance issues.

The position of the controls and TableView/SliverTableView to control are determined by the controlCellBuildContext passed. It is intended that the BuildContext passed to the cellBuilder function is used.

columnIndex is the position of the controlled column.

Other parameters are used as initial values for corresponding ValueNotifier properties of the route that can be changed later in the lifecycle of the route. Refer to their documentation comments for their usage.

Implementation

factory TableColumnControlHandlesPopupRoute.realtime({
  required BuildContext controlCellBuildContext,
  required int columnIndex,
  required Listenable? tableViewChanged,
  required ColumnResizeCallback? onColumnResize,
  required ColumnMoveCallback? onColumnMove,
  required ColumnTranslateCallback? onColumnTranslate,
  int leadingImmovableColumnCount = 0,
  int trailingImmovableColumnCount = 0,
  Color? barrierColor,
  ResizeHandleBuilder resizeHandleBuilder = _defaultResizeHandleBuilder,
  DragHandleBuilder dragHandleBuilder = _defaultDragHandleBuilder,
  PopupBuilder? popupBuilder,
  EdgeInsets popupPadding = const EdgeInsets.all(16.0),
  Duration transitionDuration = const Duration(milliseconds: 200),
  ColumnTranslationDurationFunctor columnTranslationDuration =
      _defaultColumnTranslationDuration,
  Curve columnTranslationCurve = Curves.fastOutSlowIn,
}) {
  var tableContentLayoutState = controlCellBuildContext
      .findAncestorStateOfType<TableContentLayoutState>();
  assert(
    tableContentLayoutState != null,
    'No TableView ancestor found.'
    ' Make sure to pass a correct BuildContext.'
    ' It is intended to use a BuildContext passed to a cellBuilder function.',
  );

  var cellRenderObject = controlCellBuildContext.findRenderObject();
  assert(cellRenderObject is RenderBox);

  var state = controlCellBuildContext
      .findAncestorStateOfType<TableColumnControlsControllable>();
  assert(state != null, 'No TableView ancestor found');
  state = state!;

  assert(
    onColumnMove == null || state.columns[columnIndex].key != null,
    _movingColumnsWithoutKeyAssertionMessage,
  );

  controlCellBuildContext.findRenderObject() as RenderBox;

  return TableColumnControlHandlesPopupRoute._(
    state,
    tableContentLayoutState!,
    cellRenderObject as RenderBox,
    columnIndex,
    state.columns[columnIndex].key!,
    transitionDuration: transitionDuration,
    columnTranslationDuration: columnTranslationDuration,
    columnTranslationCurve: columnTranslationCurve,
    barrierColor: barrierColor,
    dragHandleBuilder: dragHandleBuilder,
    leadingImmovableColumnCount: leadingImmovableColumnCount,
    onColumnMove: onColumnMove,
    onColumnResize: onColumnResize,
    onColumnTranslate: onColumnTranslate,
    popupBuilder: popupBuilder,
    popupPadding: popupPadding,
    resizeHandleBuilder: resizeHandleBuilder,
    trailingImmovableColumnCount: trailingImmovableColumnCount,
    tableViewChanged: tableViewChanged,
  );
}