|
@@ -32,6 +32,7 @@ class VitalTable<T> extends StatefulWidget {
|
|
|
this.rowTextStyle,
|
|
|
this.selectedTextStyle,
|
|
|
this.noDataHintText,
|
|
|
+ this.currectSelected,
|
|
|
}) : assert(() {
|
|
|
if (showSelect == true && selecteds == null) {
|
|
|
throw FlutterError(
|
|
@@ -106,6 +107,9 @@ class VitalTable<T> extends StatefulWidget {
|
|
|
/// 选中行文本样式
|
|
|
final TextStyle? selectedTextStyle;
|
|
|
|
|
|
+ /// 当前选中的
|
|
|
+ int? currectSelected = -1;
|
|
|
+
|
|
|
@override
|
|
|
State<StatefulWidget> createState() => _VitalTableState<T>();
|
|
|
}
|
|
@@ -114,11 +118,15 @@ class _VitalTableState<T> extends State<VitalTable<T>> {
|
|
|
final ScrollController _scrollController = ScrollController();
|
|
|
List<int> _selectedIdxs = [];
|
|
|
List<T> _source = [];
|
|
|
- int _currectSelected = -1;
|
|
|
+ late int _currectSelected = widget.currectSelected ?? -1;
|
|
|
|
|
|
@override
|
|
|
void didUpdateWidget(VitalTable<T> oldWidget) {
|
|
|
_loadData();
|
|
|
+ if (widget.currectSelected != oldWidget.currectSelected) {
|
|
|
+ _currectSelected = widget.currectSelected ?? -1;
|
|
|
+ setState(() {});
|
|
|
+ }
|
|
|
super.didUpdateWidget(oldWidget);
|
|
|
}
|
|
|
|
|
@@ -131,7 +139,6 @@ class _VitalTableState<T> extends State<VitalTable<T>> {
|
|
|
void _loadData() {
|
|
|
_selectedIdxs = [if (widget.selecteds != null) ...widget.selecteds!];
|
|
|
_source = widget.source ?? [];
|
|
|
- _currectSelected = -1;
|
|
|
}
|
|
|
|
|
|
@override
|