📅  最后修改于: 2022-03-11 14:58:28.398000             🧑  作者: Mango
import 'dart:async';
class BaseModel {
Map objects;
StreamController fetchDoneController = new StreamController.broadcast();
// define constructor here
fetch() {
// fetch json from server and then load it to objects
// emits an event here
fetchDoneController.add("all done"); // send an arbitrary event
}
Stream get fetchDone => fetchDoneController.stream;
}
// over in youre app file
main() {
var model = new BaseModel();
model.fetchDone.listen((_) => doCoolStuff(model));
}