Compare commits
2 Commits
d3a8a401c4
...
235cfd21dc
Author | SHA1 | Date |
---|---|---|
Mguy13 | 235cfd21dc | |
Mguy13 | 53d13927fd |
17
README.md
17
README.md
|
@ -1,16 +1,13 @@
|
||||||
# mc_gallery
|
# mc_gallery
|
||||||
|
|
||||||
A new Flutter project.
|
## Dart docs explanation
|
||||||
|
|
||||||
## Getting Started
|
## Emulation
|
||||||
|
|
||||||
This project is a starting point for a Flutter application.
|
## Maintaining scope
|
||||||
|
It's an 'assignment'
|
||||||
|
|
||||||
A few resources to get you started if this is your first Flutter project:
|
## Model vs. DTO
|
||||||
|
|
||||||
- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab)
|
## Extra quirks
|
||||||
- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook)
|
Just because I had those assets lying around
|
||||||
|
|
||||||
For help getting started with Flutter development, view the
|
|
||||||
[online documentation](https://docs.flutter.dev/), which offers tutorials,
|
|
||||||
samples, guidance on mobile development, and a full API reference.
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
import 'package:string_similarity/string_similarity.dart';
|
||||||
|
|
||||||
|
abstract class ConstSorters {
|
||||||
|
/// Uses Dice's Coefficient as a similarity metric, for a 2-way comparison, between a [targetWord]
|
||||||
|
/// and given words.
|
||||||
|
static int stringsSimilarityTarget(String a, String b, {required String targetWord}) =>
|
||||||
|
a.similarityTo(targetWord).compareTo(b.similarityTo(targetWord));
|
||||||
|
}
|
|
@ -1,3 +1,6 @@
|
||||||
extension MapExtensions<A, B> on Map<A, B> {
|
extension MapExtensions<A, B> on Map<A, B> {
|
||||||
Map<A, B> get deepCopy => {...this};
|
Map<A, B> get deepCopy => {...this};
|
||||||
|
|
||||||
|
/// Returns the values of a [Map] at given [keys] indices.
|
||||||
|
Iterable<B> valuesByKeys({required Iterable<A> keys}) => keys.map((final key) => this[key]!);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
extension ObjectExtensions on Object? {
|
||||||
|
E asType<E>() => this as E;
|
||||||
|
E? asNullableType<E>() => this as E?;
|
||||||
|
}
|
||||||
|
|
||||||
|
extension AsCallback<T extends Object> on T {
|
||||||
|
T Function() get asCallback => () => this;
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
extension StringExtensions on String {
|
||||||
|
/// Returns true if given word contains atleast all the characters in [targetChars], and `false` otherwise
|
||||||
|
///
|
||||||
|
/// Very efficient `O(n)` instead of naive `O(n*m)`
|
||||||
|
bool containsAllCharacters({required String targetChars}) {
|
||||||
|
final Set<String> characterSet = Set.from(targetChars.split(''));
|
||||||
|
for (final testChar in split('')) {
|
||||||
|
characterSet.remove(testChar);
|
||||||
|
if (characterSet.isEmpty) return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,15 +1,13 @@
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import '../data/models/image_model.dart';
|
|
||||||
|
|
||||||
/// Interface for implementing image-fetching strategies, specific to a resource location on the internet.
|
/// Interface for implementing image-fetching strategies, specific to a resource location on the internet.
|
||||||
///
|
///
|
||||||
/// Since I used a site that was more obscure than the ones in the examples, this (otherwise pointless
|
/// Since I used a site that was more obscure than the ones in the examples, this (otherwise pointless
|
||||||
/// and convoluting) interface is for adding a bit of flexibility to change strategy to some other site.
|
/// and convoluting) interface is for adding a bit of flexibility to change strategy to some other site.
|
||||||
abstract class ImagesApi {
|
abstract class ImagesApi {
|
||||||
FutureOr<Iterable<ImageModel>> fetchImageUri({required String token});
|
FutureOr<Iterable<Map<String, dynamic>>> fetchImageUri({required String token});
|
||||||
|
|
||||||
FutureOr<List<ImageModel>> searchImages({
|
FutureOr<Iterable<Map<String, dynamic>>> searchImages({
|
||||||
required String searchStr,
|
required String searchStr,
|
||||||
required String token,
|
required String token,
|
||||||
});
|
});
|
||||||
|
|
|
@ -14,14 +14,15 @@ class UnsplashImagesApi implements ImagesApi {
|
||||||
final random = Random();
|
final random = Random();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
FutureOr<Iterable<ImageModel>> fetchImageUri({required String token}) async {
|
FutureOr<Iterable<Map<String, dynamic>>> fetchImageUri({required String token}) async {
|
||||||
// Dummy fetching delay emulation
|
// Dummy fetching delay emulation
|
||||||
await Future.delayed(const Duration(
|
await Future.delayed(const Duration(
|
||||||
milliseconds: ConstValues.defaultEmulatedLatencyMillis * ConstValues.numberOfImages));
|
milliseconds: ConstValues.defaultEmulatedLatencyMillis * ConstValues.numberOfImages));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Create fixed number of images
|
// Create fixed number of images
|
||||||
return Iterable<int>.generate(ConstValues.numberOfImages).map((final imageIndex) {
|
final dummyImageModels =
|
||||||
|
Iterable<int>.generate(ConstValues.numberOfImages).map((final imageIndex) {
|
||||||
// Drawing from a normal distribution
|
// Drawing from a normal distribution
|
||||||
final imageSide =
|
final imageSide =
|
||||||
random.nextIntInRange(min: ConstValues.minImageSize, max: ConstValues.maxImageSize);
|
random.nextIntInRange(min: ConstValues.minImageSize, max: ConstValues.maxImageSize);
|
||||||
|
@ -36,6 +37,9 @@ class UnsplashImagesApi implements ImagesApi {
|
||||||
imageName: Strings.current.imageNameFetch(imageIndex + 1, imageSide),
|
imageName: Strings.current.imageNameFetch(imageIndex + 1, imageSide),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Emulating serialization
|
||||||
|
return dummyImageModels.map((final dummyModel) => dummyModel.toJson());
|
||||||
} on Exception catch (ex, stackTrace) {
|
} on Exception catch (ex, stackTrace) {
|
||||||
_loggingService.handleException(ex, stackTrace);
|
_loggingService.handleException(ex, stackTrace);
|
||||||
return const Iterable.empty();
|
return const Iterable.empty();
|
||||||
|
@ -43,7 +47,7 @@ class UnsplashImagesApi implements ImagesApi {
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
FutureOr<List<ImageModel>> searchImages({
|
FutureOr<Iterable<Map<String, dynamic>>> searchImages({
|
||||||
required String searchStr,
|
required String searchStr,
|
||||||
required String token,
|
required String token,
|
||||||
}) async {
|
}) async {
|
||||||
|
@ -55,7 +59,7 @@ class UnsplashImagesApi implements ImagesApi {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Create (randomly-bounded) dummy number of images
|
// Create (randomly-bounded) dummy number of images
|
||||||
return Iterable<int>.generate(numberOfResults).map((final imageIndex) {
|
final dummyImageModels = Iterable<int>.generate(numberOfResults).map((final imageIndex) {
|
||||||
// Drawing from a normal distribution
|
// Drawing from a normal distribution
|
||||||
final imageSide =
|
final imageSide =
|
||||||
random.nextIntInRange(min: ConstValues.minImageSize, max: ConstValues.maxImageSize);
|
random.nextIntInRange(min: ConstValues.minImageSize, max: ConstValues.maxImageSize);
|
||||||
|
@ -68,7 +72,10 @@ class UnsplashImagesApi implements ImagesApi {
|
||||||
// Custom dummy name for the image
|
// Custom dummy name for the image
|
||||||
imageName: Strings.current.imageNameSearch(searchStr, imageIndex + 1),
|
imageName: Strings.current.imageNameSearch(searchStr, imageIndex + 1),
|
||||||
);
|
);
|
||||||
}).toList(growable: false);
|
});
|
||||||
|
|
||||||
|
// Emulating serialization
|
||||||
|
return dummyImageModels.map((final dummyModel) => dummyModel.toJson());
|
||||||
} on Exception catch (ex, stackTrace) {
|
} on Exception catch (ex, stackTrace) {
|
||||||
_loggingService.handleException(ex, stackTrace);
|
_loggingService.handleException(ex, stackTrace);
|
||||||
return List.empty();
|
return List.empty();
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
import 'package:json_annotation/json_annotation.dart';
|
||||||
|
|
||||||
|
part 'image_model.g.dart';
|
||||||
|
|
||||||
|
@JsonSerializable()
|
||||||
class ImageModel {
|
class ImageModel {
|
||||||
const ImageModel({
|
const ImageModel({
|
||||||
required this.uri,
|
required this.uri,
|
||||||
|
@ -15,4 +20,9 @@ class ImageModel {
|
||||||
|
|
||||||
/// Given name of the image.
|
/// Given name of the image.
|
||||||
final String imageName;
|
final String imageName;
|
||||||
|
|
||||||
|
factory ImageModel.fromJson(Map<String, dynamic> json) => _$ImageModelFromJson(json);
|
||||||
|
|
||||||
|
/// Connect the generated [_$PersonToJson] function to the `toJson` method.
|
||||||
|
Map<String, dynamic> toJson() => _$ImageModelToJson(this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||||
|
|
||||||
|
part of 'image_model.dart';
|
||||||
|
|
||||||
|
// **************************************************************************
|
||||||
|
// JsonSerializableGenerator
|
||||||
|
// **************************************************************************
|
||||||
|
|
||||||
|
ImageModel _$ImageModelFromJson(Map<String, dynamic> json) => ImageModel(
|
||||||
|
uri: Uri.parse(json['uri'] as String),
|
||||||
|
imageIndex: json['imageIndex'] as int,
|
||||||
|
imageName: json['imageName'] as String,
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> _$ImageModelToJson(ImageModel instance) =>
|
||||||
|
<String, dynamic>{
|
||||||
|
'uri': instance.uri.toString(),
|
||||||
|
'imageIndex': instance.imageIndex,
|
||||||
|
'imageName': instance.imageName,
|
||||||
|
};
|
|
@ -1,12 +1,16 @@
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
|
import 'package:mc_gallery/features/core/data/extensions/string_extensions.dart';
|
||||||
|
|
||||||
|
import '/features/core/data/constants/const_sorters.dart';
|
||||||
import '/features/core/data/extensions/iterable_extensions.dart';
|
import '/features/core/data/extensions/iterable_extensions.dart';
|
||||||
|
import '/features/core/data/extensions/map_extensions.dart';
|
||||||
import '/features/core/services/logging_service.dart';
|
import '/features/core/services/logging_service.dart';
|
||||||
import '/features/core/utils/mutex.dart';
|
import '/features/core/utils/mutex.dart';
|
||||||
import '/features/home/data/models/image_model.dart';
|
|
||||||
import '/locator.dart';
|
import '/locator.dart';
|
||||||
import '../abstracts/images_api.dart';
|
import '../abstracts/images_api.dart';
|
||||||
import '../data/enums/search_option.dart';
|
import '../data/enums/search_option.dart';
|
||||||
|
import '../data/models/image_model.dart';
|
||||||
|
|
||||||
/// Handles fetching and storing of Images.
|
/// Handles fetching and storing of Images.
|
||||||
///
|
///
|
||||||
|
@ -24,8 +28,9 @@ class ImagesService {
|
||||||
final ImagesApi _imagesApi;
|
final ImagesApi _imagesApi;
|
||||||
final LoggingService _loggingService;
|
final LoggingService _loggingService;
|
||||||
|
|
||||||
late final Iterable<ImageModel> _imageModels;
|
late final Map<String, ImageModel> _imageModels;
|
||||||
Iterable<ImageModel> get imageModels => _imageModels.deepCopy;
|
Iterable<ImageModel> get imageModels => _imageModels.values.deepCopy;
|
||||||
|
|
||||||
final Mutex _searchMutex = Mutex();
|
final Mutex _searchMutex = Mutex();
|
||||||
|
|
||||||
/// Manual initialization triggering
|
/// Manual initialization triggering
|
||||||
|
@ -36,7 +41,11 @@ class ImagesService {
|
||||||
|
|
||||||
Future<void> _init() async {
|
Future<void> _init() async {
|
||||||
_loggingService.info('Fetching and creating image models...');
|
_loggingService.info('Fetching and creating image models...');
|
||||||
_imageModels = await _imagesApi.fetchImageUri(token: '');
|
_imageModels = {
|
||||||
|
for (final imageModel in (await _imagesApi.fetchImageUri(token: ''))
|
||||||
|
.map((final emulatedModelSerialized) => ImageModel.fromJson(emulatedModelSerialized)))
|
||||||
|
imageModel.imageName: imageModel
|
||||||
|
};
|
||||||
|
|
||||||
_imageModels.isNotEmpty
|
_imageModels.isNotEmpty
|
||||||
? _loggingService.good("Created ${_imageModels.length} images' models")
|
? _loggingService.good("Created ${_imageModels.length} images' models")
|
||||||
|
@ -49,24 +58,46 @@ class ImagesService {
|
||||||
int get lastAvailableImageIndex => _imageModels.length - 1;
|
int get lastAvailableImageIndex => _imageModels.length - 1;
|
||||||
int get numberOfImages => _imageModels.length;
|
int get numberOfImages => _imageModels.length;
|
||||||
|
|
||||||
ImageModel imageModelAt({required int index}) => _imageModels.elementAt(index);
|
ImageModel imageModelAt({required int index}) => _imageModels.values.elementAt(index);
|
||||||
|
|
||||||
Future<void> get lastQueryIsCompleted => _searchMutex.lastOperationCompletionAwaiter;
|
Future<void> get lastQueryIsCompleted => _searchMutex.lastOperationCompletionAwaiter;
|
||||||
|
|
||||||
|
/// Performs searching on images, both locally and by a Web API endpoint.
|
||||||
|
///
|
||||||
|
/// For now, a simple mechanism is used for handling async calls between (posssible) API fetches ->
|
||||||
|
/// just 'pile-up'. A mechanism can be made to 'cancel' a fetch if a newer search request comes in,
|
||||||
|
/// but that may be more complicated, and not the point of the assignment I think.
|
||||||
|
/// There are lots of optimizations possible for new inputs, for example reducing search frontier
|
||||||
|
/// by using set-cover/subsetting optimizations on backspace, and so on, but again, not the point,
|
||||||
|
/// I think.
|
||||||
Future<List<ImageModel>> searchImages({
|
Future<List<ImageModel>> searchImages({
|
||||||
required SearchOption searchOption,
|
required SearchOption searchOption,
|
||||||
required String imageNamePart,
|
required String imageNamePart,
|
||||||
|
bool treatAsInSequence = false,
|
||||||
}) async {
|
}) async {
|
||||||
return await _searchMutex.lockAndRun(run: (final unlock) async {
|
return await _searchMutex.lockAndRun(run: (final unlock) async {
|
||||||
try {
|
try {
|
||||||
switch (searchOption) {
|
switch (searchOption) {
|
||||||
case SearchOption.local:
|
case SearchOption.local:
|
||||||
return [];
|
final rankedKeys = _imageModels.keys
|
||||||
|
// Reduce number of results by atleast occurring
|
||||||
|
.where((final imageName) => treatAsInSequence
|
||||||
|
? imageName.contains(imageNamePart)
|
||||||
|
: imageName.containsAllCharacters(targetChars: imageNamePart))
|
||||||
|
.toList(growable: false)
|
||||||
|
// Sorting by the highest similarity first
|
||||||
|
..sort((final a, final b) =>
|
||||||
|
ConstSorters.stringsSimilarityTarget(targetWord: imageNamePart, a, b))
|
||||||
|
..reversed;
|
||||||
|
return _imageModels.valuesByKeys(keys: rankedKeys).toList(growable: false);
|
||||||
case SearchOption.web:
|
case SearchOption.web:
|
||||||
return await _imagesApi.searchImages(
|
return (await _imagesApi.searchImages(
|
||||||
searchStr: imageNamePart,
|
searchStr: imageNamePart,
|
||||||
token: '',
|
token: '',
|
||||||
);
|
))
|
||||||
|
.map(
|
||||||
|
(final emulatedModelSerialized) => ImageModel.fromJson(emulatedModelSerialized))
|
||||||
|
.toList(growable: false);
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
unlock();
|
unlock();
|
||||||
|
|
|
@ -7,12 +7,12 @@ import 'package:flutter_cache_manager/flutter_cache_manager.dart';
|
||||||
import '/features/core/abstracts/base_view_model.dart';
|
import '/features/core/abstracts/base_view_model.dart';
|
||||||
import '/features/core/services/logging_service.dart';
|
import '/features/core/services/logging_service.dart';
|
||||||
import '/features/core/services/navigation_service.dart';
|
import '/features/core/services/navigation_service.dart';
|
||||||
import '/features/home/data/models/image_model.dart';
|
|
||||||
import '/features/home/services/image_cache_manager_service.dart';
|
|
||||||
import '/features/home/services/images_service.dart';
|
|
||||||
import '/features/home/views/image_carousel/image_carousel_view.dart';
|
|
||||||
import '/locator.dart';
|
import '/locator.dart';
|
||||||
import '../../data/enums/search_option.dart';
|
import '../../data/enums/search_option.dart';
|
||||||
|
import '../../data/models/image_model.dart';
|
||||||
|
import '../../services/image_cache_manager_service.dart';
|
||||||
|
import '../../services/images_service.dart';
|
||||||
|
import '../image_carousel/image_carousel_view.dart';
|
||||||
|
|
||||||
class GalleryViewModel extends BaseViewModel {
|
class GalleryViewModel extends BaseViewModel {
|
||||||
GalleryViewModel({
|
GalleryViewModel({
|
||||||
|
@ -54,17 +54,20 @@ class GalleryViewModel extends BaseViewModel {
|
||||||
// If empty-string (from backspacing) -> reset state.
|
// If empty-string (from backspacing) -> reset state.
|
||||||
if (searchTerm.isEmpty) {
|
if (searchTerm.isEmpty) {
|
||||||
_imageSearchResultsNotifier.value = [];
|
_imageSearchResultsNotifier.value = [];
|
||||||
|
_loggingService.info('Clearing results on search string removal');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Detached call to prevent UI blocking
|
// Detached call to prevent UI blocking
|
||||||
unawaited(_imagesService
|
unawaited(
|
||||||
.searchImages(
|
_imagesService
|
||||||
imageNamePart: searchTerm,
|
.searchImages(
|
||||||
searchOption: searchOptionListenable.value,
|
imageNamePart: searchTerm,
|
||||||
)
|
searchOption: searchOptionListenable.value,
|
||||||
.then(
|
)
|
||||||
(final fetchedImageModels) => _imageSearchResultsNotifier.value = fetchedImageModels));
|
.then(
|
||||||
|
(final fetchedImageModels) => _imageSearchResultsNotifier.value = fetchedImageModels),
|
||||||
|
);
|
||||||
|
|
||||||
// Force-update to trigger listening to `lastQueryResultDone()`.
|
// Force-update to trigger listening to `lastQueryResultDone()`.
|
||||||
_imageSearchResultsNotifier.notifyListeners();
|
_imageSearchResultsNotifier.notifyListeners();
|
||||||
|
@ -72,14 +75,25 @@ class GalleryViewModel extends BaseViewModel {
|
||||||
|
|
||||||
void searchPressed() {
|
void searchPressed() {
|
||||||
// If transitioning from 'Searching', clear previous results immediately
|
// If transitioning from 'Searching', clear previous results immediately
|
||||||
if (_isSearchingNotifier.value) _imageSearchResultsNotifier.value = [];
|
if (_isSearchingNotifier.value) {
|
||||||
|
_imageSearchResultsNotifier.value = [];
|
||||||
|
_loggingService.info('Clearing of results on view mode change');
|
||||||
|
}
|
||||||
|
|
||||||
_isSearchingNotifier.value = !_isSearchingNotifier.value;
|
_isSearchingNotifier.value = !_isSearchingNotifier.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> get lastQueryResultDone => _imagesService.lastQueryIsCompleted;
|
Future<void> get lastQueryResultDone => _imagesService.lastQueryIsCompleted;
|
||||||
|
|
||||||
void onSearchOptionChanged(SearchOption? option) => _searchOptionNotifier.value = option!;
|
void onSearchOptionChanged(SearchOption? option) {
|
||||||
|
_searchOptionNotifier.value = option!;
|
||||||
|
_loggingService.info('Switched over to $option search');
|
||||||
|
|
||||||
|
_imageSearchResultsNotifier.value = [];
|
||||||
|
_loggingService.info('Cleared resultsw from view');
|
||||||
|
|
||||||
|
//todo(mehul): Either redo search or force user to type in by clearing field
|
||||||
|
}
|
||||||
|
|
||||||
void onPromptPressed() => _isDisplayingPressingPrompt.value = false;
|
void onPromptPressed() => _isDisplayingPressingPrompt.value = false;
|
||||||
|
|
||||||
|
|
|
@ -24,29 +24,56 @@ class _SearchGalleryView extends StatelessWidget {
|
||||||
displayedWidget = const CircularProgressIndicator();
|
displayedWidget = const CircularProgressIndicator();
|
||||||
break;
|
break;
|
||||||
case ConnectionState.done:
|
case ConnectionState.done:
|
||||||
displayedWidget = Wrap(
|
displayedWidget = ValueListenableBuilder<SearchOption>(
|
||||||
runSpacing: 24,
|
valueListenable: galleryViewModel.searchOptionListenable,
|
||||||
spacing: 8,
|
builder: (context, final searchOption, child) {
|
||||||
alignment: WrapAlignment.center,
|
switch (searchOption) {
|
||||||
runAlignment: WrapAlignment.center,
|
case SearchOption.local:
|
||||||
crossAxisAlignment: WrapCrossAlignment.center,
|
return Wrap(
|
||||||
children: [
|
runSpacing: 24,
|
||||||
for (final imageResult in resultsImageModels)
|
spacing: 8,
|
||||||
Image.network(
|
alignment: WrapAlignment.center,
|
||||||
imageResult.uri.toString(),
|
runAlignment: WrapAlignment.center,
|
||||||
loadingBuilder: (context, final child, final loadingProgress) =>
|
crossAxisAlignment: WrapCrossAlignment.center,
|
||||||
loadingProgress == null
|
children: [
|
||||||
? child
|
for (final resultsImageModel in resultsImageModels)
|
||||||
: Center(
|
CachedNetworkImage(
|
||||||
child: CircularProgressIndicator(
|
imageUrl: resultsImageModel.uri.toString(),
|
||||||
value: loadingProgress.expectedTotalBytes != null
|
cacheKey: resultsImageModel.imageIndex.toString(),
|
||||||
? loadingProgress.cumulativeBytesLoaded /
|
progressIndicatorBuilder: (_, __, final progress) =>
|
||||||
loadingProgress.expectedTotalBytes!
|
CircularProgressIndicator(
|
||||||
: null,
|
value: galleryViewModel.downloadProgressValue(progress: progress),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
);
|
||||||
|
case SearchOption.web:
|
||||||
|
return Wrap(
|
||||||
|
runSpacing: 24,
|
||||||
|
spacing: 8,
|
||||||
|
alignment: WrapAlignment.center,
|
||||||
|
runAlignment: WrapAlignment.center,
|
||||||
|
crossAxisAlignment: WrapCrossAlignment.center,
|
||||||
|
children: [
|
||||||
|
for (final imageResult in resultsImageModels)
|
||||||
|
Image.network(
|
||||||
|
imageResult.uri.toString(),
|
||||||
|
loadingBuilder: (context, final child, final loadingProgress) =>
|
||||||
|
loadingProgress == null
|
||||||
|
? child
|
||||||
|
: Center(
|
||||||
|
child: CircularProgressIndicator(
|
||||||
|
value: loadingProgress.expectedTotalBytes != null
|
||||||
|
? loadingProgress.cumulativeBytesLoaded /
|
||||||
|
loadingProgress.expectedTotalBytes!
|
||||||
|
: null,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
196
pubspec.lock
196
pubspec.lock
|
@ -57,6 +57,62 @@ packages:
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.0"
|
version: "2.1.0"
|
||||||
|
build:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: build
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "2.3.1"
|
||||||
|
build_config:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: build_config
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "1.1.1"
|
||||||
|
build_daemon:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: build_daemon
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "3.1.0"
|
||||||
|
build_resolvers:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: build_resolvers
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "2.1.0"
|
||||||
|
build_runner:
|
||||||
|
dependency: "direct dev"
|
||||||
|
description:
|
||||||
|
name: build_runner
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "2.3.3"
|
||||||
|
build_runner_core:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: build_runner_core
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "7.2.7"
|
||||||
|
built_collection:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: built_collection
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "5.1.1"
|
||||||
|
built_value:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: built_value
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "8.4.2"
|
||||||
cached_network_image:
|
cached_network_image:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
@ -92,6 +148,13 @@ packages:
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.2.1"
|
version: "1.2.1"
|
||||||
|
checked_yaml:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: checked_yaml
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "2.0.1"
|
||||||
clock:
|
clock:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -99,6 +162,13 @@ packages:
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.1.1"
|
version: "1.1.1"
|
||||||
|
code_builder:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: code_builder
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "4.4.0"
|
||||||
collection:
|
collection:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -183,6 +253,13 @@ packages:
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "6.1.4"
|
version: "6.1.4"
|
||||||
|
fixnum:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: fixnum
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "1.0.1"
|
||||||
flutter:
|
flutter:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description: flutter
|
description: flutter
|
||||||
|
@ -233,6 +310,13 @@ packages:
|
||||||
description: flutter
|
description: flutter
|
||||||
source: sdk
|
source: sdk
|
||||||
version: "0.0.0"
|
version: "0.0.0"
|
||||||
|
frontend_server_client:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: frontend_server_client
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "3.2.0"
|
||||||
get_it:
|
get_it:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
@ -254,6 +338,13 @@ packages:
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "6.0.0"
|
version: "6.0.0"
|
||||||
|
graphs:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: graphs
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "2.2.0"
|
||||||
http:
|
http:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -261,6 +352,13 @@ packages:
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.13.5"
|
version: "0.13.5"
|
||||||
|
http_multi_server:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: http_multi_server
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "3.2.1"
|
||||||
http_parser:
|
http_parser:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -289,6 +387,13 @@ packages:
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.8.1"
|
version: "2.8.1"
|
||||||
|
io:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: io
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "1.0.3"
|
||||||
js:
|
js:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -296,6 +401,20 @@ packages:
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.6.4"
|
version: "0.6.4"
|
||||||
|
json_annotation:
|
||||||
|
dependency: "direct dev"
|
||||||
|
description:
|
||||||
|
name: json_annotation
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "4.7.0"
|
||||||
|
json_serializable:
|
||||||
|
dependency: "direct dev"
|
||||||
|
description:
|
||||||
|
name: json_serializable
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "6.5.4"
|
||||||
lints:
|
lints:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -338,6 +457,13 @@ packages:
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.8.0"
|
version: "1.8.0"
|
||||||
|
mime:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: mime
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "1.0.3"
|
||||||
nested:
|
nested:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -471,6 +597,13 @@ packages:
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.6.2"
|
version: "3.6.2"
|
||||||
|
pool:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: pool
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "1.5.1"
|
||||||
process:
|
process:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -492,6 +625,13 @@ packages:
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.3"
|
version: "2.1.3"
|
||||||
|
pubspec_parse:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: pubspec_parse
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "1.2.1"
|
||||||
rxdart:
|
rxdart:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -499,11 +639,39 @@ packages:
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.27.7"
|
version: "0.27.7"
|
||||||
|
shelf:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: shelf
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "1.4.0"
|
||||||
|
shelf_web_socket:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: shelf_web_socket
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "1.0.3"
|
||||||
sky_engine:
|
sky_engine:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description: flutter
|
description: flutter
|
||||||
source: sdk
|
source: sdk
|
||||||
version: "0.0.99"
|
version: "0.0.99"
|
||||||
|
source_gen:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: source_gen
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "1.2.6"
|
||||||
|
source_helper:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: source_helper
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "1.3.3"
|
||||||
source_span:
|
source_span:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -539,6 +707,13 @@ packages:
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.0"
|
version: "2.1.0"
|
||||||
|
stream_transform:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: stream_transform
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "2.1.0"
|
||||||
string_scanner:
|
string_scanner:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -546,6 +721,13 @@ packages:
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.1.1"
|
version: "1.1.1"
|
||||||
|
string_similarity:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: string_similarity
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "2.0.0"
|
||||||
synchronized:
|
synchronized:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -588,6 +770,13 @@ packages:
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.4.12"
|
version: "0.4.12"
|
||||||
|
timing:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: timing
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "1.0.0"
|
||||||
typed_data:
|
typed_data:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -616,6 +805,13 @@ packages:
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.0.2"
|
version: "1.0.2"
|
||||||
|
web_socket_channel:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: web_socket_channel
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "2.2.0"
|
||||||
win32:
|
win32:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|
|
@ -29,6 +29,7 @@ dependencies:
|
||||||
intl_utils: ^2.8.1
|
intl_utils: ^2.8.1
|
||||||
connectivity_plus: ^3.0.2
|
connectivity_plus: ^3.0.2
|
||||||
internet_connection_checker: ^1.0.0+1
|
internet_connection_checker: ^1.0.0+1
|
||||||
|
string_similarity: ^2.0.0
|
||||||
|
|
||||||
# Util frontend
|
# Util frontend
|
||||||
flutter_markdown: ^0.6.13
|
flutter_markdown: ^0.6.13
|
||||||
|
@ -49,6 +50,11 @@ dev_dependencies:
|
||||||
|
|
||||||
flutter_lints: ^2.0.1
|
flutter_lints: ^2.0.1
|
||||||
|
|
||||||
|
# Builders
|
||||||
|
build_runner: ^2.3.3
|
||||||
|
json_annotation: ^4.7.0
|
||||||
|
json_serializable: ^6.5.4
|
||||||
|
|
||||||
flutter:
|
flutter:
|
||||||
uses-material-design: true
|
uses-material-design: true
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue