backend
This commit is contained in:
parent
193ae3b0ea
commit
3e374d24f6
13 changed files with 126 additions and 3 deletions
26
lib/features/home/services/images_service.dart
Normal file
26
lib/features/home/services/images_service.dart
Normal file
|
@ -0,0 +1,26 @@
|
|||
import 'package:mc_gallery/features/home/data/models/image_model.dart';
|
||||
import 'package:mc_gallery/locator.dart';
|
||||
|
||||
import '../abstracts/images_api.dart';
|
||||
|
||||
/// Handles fetching and storing of Images.
|
||||
///
|
||||
/// Since this is very simple use-case, this is the only interface. For complex (actual CRUD-based) I/O,
|
||||
/// an additional Repository layer interface can be used between [ImagesService] and [ImagesApi].
|
||||
class ImagesService {
|
||||
ImagesService({required ImagesApi imagesApi}) : _imagesApi = imagesApi {
|
||||
_init();
|
||||
}
|
||||
|
||||
final ImagesApi _imagesApi;
|
||||
|
||||
late final Iterable<ImageModel> _imageModels;
|
||||
|
||||
Future<void> _init() async {
|
||||
_imageModels = await _imagesApi.fetchImageUri(token: '');
|
||||
|
||||
Locator.instance().signalReady(this);
|
||||
}
|
||||
|
||||
static ImagesService get locate => Locator.locate();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue