I'm trying to build an Expense tracker App in Flutter and has decided to use Scoped Model for state management. The App has a User who can have many Accounts and each account can have many Transactions.
How do I model these to be used with Scoped Model, I am stuck on selecting a good Architecture.
If I create a UserModel that has a list of Accounts where each Account is an AccountModel then triggering and update from inside AccountModel would not trigger the ones accessing the UserModel class.
class CombinedWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
final username =
ScopedModel.of<UserModel>(context, rebuildOnChange: true).username;
final counter =
ScopedModel.of<CounterModel>(context, rebuildOnChange: true).counter;
return Text('$username tapped the button $counter times');
}
}
you can see complete example in source .