Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- WishlistSource ws = WishlistSource();
- bool _isFavorite = false;
- toogleWishlist() async {
- bool isFavorite = await ws.isWishlist(widget.products.code);
- setState(() => _isFavorite = isFavorite);
- }
- @override
- void initState() {
- toogleWishlist();
- super.initState();
- }
- Widget _favorite() {
- return Positioned(
- right: 4.0,
- bottom: 4.0,
- child: Material(
- elevation: 1.0,
- clipBehavior: Clip.antiAliasWithSaveLayer,
- shape: CircleBorder(),
- color: Colors.white.withOpacity(0.95),
- child: IconButton(
- // color: _isFavorite ? Colors.red : ThemeApp.registerButton,
- icon: Icon(_isFavorite ? Icons.favorite : Icons.favorite_border),
- onPressed: () async {
- try {
- await ws.toggle(widget.products);
- await toogleWishlist();
- print('data $toogleWishlist');
- print('masuk ${widget.products}');
- } catch (e) {
- print(e);
- }
- setState(() {
- _isFavorite = _isFavorite ? false : true;
- });
- },
- ),
- ),
- );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement