Created
January 9, 2019 19:33
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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