Skip to content

Instantly share code, notes, and snippets.

@Bharathh-Raj
Last active November 2, 2022 08:45
Show Gist options
  • Save Bharathh-Raj/557c9abad9f538e6975cfdc2cd5ef609 to your computer and use it in GitHub Desktop.
Save Bharathh-Raj/557c9abad9f538e6975cfdc2cd5ef609 to your computer and use it in GitHub Desktop.
Flutter testing - Repository
//Note: This code is just for demonstration purpose
class Repository {
final RemoteDateSource remoteDateSource;
Repository(this.remoteDateSource);
Future<Student> fetch() async {
late String result;
try {
result = await remoteDateSource.fetch();
} catch (e) {
throw Failure(e);
}
Student student = Student.fromString(result);
return student;
}
}
class RemoteDateSource {
Future<String> fetch() async {
final result = await httpClient.get("");
return result;
}
}
@topex-psy
Copy link

where does Failure() class come from?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment