-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcontrollers.dart
52 lines (29 loc) · 902 Bytes
/
controllers.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
import 'models.dart';
class Inter{}
class MainController extends Inter with ProductController, FavController{}
mixin ProductController on Inter{
Products createProductObject(Map<String, dynamic> product) {
Products _newProduct = Products.fromJson(product);
return _newProduct;
}
List<Products> createListOfProductObj(List<Map<String, dynamic>> products) {
List<Products> _allNewProducts = [];
products.forEach((i) {
Products _newProduct = createProductObject(i);
_allNewProducts.add(_newProduct);
});
return _allNewProducts;
}
}
mixin FavController on Inter{
List<Products> _allFav = [];
List<Products> get allFav => _allFav;
addFav(Products product, String userName, int id) {
product.isFav = true;
_allFav.add(product);
}
removeFav(Products product) {
product.isFav = false;
_allFav.remove(product);
}
}