Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'package:http/http.dart' as http;
- import 'util/Launch.dart';
- class Services {
- static const String url = 'https://api.spacexdata.com/v2/launches';
- final launch = launchFromJson(url);
- static Future<List<Launch>> getLaunches() async {
- try {
- final response = await http.get(url);
- if (response.statusCode == 200) {
- final List<Launch> listOfLaunches = launchFromJson(response.body);
- return listOfLaunches;
- } else {
- return List<Launch>();
- }
- } catch (e) {
- return List<Launch>();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment