create method

Future<Map<String, dynamic>?> create(
  1. String key,
  2. Map<String, dynamic> value
)

Implementation

Future<Map<String, dynamic>?> create(
    String key, Map<String, dynamic> value) async {
  final response = await http.post(Uri.parse(_url! + '/' + key + '.json'),
      body: jsonEncode(value), headers: {'content-type': "application/json"});
  if (response.statusCode == 200) {
    print(response.statusCode);
    var jsonResponse = jsonDecode(response.body);
    return jsonResponse;
  } else {
    print('Request failed with status: ${response.statusCode}.');
    return null;
  }
}