-
Notifications
You must be signed in to change notification settings - Fork 0
/
cocktails.dart
74 lines (66 loc) · 1.56 KB
/
cocktails.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import 'dart:convert';
import 'dart:ffi';
class Cocktail{
int id;
String name;
String category;
String glass;
String instructions;
String imageUrl;
bool alcoholic;
List<Ingredient>? ingredients;
Cocktail.fromJson(Map json):
id = json['id'],
name = json['name'],
category = json['category'],
glass = json['glass'],
instructions = json['instructions'],
imageUrl = json['imageUrl'],
alcoholic = json['alcoholic'],
ingredients = (json['ingredients'] as List?)?.map(
(ingredient) => Ingredient.fromJson(ingredient)
).toList();
Map mapa(){
return {
'id': id,
'name': name,
'category': category,
'glass': glass,
'instructions': instructions,
'imageUrl': imageUrl,
'alcoholic': alcoholic,
'ingredients': ingredients
};
}
}
class Ingredient{
int id;
String name;
String? description;
bool alcohol;
String? type;
int? percentage;
String? imageUrl;
String measure;
Ingredient.fromJson(Map json):
id = json['id'],
name = json['name'],
description = json['description'],
alcohol = json['alcohol'],
type = json['type'],
percentage = json['percentage'],
imageUrl = json['imageUrl'],
measure = json['measure'];
Map map(){
return {
'id': id,
'name': name,
'description': description,
'alcohol': alcohol,
'type': type,
'percentage': percentage,
'imageUrl': imageUrl,
'measure': measure
};
}
}