27 lines
562 B
Dart
27 lines
562 B
Dart
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();
|
|
}
|
|
}
|
|
}
|