getChild method

  1. @protected
JsonWidgetData getChild(
  1. JsonWidgetData? data, {
  2. int index = 0,
})
inherited

Returns a non-null child for widgets that must always have child widgets. This allows the widget to be built and rendered even if the child is missing.

Implementation

@protected
JsonWidgetData getChild(JsonWidgetData? data, {int index = 0}) {
  late JsonWidgetData child;

  if (data?.children?.isNotEmpty == true && data!.children!.length > index) {
    child = data.children![index];
  } else {
    child = kDefaultChild;
  }

  return child;
}