Files
momo/lib/provider/gallery.dart

21 lines
471 B
Dart
Raw Normal View History

2023-02-10 00:07:41 +08:00
import 'package:flutter_riverpod/flutter_riverpod.dart';
2023-02-10 17:33:51 +08:00
import 'package:momo/models/image_resp.dart';
2023-02-10 00:07:41 +08:00
2023-02-10 17:33:51 +08:00
class GalleryNotifier extends Notifier<List<ImageResp>> {
2023-02-10 00:07:41 +08:00
@override
2023-02-10 17:33:51 +08:00
List<ImageResp> build() {
return [];
2023-02-10 00:07:41 +08:00
}
2023-02-10 17:33:51 +08:00
void addImage({required List<ImageResp> imageList}) {
state = [...state, ...imageList];
}
void clearImage() {
state = [];
2023-02-10 00:07:41 +08:00
}
}
2023-02-10 17:33:51 +08:00
final galleryProvider =
NotifierProvider<GalleryNotifier, List<ImageResp>>(() => GalleryNotifier());