MhItemsViewState<T> constructor
MhItemsViewState<T> ({
- required MhItemsView<
T> widget, - required List<
T> itemsSource, - List<
MhItemsViewColumnDef< ? columnDefs,T> > - MhItemsViewSettings<
T> ? settings, - MhItemsViewTheme? themeLight,
- MhItemsViewTheme? themeDark,
- required void setState(),
- String debugName = "noName",
Implementation
MhItemsViewState(
{required this.widget,
required this.itemsSource,
List<MhItemsViewColumnDef<T>>? columnDefs,
MhItemsViewSettings<T>? settings,
MhItemsViewTheme? themeLight,
MhItemsViewTheme? themeDark,
required this.setState,
this.debugName = "noName"}) {
this.columnDefs = columnDefs ?? [MhItemsViewColumnDef.buildDefault<T>()];
this.settings = settings ?? MhItemsViewSettings<T>();
this.themeLight = themeLight ?? MhItemsViewTheme();
this.themeDark = themeDark ?? MhItemsViewTheme();
// show or remove the selection Column according to the settings
if (this.settings.selectionSettings.showSelectColumn &&
!this.columnDefs.any(
(element) => element.columnType == CdItemsViewColumnTypes.select)) {
this.columnDefs.insert(
0,
MhItemsViewColumnDef(
id: selectionColumnId,
columnWidth: 50,
columnType: CdItemsViewColumnTypes.select));
}
if (!this.settings.selectionSettings.showSelectColumn &&
this.columnDefs.any((element) =>
element.columnType == CdItemsViewColumnTypes.select &&
element.id == selectionColumnId)) {
var colDefSelect = this.columnDefs.firstWhere((element) =>
element.columnType == CdItemsViewColumnTypes.select &&
element.id == selectionColumnId);
this.columnDefs.remove(colDefSelect);
}
// show or remove the reorder Column according to the settings
if (this.settings.dragDropSettings.showReorderColumn &&
!this.columnDefs.any((element) =>
element.columnType == CdItemsViewColumnTypes.reorder)) {
this.columnDefs.insert(
0,
MhItemsViewColumnDef(
id: reorderColumnId,
columnWidth: 40,
columnType: CdItemsViewColumnTypes.reorder));
}
if (!this.settings.dragDropSettings.showReorderColumn &&
this.columnDefs.any((element) =>
element.columnType == CdItemsViewColumnTypes.reorder &&
element.id == reorderColumnId)) {
var colDefReorder = this.columnDefs.firstWhere((element) =>
element.columnType == CdItemsViewColumnTypes.reorder &&
element.id == reorderColumnId);
this.columnDefs.remove(colDefReorder);
}
refreshFilter();
}