Skip to content

Instantly share code, notes, and snippets.

@jesusrp98
Created January 9, 2019 19:33
Show Gist options
  • Save jesusrp98/25040ea05b91e6913d0e34a3fd26d672 to your computer and use it in GitHub Desktop.
Save jesusrp98/25040ea05b91e6913d0e34a3fd26d672 to your computer and use it in GitHub Desktop.
General model used to help retrieve, parse & storage information from a public API
import 'dart:async';
import 'package:scoped_model/scoped_model.dart';
/// QUERRY MODEL
/// General model used to help retrieve, parse & storage
/// information from a public API
abstract class QuerryModel extends Model {
List _items = List();
List _photos = List();
List snapshot;
var response;
bool _loading = true;
Future refresh() async {
clearItems();
await loadData();
notifyListeners();
}
void setLoading(bool state) {
_loading = state;
notifyListeners();
}
Future loadData();
List get items => _items;
List get photos => _photos;
dynamic getItem(index) => _items[index];
String getPhoto(index) => _photos[index];
int get getItemCount => _items.length;
int get getPhotosCount => _photos.length;
bool get isLoading => _loading;
clearItems() => _items.clear();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment