@@ -8,6 +8,7 @@ import 'package:final_app/Helper/SubCategories.dart';
8
8
import 'package:final_app/Helper/SubCategoriesApi.dart' ;
9
9
import 'package:final_app/Helper/TrendingNow.dart' ;
10
10
import 'package:final_app/Helper/TrendingNowApi.dart' ;
11
+ import 'package:final_app/api/cart.dart' ;
11
12
import 'package:final_app/pages/HomePage.dart' ;
12
13
import 'package:final_app/pages/ProfilePage.dart' ;
13
14
import 'package:flutter/services.dart' ;
@@ -17,6 +18,7 @@ import 'package:final_app/api/loginApi.dart';
17
18
import 'package:final_app/models/Categories.dart' ;
18
19
import 'package:flutter/material.dart' ;
19
20
import 'package:google_fonts/google_fonts.dart' ;
21
+ import 'package:badges/badges.dart' ;
20
22
import '../Constants.dart' ;
21
23
22
24
import 'package:final_app/Helper/nav_drawer.dart' ;
@@ -33,18 +35,29 @@ class _MainPageState extends State<MainPage> {
33
35
title: Text ("Home" ),
34
36
backgroundColor: Colors .redAccent),
35
37
BottomNavigationBarItem (
36
- icon: Icon (Icons .shop), title: Text ("Shop" ), backgroundColor: Colors .redAccent),
38
+ icon: Icon (Icons .shop),
39
+ title: Text ("Shop" ),
40
+ backgroundColor: Colors .redAccent),
37
41
BottomNavigationBarItem (
38
42
icon: Icon (Icons .person),
39
43
title: Text ("Profile" ),
40
44
backgroundColor: Colors .redAccent),
41
45
];
42
46
47
+ int count= 0 ;
48
+
43
49
@override
44
50
void initState () {
45
51
super .initState ();
46
52
print ("======================== Trending Now Listing ==========" );
47
53
CategoriesList .TrendingNowListing ();
54
+ CartApi .cartCount ().then ((value) {
55
+ if (value != 0 ) {
56
+ setState (() {
57
+ count = value;
58
+ });
59
+ }
60
+ });
48
61
}
49
62
50
63
int _currentIndex = 0 ;
@@ -113,13 +126,14 @@ class _MainPageState extends State<MainPage> {
113
126
child: CircleAvatar (
114
127
backgroundColor: Colors .white,
115
128
child: GestureDetector (
116
- onTap: () {
117
- Navigator .of (context).pushNamed ('/Cart' );
118
- },
119
- child: Icon (
120
- Icons .shopping_cart,
121
- color: Colors .redAccent,
122
- )),
129
+ onTap: () {
130
+ Navigator .of (context).pushNamed ('/Cart' );
131
+ },
132
+ child: Badge (
133
+ badgeContent: Text ("$count " ,style: TextStyle (color: Colors .white),),
134
+ child: Icon (Icons .shopping_cart),
135
+ ),
136
+ ),
123
137
),
124
138
)
125
139
],
0 commit comments