provider_state_management/lib/provider/card.dart

27 lines
562 B
Dart
Raw Normal View History

2022-08-22 19:18:37 +07:00
import 'package:flutter/material.dart';
import 'package:provider_state/model/products.dart';
class CardProvider extends ChangeNotifier {
int count = 0;
List<ProductModel> localStorage = [];
bool get isLocal => localStorage.isNotEmpty;
void increase() {
count++;
notifyListeners();
}
void addCard(ProductModel data) {
if (data.select != true) {
data.setSelected();
localStorage.add(data);
notifyListeners();
} else {
data.setSelected();
localStorage.remove(data);
notifyListeners();
}
}
}