Add viewCart function

This commit is contained in:
Moe Poi ~ 2022-04-26 10:45:04 +07:00
parent de612bc1c6
commit 9967caf0cd

View file

@ -38,4 +38,11 @@ Future<void> removeFromCart(productId, bool batch) async {
}
}
await prefs.setString('cart', jsonEncode(cart).toString());
}
Future<dynamic> viewCart(productId, bool batch) async {
final prefs = await SharedPreferences.getInstance();
var cart = jsonDecode(prefs.getString('cart') ?? '[]');
return cart;
}