1234567891011121314151617181920212223 |
- import 'package:flutter/material.dart';
- import 'package:flutter_provider_demo/dao/car_dao.dart';
- import 'package:flutter_provider_demo/model/car_model.dart';
- /// Description: car provider
- /// Time : 09/04/2023 Monday
- /// Author : liuyuqi.gov@msn.cn
- class CarProvider extends ChangeNotifier {
- late List<CarModel> _cars;
- int _count = 0;
- Future<List<CarModel>> getCars() async {
- _cars = await CarDao.getCars();
- notifyListeners();
- return _cars;
- }
- void deleteCar(BuildContext context, CarModel car) async {
- await CarDao.deleteCar(car);
- _cars.remove(car);
- notifyListeners();
- }
- }
|