Skip to content

Commit f62c040

Browse files
committed
Snackbar optimizations and multiselect using ValueNotifier for efficiency
1 parent e4d4a22 commit f62c040

3 files changed

Lines changed: 32 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## 7.4.0-prerelease4
4+
5+
- Added multi selection support to `ThemedTable2` with `ValueNotifier` to handle the selected items.
6+
- Updates on `ThemedSnackbar` to prevent issues with multiple snackbars in the queue.
7+
38
## 7.4.0-prerelease3
49

510
- Added multi selection support to `ThemedTable2` with actions

lib/src/snackbar/src/messenger.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ class ThemedSnackbarMessengerState extends State<ThemedSnackbarMessenger>
9494
WidgetsBinding.instance.addPostFrameCallback((_) {
9595
setState(() {});
9696

97+
if (_timerController.isAnimating || _fadeController.isAnimating) return;
9798
_resetControllers();
9899
});
99100
}

lib/src/table2/src/table.dart

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ class ThemedTable2<T> extends StatefulWidget {
5454
/// Consider that the list will be appened with the clear button
5555
final List<ThemedActionButton> multiselectActions;
5656

57+
/// [multiselectValue] is the value change listener for the multi-select checkbox list.
58+
final ValueNotifier<List<T>>? multiselectValue;
59+
5760
const ThemedTable2({
5861
required this.items,
5962
required this.columns,
@@ -71,7 +74,18 @@ class ThemedTable2<T> extends StatefulWidget {
7174
this.multiSelectionTitleText = "Multiple items selected",
7275
this.multiSelectionContentText = "You have selected multiple items. What do you want to do?",
7376
this.multiSelectionCancelLabelText = "Clear",
74-
}) : assert(columns.length > 0, 'Columns cant be empty');
77+
this.multiselectValue,
78+
}) : assert(columns.length > 0, 'Columns cant be empty'),
79+
assert(actionsCount >= 0, 'Actions count cant be negative'),
80+
assert(minColumnWidth > 0, 'Min column width must be greater than 0'),
81+
assert(
82+
actionsCount == 0 || actionsBuilder != null,
83+
'If actionsCount is greater than 0, actionsBuilder must be provided',
84+
),
85+
assert(
86+
multiselectActions.length > 0 && hasMultiselect && multiselectValue != null,
87+
'If hasMultiselect is true, multiselectActions and multiselectValue must be provided',
88+
);
7589

7690
@override
7791
State<ThemedTable2<T>> createState() => _ThemedTable2State<T>();
@@ -565,6 +579,7 @@ class _ThemedTable2State<T> extends State<ThemedTable2<T>> {
565579
Center(
566580
child: SingleChildScrollView(
567581
child: Row(
582+
spacing: 5,
568583
mainAxisAlignment: MainAxisAlignment.center,
569584
crossAxisAlignment: CrossAxisAlignment.center,
570585
children: [
@@ -578,6 +593,16 @@ class _ThemedTable2State<T> extends State<ThemedTable2<T>> {
578593
setState(() {});
579594
},
580595
),
596+
...widget.multiselectActions.map((action) {
597+
return ThemedButton(
598+
labelText: action.labelText,
599+
icon: action.icon,
600+
color: action.color,
601+
onTap: action.onTap,
602+
isLoading: action.isLoading,
603+
isCooldown: action.isCooldown,
604+
);
605+
}),
581606
],
582607
),
583608
),

0 commit comments

Comments
 (0)