addtocart
This commit is contained in:
@@ -314,8 +314,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
// const Spacer(),
|
||||
const Spacer(),
|
||||
Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: GestureDetector(
|
||||
@@ -325,27 +324,18 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
|
||||
if (await SharedPrefUtils.getToken() !=
|
||||
null) {
|
||||
if (!(provider
|
||||
.isLoading[bestdealproduct.id] ??
|
||||
false)) {
|
||||
await provider.addToCart(
|
||||
context, bestdealproduct.id!);
|
||||
}
|
||||
// if (!(provider
|
||||
// .isLoading[bestdealproduct.id] ??
|
||||
// false))
|
||||
// {
|
||||
|
||||
await provider.addToCart(
|
||||
context, bestdealproduct.id!);
|
||||
|
||||
// }
|
||||
} else {
|
||||
context.push(MyRoutes.LOGIN);
|
||||
}
|
||||
|
||||
// if (await SharedPrefUtils.getToken() != null)
|
||||
// {
|
||||
|
||||
// provider.isLoading[bestdealproduct.id] ?? false
|
||||
// ? null
|
||||
// : () => provider.addToCart(
|
||||
// context, bestdealproduct.id!);
|
||||
// } else
|
||||
// {
|
||||
// context.push(MyRoutes.LOGIN);
|
||||
// }
|
||||
},
|
||||
child: Container(
|
||||
height: MediaQuery.of(context).size.height *
|
||||
@@ -353,23 +343,29 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
width:
|
||||
MediaQuery.of(context).size.width * 0.1,
|
||||
decoration: BoxDecoration(
|
||||
color: provider.cartItems
|
||||
.contains(bestdealproduct.id)
|
||||
? Colors.grey
|
||||
: APPCOLOR.lightGreen,
|
||||
color: APPCOLOR.lightGreen,
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
),
|
||||
child: Center(
|
||||
child: provider.isLoading[
|
||||
bestdealproduct.id] ??
|
||||
false
|
||||
? CircularProgressIndicator(
|
||||
color: Colors.white, strokeWidth: 2)
|
||||
? Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Container(
|
||||
height: 10,
|
||||
width: 10,
|
||||
child: CircularProgressIndicator(
|
||||
color: Colors.white,
|
||||
strokeWidth: 2),
|
||||
),
|
||||
)
|
||||
: Text(
|
||||
provider.cartItems.contains(
|
||||
bestdealproduct.id)
|
||||
? 'Added'
|
||||
: 'Add',
|
||||
// provider.cartItems
|
||||
// .contains(bestdealproduct.id)
|
||||
// ? 'Added'
|
||||
// :
|
||||
'Add',
|
||||
style: context.customRegular(
|
||||
Colors.white, 12),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user