Last active
November 2, 2022 08:45
-
-
Save Bharathh-Raj/557c9abad9f538e6975cfdc2cd5ef609 to your computer and use it in GitHub Desktop.
Flutter testing - Repository
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
//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; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
where does
Failure()
class come from?