1import 'package:http/http.dart' as http;
2import 'dart:convert';
3class API
4{
5//replace with your endpoint
6static String BASE_URL = 'https://some-url/api/';
7
8 static Future<List<ExampleData>> getRequest() async {
9
10 Response res = await http.get(BASE_URL+'example');
11
12 if (res.statusCode == 200) {
13 List<dynamic> body = jsonDecode(res.body);
14
15 // complete by parsing the json body return into ExampleData object and return
16 //.................
17 }
18}
19
20}
21
1final queryParameters = {
2 'name': 'Bob',
3 'age': '87',
4};
5final uri = Uri.http('www.example.com', '/path', queryParameters);
6final headers = {HttpHeaders.contentTypeHeader: 'application/json'};
7final response = await http.get(uri, headers: headers);
8