setDefaultLayout method

dynamic setDefaultLayout(
  1. LayoutConfiguration<T> layout, {
  2. required FromJsonConverter<LayoutConfiguration<T>> fromJson,
})

Implementation

setDefaultLayout(LayoutConfiguration<T> layout,
    {required FromJsonConverter<LayoutConfiguration<T>> fromJson}) {
  _defaultLayout = layout;

  final currentLayoutSchemaType = _defaultLayoutDescriptor.schemaType;

  _defaultLayoutDescriptor = TypeDescriptor<LayoutConfiguration<T>>(
    schemaType: currentLayoutSchemaType,
    fromJson: fromJson,
    title: 'Override Layout for ${content.schemaType}',
  );

  registerDescriptors<LayoutConfiguration>([_defaultLayoutDescriptor]);

  _layouts.removeWhere((td) => td.schemaType == currentLayoutSchemaType);
  _layouts.insert(0, _defaultLayoutDescriptor);
}