sublistCallback method

  1. @protected
void sublistCallback(
  1. BuildContext context
)
inherited

Create a callback to push children to the nearest DefaultNestedListController.

Can be used as a callback for activation of menu items with nested items.

Implementation

@protected
void sublistCallback(BuildContext context) {
  assert(() {
    if (context.widget is! DefaultNestedListController &&
        context.findAncestorWidgetOfExactType<
                DefaultNestedListController<T>>() ==
            null) {
      throw FlutterError.fromParts(<DiagnosticsNode>[
        ErrorSummary('No DefaultNestedListController<$T> found.'),
        ErrorDescription('Sublists use DefaultNestedListController to '
            'maintain their state. Therefore a DefaultNestedListController '
            '''with matching type '$T' must be in the tree above a '''
            'NestedListItem.'),
        ErrorHint('You can include a DefaultNestedListController<$T> widget '
            'above this one in the widget tree.'),
      ]);
    }

    return true;
  }(), 'unnreachable');

  DefaultNestedListController.of<T>(context)!.push(this as T);
}