fix: problema de assincronicidade com o setState do LocalProfileComponent

This commit is contained in:
J. A. Messias 2024-11-13 08:31:57 -03:00
parent e470a612b2
commit a47319d29a
1 changed files with 5 additions and 4 deletions

View File

@ -27,14 +27,14 @@ class _LocalProfileComponentWidgetState extends State<LocalProfileComponentWidge
@override
void setState(VoidCallback callback) {
super.setState(callback);
_model.onUpdate();
callback();
}
@override
void initState() {
super.initState();
_model = createModel(context, () => LocalProfileComponentModel());
_model.setOnUpdate(onUpdate: () => setState(() {}));
_model.setOnUpdate(onUpdate: () => safeSetState(() {}));
_model.setStateCallback = () => safeSetState(() {});
WidgetsBinding.instance.addPostFrameCallback((_) async {
@ -54,9 +54,10 @@ class _LocalProfileComponentWidgetState extends State<LocalProfileComponentWidge
super.dispose();
}
void onUpdate() {
void onUpdate() async {
log('() => onUpdate()');
safeSetState(() async => await _model.getData());
await _model.getData();
safeSetState(() {});
}
@override