FromJsonBloc constructor
FromJsonBloc(
- AppModel app,
- MemberModel member
Implementation
FromJsonBloc(this.app, this.member) : super(FromJsonUninitialised()) {
on<FromJsonInitialise>((event, emit) async {
emit(FromJsonInitialised());
});
on<NewFromJsonWithUrl>((event, emit) async {
runTasks(
await JsonToModelsHelper.createOtherFromURL(
app, member.documentID, event.url, event.includeMedia,
feedback: feedback),
event.postCreationAction);
});
on<NewFromJsonWithModel>((event, emit) async {
runTasks(
await JsonToModelsHelper.createOtherFromMemberMedium(app,
member.documentID, event.memberMediumModel, event.includeMedia,
feedback: feedback),
event.postCreationAction);
});
on<NewFromJsonWithClipboard>((event, emit) async {
var json = await Clipboard.getData(Clipboard.kTextPlain);
if (json != null) {
var jsonText = json.text;
if (jsonText != null) {
runTasks(
await JsonToModelsHelper.createOtherFromJson(
app, member.documentID, jsonText, event.includeMedia,
feedback: feedback),
event.postCreationAction);
} else {
throw Exception("Json text is null");
}
} else {
throw Exception("json is null");
}
});
on<NewFromJsonCancelAction>((event, emit) async {
emit(FromJsonActionCancelled());
});
on<FromJsonProgressEvent>((event, emit) async {
emit(FromJsonProgress(event.progress));
});
}