Reputation: 7656
Hi I got simple obseverable for testing loading state.
abstract class _AccountStore with Store {
@observable
bool loadingButtonStatus = false;
@observable
bool get loading => loadingButtonStatus;
@action
Future updateAccount(formData) async {
loadingButtonStatus = true;
Future.delayed(Duration(milliseconds: 2000)).then((future) {
loadingButtonStatus = false;
}).catchError((e) {
loadingButtonStatus = false;
print(e);
});
}
}
here is my widget
AccountStore store = AccountStore();
Observer(
name: 'loading_button',
builder: (_) => LoadingButton(
loading: store.loading,
text: Text('Save'),
onPressed: () {
store.updateAccount({});
},
))
But everytime i run the code it always return me: There are no observables detected in the builder function
I've tried changed use store.loadingButtonStatus
still the same.
any solution?
thanks.
Upvotes: 5
Views: 10389
Reputation: 1
run this command in terminal
flutter packages pub run build_runner build
Upvotes: 0
Reputation: 75
I also have seen this error. Because store_name.g.dart not update.
just run scrip flutter pub run build_runner watch --delete-conflicting-outputs
in terminal
Upvotes: 4
Reputation: 1574
I had same issue but above answer didn't working for me and also Code was correct.
my part
was not updated.
just run this command in terminal
flutter packages pub run build_runner build
I hope this will work.
Upvotes: 12
Reputation: 1540
If you use a getter you are required to use @computed.
@observable
bool _loadingButtonStatus = false;
@computed
bool get loading => _loadingButtonStatus;
Upvotes: 8