-
-
Save marcossevilla/c9d5c5d81a887e428310d711d7684140 to your computer and use it in GitHub Desktop.
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
// imports remote data source abstract class | |
import 'package:http/http.dart' show Client; | |
class AnotherRemoteDataSource implements IRemoteDataSource { | |
AnotherRemoteDataSource({ | |
required String url, | |
required Client client, | |
}) : _url = url, | |
_client = client; | |
final String _url; | |
final Client _client; | |
@override | |
Future<SomeModel> getModel() async { | |
try { | |
final result = await _client.get(Uri(scheme: _url)); | |
if (response.statusCode != 200) throw ServerException(); | |
final decode = json.decode(result.body); | |
return SomeModel.fromJson(decode); | |
} catch (e) { | |
throw ServerException(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment