Skip to content

Instantly share code, notes, and snippets.

@marcossevilla
Created May 4, 2021 17:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcossevilla/c9d5c5d81a887e428310d711d7684140 to your computer and use it in GitHub Desktop.
Save marcossevilla/c9d5c5d81a887e428310d711d7684140 to your computer and use it in GitHub Desktop.
// 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