Skip to content

Instantly share code, notes, and snippets.

@GIfatahTH
Last active February 18, 2019 16:35
Show Gist options
  • Save GIfatahTH/de360e4caf3fd7d4bab1be8fb6107ed1 to your computer and use it in GitHub Desktop.
Save GIfatahTH/de360e4caf3fd7d4bab1be8fb6107ed1 to your computer and use it in GitHub Desktop.
main.dart file of scoped_model
class MainModel extends Model {
final itemProvider = ItemProvider();
List<Item> items;
Color detailedColor; // The color of the tapped card from the ListView
int detailedIndex; // The index of the tapped card from the ListView
getItems() async {
items = await itemProvider.fetchItems();
notifyListeners();
}
showDetailed(Color color, int index) {
detailedColor = color;
detailedIndex = index;
notifyListeners();
}
increment() {
items[detailedIndex].count++;
notifyListeners();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment