Describe the bug
demo code like below:
class _SimpleTableRefreshLoadPageState
extends State<SimpleTableRefreshLoadPage> {
late bool conditionSometimeFalse;
@override
void initState() {
widget.user.initData(5);
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Pull-to-refresh Table')),
body: tableView(),
);
}
Widget tableView() {
final HDTRefreshController hdtRefreshController = HDTRefreshController();
if (conditionSometimeFalse) {
return const Center(
child: CircularProgressIndicator(),
);
}
return HorizontalDataTable(
leftHandSideColumnWidth: 100,
rightHandSideColumnWidth: 300,
headerWidgets: _getTitleWidget(),
leftSideItemBuilder: _generateFirstColumnRow,
rightSideItemBuilder: _generateRightHandSideColumnRow,
itemCount: widget.user.userInfo.length,
enablePullToLoadNewData: true,
loadIndicator: const ClassicFooter(),
onLoad: () async {
debugPrint('onLoad');
//Do sth
await Future.delayed(const Duration(milliseconds: 500));
hdtRefreshController.loadComplete();
},
htdRefreshController: hdtRefreshController,
);
}
i found HDTRefreshController.loadComplete() sometimes not worked ,the footer is still show loading even if the HDTRefreshController.loadComplete() has been executed。
UPDATE: after exploring a long time , i found the cause。
this bug happend because of: HDTRefreshController not has a same lifecycle as table widget;
in the demo code, HDTRefreshController will created by every build, but been seted controller only when table widget init [_HorizontalDataTableState : initState],
so , i change the code like this , but it looks strange
class _SimpleTableRefreshLoadPageState
extends State<SimpleTableRefreshLoadPage> {
late bool conditionSometimeFalse;
HDTRefreshController? hdtRefreshController;
@override
void initState() {
widget.user.initData(5);
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Pull-to-refresh Table')),
body: tableView(),
);
}
Widget tableView() {
if (conditionSometimeFalse) {
hdtRefreshController = null;
return const Center(
child: CircularProgressIndicator(),
);
}
hdtRefreshController?? HDTRefreshController();
return HorizontalDataTable(
leftHandSideColumnWidth: 100,
rightHandSideColumnWidth: 300,
headerWidgets: _getTitleWidget(),
leftSideItemBuilder: _generateFirstColumnRow,
rightSideItemBuilder: _generateRightHandSideColumnRow,
itemCount: widget.user.userInfo.length,
enablePullToLoadNewData: true,
loadIndicator: const ClassicFooter(),
onLoad: () async {
debugPrint('onLoad');
//Do sth
await Future.delayed(const Duration(milliseconds: 500));
hdtRefreshController?.loadComplete();
},
htdRefreshController: hdtRefreshController,
);
}
Platform
All
Additional context
Add any other context about the problem here.
Describe the bug
demo code like below:
i found HDTRefreshController.loadComplete() sometimes not worked ,the footer is still show loading even if the HDTRefreshController.loadComplete() has been executed。
UPDATE: after exploring a long time , i found the cause。
this bug happend because of: HDTRefreshController not has a same lifecycle as table widget;
in the demo code, HDTRefreshController will created by every build, but been seted controller only when table widget init [_HorizontalDataTableState : initState],
so , i change the code like this , but it looks strange
Platform
All
Additional context
Add any other context about the problem here.