mirror of
https://github.com/flutter/samples.git
synced 2026-06-12 01:09:47 +00:00
Flutter 3.29 beta (#2571)
This commit is contained in:
@@ -29,7 +29,9 @@ abstract class Search implements Built<Search, SearchBuilder> {
|
||||
|
||||
static Search? fromJson(String jsonString) {
|
||||
return serializers.deserializeWith(
|
||||
Search.serializer, json.decode(jsonString));
|
||||
Search.serializer,
|
||||
json.decode(jsonString),
|
||||
);
|
||||
}
|
||||
|
||||
static Serializer<Search> get serializer => _$searchSerializer;
|
||||
|
||||
@@ -19,24 +19,33 @@ class _$SearchSerializer implements StructuredSerializer<Search> {
|
||||
final String wireName = 'Search';
|
||||
|
||||
@override
|
||||
Iterable<Object?> serialize(Serializers serializers, Search object,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
Iterable<Object?> serialize(
|
||||
Serializers serializers,
|
||||
Search object, {
|
||||
FullType specifiedType = FullType.unspecified,
|
||||
}) {
|
||||
final result = <Object?>[
|
||||
'query',
|
||||
serializers.serialize(object.query,
|
||||
specifiedType: const FullType(String)),
|
||||
serializers.serialize(
|
||||
object.query,
|
||||
specifiedType: const FullType(String),
|
||||
),
|
||||
'results',
|
||||
serializers.serialize(object.results,
|
||||
specifiedType:
|
||||
const FullType(BuiltList, const [const FullType(Photo)])),
|
||||
serializers.serialize(
|
||||
object.results,
|
||||
specifiedType: const FullType(BuiltList, const [const FullType(Photo)]),
|
||||
),
|
||||
];
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@override
|
||||
Search deserialize(Serializers serializers, Iterable<Object?> serialized,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
Search deserialize(
|
||||
Serializers serializers,
|
||||
Iterable<Object?> serialized, {
|
||||
FullType specifiedType = FullType.unspecified,
|
||||
}) {
|
||||
final result = new SearchBuilder();
|
||||
|
||||
final iterator = serialized.iterator;
|
||||
@@ -46,14 +55,23 @@ class _$SearchSerializer implements StructuredSerializer<Search> {
|
||||
final Object? value = iterator.current;
|
||||
switch (key) {
|
||||
case 'query':
|
||||
result.query = serializers.deserialize(value,
|
||||
specifiedType: const FullType(String))! as String;
|
||||
result.query =
|
||||
serializers.deserialize(
|
||||
value,
|
||||
specifiedType: const FullType(String),
|
||||
)!
|
||||
as String;
|
||||
break;
|
||||
case 'results':
|
||||
result.results.replace(serializers.deserialize(value,
|
||||
specifiedType:
|
||||
const FullType(BuiltList, const [const FullType(Photo)]))!
|
||||
as BuiltList<Object?>);
|
||||
result.results.replace(
|
||||
serializers.deserialize(
|
||||
value,
|
||||
specifiedType: const FullType(BuiltList, const [
|
||||
const FullType(Photo),
|
||||
]),
|
||||
)!
|
||||
as BuiltList<Object?>,
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -148,11 +166,16 @@ class SearchBuilder implements Builder<Search, SearchBuilder> {
|
||||
_$Search _build() {
|
||||
_$Search _$result;
|
||||
try {
|
||||
_$result = _$v ??
|
||||
_$result =
|
||||
_$v ??
|
||||
new _$Search._(
|
||||
query: BuiltValueNullFieldError.checkNotNull(
|
||||
query, r'Search', 'query'),
|
||||
results: results.build());
|
||||
query: BuiltValueNullFieldError.checkNotNull(
|
||||
query,
|
||||
r'Search',
|
||||
'query',
|
||||
),
|
||||
results: results.build(),
|
||||
);
|
||||
} catch (_) {
|
||||
late String _$failedField;
|
||||
try {
|
||||
@@ -160,7 +183,10 @@ class SearchBuilder implements Builder<Search, SearchBuilder> {
|
||||
results.build();
|
||||
} catch (e) {
|
||||
throw new BuiltValueNestedFieldError(
|
||||
r'Search', _$failedField, e.toString());
|
||||
r'Search',
|
||||
_$failedField,
|
||||
e.toString(),
|
||||
);
|
||||
}
|
||||
rethrow;
|
||||
}
|
||||
|
||||
@@ -10,35 +10,42 @@ part of 'serializers.dart';
|
||||
// BuiltValueGenerator
|
||||
// **************************************************************************
|
||||
|
||||
Serializers _$serializers = (new Serializers().toBuilder()
|
||||
..add(ApiError.serializer)
|
||||
..add(CurrentUserCollections.serializer)
|
||||
..add(Exif.serializer)
|
||||
..add(Links.serializer)
|
||||
..add(Location.serializer)
|
||||
..add(Photo.serializer)
|
||||
..add(Position.serializer)
|
||||
..add(Search.serializer)
|
||||
..add(SearchPhotosResponse.serializer)
|
||||
..add(Tags.serializer)
|
||||
..add(Urls.serializer)
|
||||
..add(User.serializer)
|
||||
..addBuilderFactory(
|
||||
const FullType(BuiltList, const [const FullType(Photo)]),
|
||||
() => new ListBuilder<Photo>())
|
||||
..addBuilderFactory(
|
||||
const FullType(BuiltList, const [const FullType(Photo)]),
|
||||
() => new ListBuilder<Photo>())
|
||||
..addBuilderFactory(
|
||||
const FullType(BuiltList, const [const FullType(String)]),
|
||||
() => new ListBuilder<String>())
|
||||
..addBuilderFactory(
|
||||
const FullType(BuiltList, const [const FullType(Tags)]),
|
||||
() => new ListBuilder<Tags>())
|
||||
..addBuilderFactory(
|
||||
const FullType(
|
||||
BuiltList, const [const FullType(CurrentUserCollections)]),
|
||||
() => new ListBuilder<CurrentUserCollections>()))
|
||||
.build();
|
||||
Serializers _$serializers =
|
||||
(new Serializers().toBuilder()
|
||||
..add(ApiError.serializer)
|
||||
..add(CurrentUserCollections.serializer)
|
||||
..add(Exif.serializer)
|
||||
..add(Links.serializer)
|
||||
..add(Location.serializer)
|
||||
..add(Photo.serializer)
|
||||
..add(Position.serializer)
|
||||
..add(Search.serializer)
|
||||
..add(SearchPhotosResponse.serializer)
|
||||
..add(Tags.serializer)
|
||||
..add(Urls.serializer)
|
||||
..add(User.serializer)
|
||||
..addBuilderFactory(
|
||||
const FullType(BuiltList, const [const FullType(Photo)]),
|
||||
() => new ListBuilder<Photo>(),
|
||||
)
|
||||
..addBuilderFactory(
|
||||
const FullType(BuiltList, const [const FullType(Photo)]),
|
||||
() => new ListBuilder<Photo>(),
|
||||
)
|
||||
..addBuilderFactory(
|
||||
const FullType(BuiltList, const [const FullType(String)]),
|
||||
() => new ListBuilder<String>(),
|
||||
)
|
||||
..addBuilderFactory(
|
||||
const FullType(BuiltList, const [const FullType(Tags)]),
|
||||
() => new ListBuilder<Tags>(),
|
||||
)
|
||||
..addBuilderFactory(
|
||||
const FullType(BuiltList, const [
|
||||
const FullType(CurrentUserCollections),
|
||||
]),
|
||||
() => new ListBuilder<CurrentUserCollections>(),
|
||||
))
|
||||
.build();
|
||||
|
||||
// ignore_for_file: deprecated_member_use_from_same_package,type=lint
|
||||
|
||||
@@ -26,7 +26,9 @@ abstract class ApiError implements Built<ApiError, ApiErrorBuilder> {
|
||||
|
||||
static ApiError? fromJson(String jsonString) {
|
||||
return serializers.deserializeWith(
|
||||
ApiError.serializer, json.decode(jsonString));
|
||||
ApiError.serializer,
|
||||
json.decode(jsonString),
|
||||
);
|
||||
}
|
||||
|
||||
static Serializer<ApiError> get serializer => _$apiErrorSerializer;
|
||||
|
||||
@@ -19,24 +19,35 @@ class _$ApiErrorSerializer implements StructuredSerializer<ApiError> {
|
||||
final String wireName = 'ApiError';
|
||||
|
||||
@override
|
||||
Iterable<Object?> serialize(Serializers serializers, ApiError object,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
Iterable<Object?> serialize(
|
||||
Serializers serializers,
|
||||
ApiError object, {
|
||||
FullType specifiedType = FullType.unspecified,
|
||||
}) {
|
||||
final result = <Object?>[];
|
||||
Object? value;
|
||||
value = object.errors;
|
||||
if (value != null) {
|
||||
result
|
||||
..add('errors')
|
||||
..add(serializers.serialize(value,
|
||||
specifiedType:
|
||||
const FullType(BuiltList, const [const FullType(String)])));
|
||||
..add(
|
||||
serializers.serialize(
|
||||
value,
|
||||
specifiedType: const FullType(BuiltList, const [
|
||||
const FullType(String),
|
||||
]),
|
||||
),
|
||||
);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@override
|
||||
ApiError deserialize(Serializers serializers, Iterable<Object?> serialized,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
ApiError deserialize(
|
||||
Serializers serializers,
|
||||
Iterable<Object?> serialized, {
|
||||
FullType specifiedType = FullType.unspecified,
|
||||
}) {
|
||||
final result = new ApiErrorBuilder();
|
||||
|
||||
final iterator = serialized.iterator;
|
||||
@@ -46,10 +57,15 @@ class _$ApiErrorSerializer implements StructuredSerializer<ApiError> {
|
||||
final Object? value = iterator.current;
|
||||
switch (key) {
|
||||
case 'errors':
|
||||
result.errors.replace(serializers.deserialize(value,
|
||||
specifiedType: const FullType(
|
||||
BuiltList, const [const FullType(String)]))!
|
||||
as BuiltList<Object?>);
|
||||
result.errors.replace(
|
||||
serializers.deserialize(
|
||||
value,
|
||||
specifiedType: const FullType(BuiltList, const [
|
||||
const FullType(String),
|
||||
]),
|
||||
)!
|
||||
as BuiltList<Object?>,
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -90,8 +106,8 @@ class _$ApiError extends ApiError {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return (newBuiltValueToStringHelper(r'ApiError')..add('errors', errors))
|
||||
.toString();
|
||||
return (newBuiltValueToStringHelper(r'ApiError')
|
||||
..add('errors', errors)).toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,7 +155,10 @@ class ApiErrorBuilder implements Builder<ApiError, ApiErrorBuilder> {
|
||||
_errors?.build();
|
||||
} catch (e) {
|
||||
throw new BuiltValueNestedFieldError(
|
||||
r'ApiError', _$failedField, e.toString());
|
||||
r'ApiError',
|
||||
_$failedField,
|
||||
e.toString(),
|
||||
);
|
||||
}
|
||||
rethrow;
|
||||
}
|
||||
|
||||
@@ -13,9 +13,9 @@ part 'current_user_collections.g.dart';
|
||||
|
||||
abstract class CurrentUserCollections
|
||||
implements Built<CurrentUserCollections, CurrentUserCollectionsBuilder> {
|
||||
factory CurrentUserCollections(
|
||||
[void Function(CurrentUserCollectionsBuilder)? updates]) =
|
||||
_$CurrentUserCollections;
|
||||
factory CurrentUserCollections([
|
||||
void Function(CurrentUserCollectionsBuilder)? updates,
|
||||
]) = _$CurrentUserCollections;
|
||||
|
||||
CurrentUserCollections._();
|
||||
|
||||
@@ -33,12 +33,15 @@ abstract class CurrentUserCollections
|
||||
|
||||
String toJson() {
|
||||
return json.encode(
|
||||
serializers.serializeWith(CurrentUserCollections.serializer, this));
|
||||
serializers.serializeWith(CurrentUserCollections.serializer, this),
|
||||
);
|
||||
}
|
||||
|
||||
static CurrentUserCollections? fromJson(String jsonString) {
|
||||
return serializers.deserializeWith(
|
||||
CurrentUserCollections.serializer, json.decode(jsonString));
|
||||
CurrentUserCollections.serializer,
|
||||
json.decode(jsonString),
|
||||
);
|
||||
}
|
||||
|
||||
static Serializer<CurrentUserCollections> get serializer =>
|
||||
|
||||
@@ -18,15 +18,17 @@ class _$CurrentUserCollectionsSerializer
|
||||
@override
|
||||
final Iterable<Type> types = const [
|
||||
CurrentUserCollections,
|
||||
_$CurrentUserCollections
|
||||
_$CurrentUserCollections,
|
||||
];
|
||||
@override
|
||||
final String wireName = 'CurrentUserCollections';
|
||||
|
||||
@override
|
||||
Iterable<Object?> serialize(
|
||||
Serializers serializers, CurrentUserCollections object,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
Serializers serializers,
|
||||
CurrentUserCollections object, {
|
||||
FullType specifiedType = FullType.unspecified,
|
||||
}) {
|
||||
final result = <Object?>[
|
||||
'id',
|
||||
serializers.serialize(object.id, specifiedType: const FullType(int)),
|
||||
@@ -36,30 +38,35 @@ class _$CurrentUserCollectionsSerializer
|
||||
if (value != null) {
|
||||
result
|
||||
..add('title')
|
||||
..add(serializers.serialize(value,
|
||||
specifiedType: const FullType(String)));
|
||||
..add(
|
||||
serializers.serialize(value, specifiedType: const FullType(String)),
|
||||
);
|
||||
}
|
||||
value = object.publishedAt;
|
||||
if (value != null) {
|
||||
result
|
||||
..add('published_at')
|
||||
..add(serializers.serialize(value,
|
||||
specifiedType: const FullType(String)));
|
||||
..add(
|
||||
serializers.serialize(value, specifiedType: const FullType(String)),
|
||||
);
|
||||
}
|
||||
value = object.updatedAt;
|
||||
if (value != null) {
|
||||
result
|
||||
..add('updated_at')
|
||||
..add(serializers.serialize(value,
|
||||
specifiedType: const FullType(String)));
|
||||
..add(
|
||||
serializers.serialize(value, specifiedType: const FullType(String)),
|
||||
);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@override
|
||||
CurrentUserCollections deserialize(
|
||||
Serializers serializers, Iterable<Object?> serialized,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
Serializers serializers,
|
||||
Iterable<Object?> serialized, {
|
||||
FullType specifiedType = FullType.unspecified,
|
||||
}) {
|
||||
final result = new CurrentUserCollectionsBuilder();
|
||||
|
||||
final iterator = serialized.iterator;
|
||||
@@ -69,20 +76,36 @@ class _$CurrentUserCollectionsSerializer
|
||||
final Object? value = iterator.current;
|
||||
switch (key) {
|
||||
case 'id':
|
||||
result.id = serializers.deserialize(value,
|
||||
specifiedType: const FullType(int))! as int;
|
||||
result.id =
|
||||
serializers.deserialize(
|
||||
value,
|
||||
specifiedType: const FullType(int),
|
||||
)!
|
||||
as int;
|
||||
break;
|
||||
case 'title':
|
||||
result.title = serializers.deserialize(value,
|
||||
specifiedType: const FullType(String)) as String?;
|
||||
result.title =
|
||||
serializers.deserialize(
|
||||
value,
|
||||
specifiedType: const FullType(String),
|
||||
)
|
||||
as String?;
|
||||
break;
|
||||
case 'published_at':
|
||||
result.publishedAt = serializers.deserialize(value,
|
||||
specifiedType: const FullType(String)) as String?;
|
||||
result.publishedAt =
|
||||
serializers.deserialize(
|
||||
value,
|
||||
specifiedType: const FullType(String),
|
||||
)
|
||||
as String?;
|
||||
break;
|
||||
case 'updated_at':
|
||||
result.updatedAt = serializers.deserialize(value,
|
||||
specifiedType: const FullType(String)) as String?;
|
||||
result.updatedAt =
|
||||
serializers.deserialize(
|
||||
value,
|
||||
specifiedType: const FullType(String),
|
||||
)
|
||||
as String?;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -101,20 +124,23 @@ class _$CurrentUserCollections extends CurrentUserCollections {
|
||||
@override
|
||||
final String? updatedAt;
|
||||
|
||||
factory _$CurrentUserCollections(
|
||||
[void Function(CurrentUserCollectionsBuilder)? updates]) =>
|
||||
(new CurrentUserCollectionsBuilder()..update(updates))._build();
|
||||
factory _$CurrentUserCollections([
|
||||
void Function(CurrentUserCollectionsBuilder)? updates,
|
||||
]) => (new CurrentUserCollectionsBuilder()..update(updates))._build();
|
||||
|
||||
_$CurrentUserCollections._(
|
||||
{required this.id, this.title, this.publishedAt, this.updatedAt})
|
||||
: super._() {
|
||||
_$CurrentUserCollections._({
|
||||
required this.id,
|
||||
this.title,
|
||||
this.publishedAt,
|
||||
this.updatedAt,
|
||||
}) : super._() {
|
||||
BuiltValueNullFieldError.checkNotNull(id, r'CurrentUserCollections', 'id');
|
||||
}
|
||||
|
||||
@override
|
||||
CurrentUserCollections rebuild(
|
||||
void Function(CurrentUserCollectionsBuilder) updates) =>
|
||||
(toBuilder()..update(updates)).build();
|
||||
void Function(CurrentUserCollectionsBuilder) updates,
|
||||
) => (toBuilder()..update(updates)).build();
|
||||
|
||||
@override
|
||||
CurrentUserCollectionsBuilder toBuilder() =>
|
||||
@@ -201,13 +227,18 @@ class CurrentUserCollectionsBuilder
|
||||
CurrentUserCollections build() => _build();
|
||||
|
||||
_$CurrentUserCollections _build() {
|
||||
final _$result = _$v ??
|
||||
final _$result =
|
||||
_$v ??
|
||||
new _$CurrentUserCollections._(
|
||||
id: BuiltValueNullFieldError.checkNotNull(
|
||||
id, r'CurrentUserCollections', 'id'),
|
||||
title: title,
|
||||
publishedAt: publishedAt,
|
||||
updatedAt: updatedAt);
|
||||
id: BuiltValueNullFieldError.checkNotNull(
|
||||
id,
|
||||
r'CurrentUserCollections',
|
||||
'id',
|
||||
),
|
||||
title: title,
|
||||
publishedAt: publishedAt,
|
||||
updatedAt: updatedAt,
|
||||
);
|
||||
replace(_$result);
|
||||
return _$result;
|
||||
}
|
||||
|
||||
@@ -40,7 +40,9 @@ abstract class Exif implements Built<Exif, ExifBuilder> {
|
||||
|
||||
static Exif? fromJson(String jsonString) {
|
||||
return serializers.deserializeWith(
|
||||
Exif.serializer, json.decode(jsonString));
|
||||
Exif.serializer,
|
||||
json.decode(jsonString),
|
||||
);
|
||||
}
|
||||
|
||||
static Serializer<Exif> get serializer => _$exifSerializer;
|
||||
|
||||
@@ -19,44 +19,52 @@ class _$ExifSerializer implements StructuredSerializer<Exif> {
|
||||
final String wireName = 'Exif';
|
||||
|
||||
@override
|
||||
Iterable<Object?> serialize(Serializers serializers, Exif object,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
Iterable<Object?> serialize(
|
||||
Serializers serializers,
|
||||
Exif object, {
|
||||
FullType specifiedType = FullType.unspecified,
|
||||
}) {
|
||||
final result = <Object?>[];
|
||||
Object? value;
|
||||
value = object.make;
|
||||
if (value != null) {
|
||||
result
|
||||
..add('make')
|
||||
..add(serializers.serialize(value,
|
||||
specifiedType: const FullType(String)));
|
||||
..add(
|
||||
serializers.serialize(value, specifiedType: const FullType(String)),
|
||||
);
|
||||
}
|
||||
value = object.model;
|
||||
if (value != null) {
|
||||
result
|
||||
..add('model')
|
||||
..add(serializers.serialize(value,
|
||||
specifiedType: const FullType(String)));
|
||||
..add(
|
||||
serializers.serialize(value, specifiedType: const FullType(String)),
|
||||
);
|
||||
}
|
||||
value = object.exposureTime;
|
||||
if (value != null) {
|
||||
result
|
||||
..add('exposure_time')
|
||||
..add(serializers.serialize(value,
|
||||
specifiedType: const FullType(String)));
|
||||
..add(
|
||||
serializers.serialize(value, specifiedType: const FullType(String)),
|
||||
);
|
||||
}
|
||||
value = object.aperture;
|
||||
if (value != null) {
|
||||
result
|
||||
..add('aperture')
|
||||
..add(serializers.serialize(value,
|
||||
specifiedType: const FullType(String)));
|
||||
..add(
|
||||
serializers.serialize(value, specifiedType: const FullType(String)),
|
||||
);
|
||||
}
|
||||
value = object.focalLength;
|
||||
if (value != null) {
|
||||
result
|
||||
..add('focal_length')
|
||||
..add(serializers.serialize(value,
|
||||
specifiedType: const FullType(String)));
|
||||
..add(
|
||||
serializers.serialize(value, specifiedType: const FullType(String)),
|
||||
);
|
||||
}
|
||||
value = object.iso;
|
||||
if (value != null) {
|
||||
@@ -68,8 +76,11 @@ class _$ExifSerializer implements StructuredSerializer<Exif> {
|
||||
}
|
||||
|
||||
@override
|
||||
Exif deserialize(Serializers serializers, Iterable<Object?> serialized,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
Exif deserialize(
|
||||
Serializers serializers,
|
||||
Iterable<Object?> serialized, {
|
||||
FullType specifiedType = FullType.unspecified,
|
||||
}) {
|
||||
final result = new ExifBuilder();
|
||||
|
||||
final iterator = serialized.iterator;
|
||||
@@ -79,28 +90,49 @@ class _$ExifSerializer implements StructuredSerializer<Exif> {
|
||||
final Object? value = iterator.current;
|
||||
switch (key) {
|
||||
case 'make':
|
||||
result.make = serializers.deserialize(value,
|
||||
specifiedType: const FullType(String)) as String?;
|
||||
result.make =
|
||||
serializers.deserialize(
|
||||
value,
|
||||
specifiedType: const FullType(String),
|
||||
)
|
||||
as String?;
|
||||
break;
|
||||
case 'model':
|
||||
result.model = serializers.deserialize(value,
|
||||
specifiedType: const FullType(String)) as String?;
|
||||
result.model =
|
||||
serializers.deserialize(
|
||||
value,
|
||||
specifiedType: const FullType(String),
|
||||
)
|
||||
as String?;
|
||||
break;
|
||||
case 'exposure_time':
|
||||
result.exposureTime = serializers.deserialize(value,
|
||||
specifiedType: const FullType(String)) as String?;
|
||||
result.exposureTime =
|
||||
serializers.deserialize(
|
||||
value,
|
||||
specifiedType: const FullType(String),
|
||||
)
|
||||
as String?;
|
||||
break;
|
||||
case 'aperture':
|
||||
result.aperture = serializers.deserialize(value,
|
||||
specifiedType: const FullType(String)) as String?;
|
||||
result.aperture =
|
||||
serializers.deserialize(
|
||||
value,
|
||||
specifiedType: const FullType(String),
|
||||
)
|
||||
as String?;
|
||||
break;
|
||||
case 'focal_length':
|
||||
result.focalLength = serializers.deserialize(value,
|
||||
specifiedType: const FullType(String)) as String?;
|
||||
result.focalLength =
|
||||
serializers.deserialize(
|
||||
value,
|
||||
specifiedType: const FullType(String),
|
||||
)
|
||||
as String?;
|
||||
break;
|
||||
case 'iso':
|
||||
result.iso = serializers.deserialize(value,
|
||||
specifiedType: const FullType(int)) as int?;
|
||||
result.iso =
|
||||
serializers.deserialize(value, specifiedType: const FullType(int))
|
||||
as int?;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -126,14 +158,14 @@ class _$Exif extends Exif {
|
||||
factory _$Exif([void Function(ExifBuilder)? updates]) =>
|
||||
(new ExifBuilder()..update(updates))._build();
|
||||
|
||||
_$Exif._(
|
||||
{this.make,
|
||||
this.model,
|
||||
this.exposureTime,
|
||||
this.aperture,
|
||||
this.focalLength,
|
||||
this.iso})
|
||||
: super._();
|
||||
_$Exif._({
|
||||
this.make,
|
||||
this.model,
|
||||
this.exposureTime,
|
||||
this.aperture,
|
||||
this.focalLength,
|
||||
this.iso,
|
||||
}) : super._();
|
||||
|
||||
@override
|
||||
Exif rebuild(void Function(ExifBuilder) updates) =>
|
||||
@@ -238,14 +270,16 @@ class ExifBuilder implements Builder<Exif, ExifBuilder> {
|
||||
Exif build() => _build();
|
||||
|
||||
_$Exif _build() {
|
||||
final _$result = _$v ??
|
||||
final _$result =
|
||||
_$v ??
|
||||
new _$Exif._(
|
||||
make: make,
|
||||
model: model,
|
||||
exposureTime: exposureTime,
|
||||
aperture: aperture,
|
||||
focalLength: focalLength,
|
||||
iso: iso);
|
||||
make: make,
|
||||
model: model,
|
||||
exposureTime: exposureTime,
|
||||
aperture: aperture,
|
||||
focalLength: focalLength,
|
||||
iso: iso,
|
||||
);
|
||||
replace(_$result);
|
||||
return _$result;
|
||||
}
|
||||
|
||||
@@ -34,7 +34,9 @@ abstract class Links implements Built<Links, LinksBuilder> {
|
||||
|
||||
static Links? fromJson(String jsonString) {
|
||||
return serializers.deserializeWith(
|
||||
Links.serializer, json.decode(jsonString));
|
||||
Links.serializer,
|
||||
json.decode(jsonString),
|
||||
);
|
||||
}
|
||||
|
||||
static Serializer<Links> get serializer => _$linksSerializer;
|
||||
|
||||
@@ -19,44 +19,54 @@ class _$LinksSerializer implements StructuredSerializer<Links> {
|
||||
final String wireName = 'Links';
|
||||
|
||||
@override
|
||||
Iterable<Object?> serialize(Serializers serializers, Links object,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
Iterable<Object?> serialize(
|
||||
Serializers serializers,
|
||||
Links object, {
|
||||
FullType specifiedType = FullType.unspecified,
|
||||
}) {
|
||||
final result = <Object?>[];
|
||||
Object? value;
|
||||
value = object.self;
|
||||
if (value != null) {
|
||||
result
|
||||
..add('self')
|
||||
..add(serializers.serialize(value,
|
||||
specifiedType: const FullType(String)));
|
||||
..add(
|
||||
serializers.serialize(value, specifiedType: const FullType(String)),
|
||||
);
|
||||
}
|
||||
value = object.html;
|
||||
if (value != null) {
|
||||
result
|
||||
..add('html')
|
||||
..add(serializers.serialize(value,
|
||||
specifiedType: const FullType(String)));
|
||||
..add(
|
||||
serializers.serialize(value, specifiedType: const FullType(String)),
|
||||
);
|
||||
}
|
||||
value = object.download;
|
||||
if (value != null) {
|
||||
result
|
||||
..add('download')
|
||||
..add(serializers.serialize(value,
|
||||
specifiedType: const FullType(String)));
|
||||
..add(
|
||||
serializers.serialize(value, specifiedType: const FullType(String)),
|
||||
);
|
||||
}
|
||||
value = object.downloadLocation;
|
||||
if (value != null) {
|
||||
result
|
||||
..add('download_location')
|
||||
..add(serializers.serialize(value,
|
||||
specifiedType: const FullType(String)));
|
||||
..add(
|
||||
serializers.serialize(value, specifiedType: const FullType(String)),
|
||||
);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@override
|
||||
Links deserialize(Serializers serializers, Iterable<Object?> serialized,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
Links deserialize(
|
||||
Serializers serializers,
|
||||
Iterable<Object?> serialized, {
|
||||
FullType specifiedType = FullType.unspecified,
|
||||
}) {
|
||||
final result = new LinksBuilder();
|
||||
|
||||
final iterator = serialized.iterator;
|
||||
@@ -66,20 +76,36 @@ class _$LinksSerializer implements StructuredSerializer<Links> {
|
||||
final Object? value = iterator.current;
|
||||
switch (key) {
|
||||
case 'self':
|
||||
result.self = serializers.deserialize(value,
|
||||
specifiedType: const FullType(String)) as String?;
|
||||
result.self =
|
||||
serializers.deserialize(
|
||||
value,
|
||||
specifiedType: const FullType(String),
|
||||
)
|
||||
as String?;
|
||||
break;
|
||||
case 'html':
|
||||
result.html = serializers.deserialize(value,
|
||||
specifiedType: const FullType(String)) as String?;
|
||||
result.html =
|
||||
serializers.deserialize(
|
||||
value,
|
||||
specifiedType: const FullType(String),
|
||||
)
|
||||
as String?;
|
||||
break;
|
||||
case 'download':
|
||||
result.download = serializers.deserialize(value,
|
||||
specifiedType: const FullType(String)) as String?;
|
||||
result.download =
|
||||
serializers.deserialize(
|
||||
value,
|
||||
specifiedType: const FullType(String),
|
||||
)
|
||||
as String?;
|
||||
break;
|
||||
case 'download_location':
|
||||
result.downloadLocation = serializers.deserialize(value,
|
||||
specifiedType: const FullType(String)) as String?;
|
||||
result.downloadLocation =
|
||||
serializers.deserialize(
|
||||
value,
|
||||
specifiedType: const FullType(String),
|
||||
)
|
||||
as String?;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -102,7 +128,7 @@ class _$Links extends Links {
|
||||
(new LinksBuilder()..update(updates))._build();
|
||||
|
||||
_$Links._({this.self, this.html, this.download, this.downloadLocation})
|
||||
: super._();
|
||||
: super._();
|
||||
|
||||
@override
|
||||
Links rebuild(void Function(LinksBuilder) updates) =>
|
||||
@@ -192,12 +218,14 @@ class LinksBuilder implements Builder<Links, LinksBuilder> {
|
||||
Links build() => _build();
|
||||
|
||||
_$Links _build() {
|
||||
final _$result = _$v ??
|
||||
final _$result =
|
||||
_$v ??
|
||||
new _$Links._(
|
||||
self: self,
|
||||
html: html,
|
||||
download: download,
|
||||
downloadLocation: downloadLocation);
|
||||
self: self,
|
||||
html: html,
|
||||
download: download,
|
||||
downloadLocation: downloadLocation,
|
||||
);
|
||||
replace(_$result);
|
||||
return _$result;
|
||||
}
|
||||
|
||||
@@ -32,7 +32,9 @@ abstract class Location implements Built<Location, LocationBuilder> {
|
||||
|
||||
static Location? fromJson(String jsonString) {
|
||||
return serializers.deserializeWith(
|
||||
Location.serializer, json.decode(jsonString));
|
||||
Location.serializer,
|
||||
json.decode(jsonString),
|
||||
);
|
||||
}
|
||||
|
||||
static Serializer<Location> get serializer => _$locationSerializer;
|
||||
|
||||
@@ -19,37 +19,46 @@ class _$LocationSerializer implements StructuredSerializer<Location> {
|
||||
final String wireName = 'Location';
|
||||
|
||||
@override
|
||||
Iterable<Object?> serialize(Serializers serializers, Location object,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
Iterable<Object?> serialize(
|
||||
Serializers serializers,
|
||||
Location object, {
|
||||
FullType specifiedType = FullType.unspecified,
|
||||
}) {
|
||||
final result = <Object?>[];
|
||||
Object? value;
|
||||
value = object.city;
|
||||
if (value != null) {
|
||||
result
|
||||
..add('city')
|
||||
..add(serializers.serialize(value,
|
||||
specifiedType: const FullType(String)));
|
||||
..add(
|
||||
serializers.serialize(value, specifiedType: const FullType(String)),
|
||||
);
|
||||
}
|
||||
value = object.country;
|
||||
if (value != null) {
|
||||
result
|
||||
..add('country')
|
||||
..add(serializers.serialize(value,
|
||||
specifiedType: const FullType(String)));
|
||||
..add(
|
||||
serializers.serialize(value, specifiedType: const FullType(String)),
|
||||
);
|
||||
}
|
||||
value = object.position;
|
||||
if (value != null) {
|
||||
result
|
||||
..add('position')
|
||||
..add(serializers.serialize(value,
|
||||
specifiedType: const FullType(Position)));
|
||||
..add(
|
||||
serializers.serialize(value, specifiedType: const FullType(Position)),
|
||||
);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@override
|
||||
Location deserialize(Serializers serializers, Iterable<Object?> serialized,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
Location deserialize(
|
||||
Serializers serializers,
|
||||
Iterable<Object?> serialized, {
|
||||
FullType specifiedType = FullType.unspecified,
|
||||
}) {
|
||||
final result = new LocationBuilder();
|
||||
|
||||
final iterator = serialized.iterator;
|
||||
@@ -59,16 +68,29 @@ class _$LocationSerializer implements StructuredSerializer<Location> {
|
||||
final Object? value = iterator.current;
|
||||
switch (key) {
|
||||
case 'city':
|
||||
result.city = serializers.deserialize(value,
|
||||
specifiedType: const FullType(String)) as String?;
|
||||
result.city =
|
||||
serializers.deserialize(
|
||||
value,
|
||||
specifiedType: const FullType(String),
|
||||
)
|
||||
as String?;
|
||||
break;
|
||||
case 'country':
|
||||
result.country = serializers.deserialize(value,
|
||||
specifiedType: const FullType(String)) as String?;
|
||||
result.country =
|
||||
serializers.deserialize(
|
||||
value,
|
||||
specifiedType: const FullType(String),
|
||||
)
|
||||
as String?;
|
||||
break;
|
||||
case 'position':
|
||||
result.position.replace(serializers.deserialize(value,
|
||||
specifiedType: const FullType(Position))! as Position);
|
||||
result.position.replace(
|
||||
serializers.deserialize(
|
||||
value,
|
||||
specifiedType: const FullType(Position),
|
||||
)!
|
||||
as Position,
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -171,9 +193,13 @@ class LocationBuilder implements Builder<Location, LocationBuilder> {
|
||||
_$Location _build() {
|
||||
_$Location _$result;
|
||||
try {
|
||||
_$result = _$v ??
|
||||
_$result =
|
||||
_$v ??
|
||||
new _$Location._(
|
||||
city: city, country: country, position: _position?.build());
|
||||
city: city,
|
||||
country: country,
|
||||
position: _position?.build(),
|
||||
);
|
||||
} catch (_) {
|
||||
late String _$failedField;
|
||||
try {
|
||||
@@ -181,7 +207,10 @@ class LocationBuilder implements Builder<Location, LocationBuilder> {
|
||||
_position?.build();
|
||||
} catch (e) {
|
||||
throw new BuiltValueNestedFieldError(
|
||||
r'Location', _$failedField, e.toString());
|
||||
r'Location',
|
||||
_$failedField,
|
||||
e.toString(),
|
||||
);
|
||||
}
|
||||
rethrow;
|
||||
}
|
||||
|
||||
@@ -81,7 +81,9 @@ abstract class Photo implements Built<Photo, PhotoBuilder> {
|
||||
|
||||
static Photo? fromJson(String jsonString) {
|
||||
return serializers.deserializeWith(
|
||||
Photo.serializer, json.decode(jsonString));
|
||||
Photo.serializer,
|
||||
json.decode(jsonString),
|
||||
);
|
||||
}
|
||||
|
||||
static Serializer<Photo> get serializer => _$photoSerializer;
|
||||
|
||||
@@ -19,8 +19,11 @@ class _$PhotoSerializer implements StructuredSerializer<Photo> {
|
||||
final String wireName = 'Photo';
|
||||
|
||||
@override
|
||||
Iterable<Object?> serialize(Serializers serializers, Photo object,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
Iterable<Object?> serialize(
|
||||
Serializers serializers,
|
||||
Photo object, {
|
||||
FullType specifiedType = FullType.unspecified,
|
||||
}) {
|
||||
final result = <Object?>[
|
||||
'id',
|
||||
serializers.serialize(object.id, specifiedType: const FullType(String)),
|
||||
@@ -30,15 +33,17 @@ class _$PhotoSerializer implements StructuredSerializer<Photo> {
|
||||
if (value != null) {
|
||||
result
|
||||
..add('created_at')
|
||||
..add(serializers.serialize(value,
|
||||
specifiedType: const FullType(String)));
|
||||
..add(
|
||||
serializers.serialize(value, specifiedType: const FullType(String)),
|
||||
);
|
||||
}
|
||||
value = object.updatedAt;
|
||||
if (value != null) {
|
||||
result
|
||||
..add('updated_at')
|
||||
..add(serializers.serialize(value,
|
||||
specifiedType: const FullType(String)));
|
||||
..add(
|
||||
serializers.serialize(value, specifiedType: const FullType(String)),
|
||||
);
|
||||
}
|
||||
value = object.width;
|
||||
if (value != null) {
|
||||
@@ -56,8 +61,9 @@ class _$PhotoSerializer implements StructuredSerializer<Photo> {
|
||||
if (value != null) {
|
||||
result
|
||||
..add('color')
|
||||
..add(serializers.serialize(value,
|
||||
specifiedType: const FullType(String)));
|
||||
..add(
|
||||
serializers.serialize(value, specifiedType: const FullType(String)),
|
||||
);
|
||||
}
|
||||
value = object.downloads;
|
||||
if (value != null) {
|
||||
@@ -76,72 +82,92 @@ class _$PhotoSerializer implements StructuredSerializer<Photo> {
|
||||
result
|
||||
..add('liked_by_user')
|
||||
..add(
|
||||
serializers.serialize(value, specifiedType: const FullType(bool)));
|
||||
serializers.serialize(value, specifiedType: const FullType(bool)),
|
||||
);
|
||||
}
|
||||
value = object.description;
|
||||
if (value != null) {
|
||||
result
|
||||
..add('description')
|
||||
..add(serializers.serialize(value,
|
||||
specifiedType: const FullType(String)));
|
||||
..add(
|
||||
serializers.serialize(value, specifiedType: const FullType(String)),
|
||||
);
|
||||
}
|
||||
value = object.exif;
|
||||
if (value != null) {
|
||||
result
|
||||
..add('exif')
|
||||
..add(
|
||||
serializers.serialize(value, specifiedType: const FullType(Exif)));
|
||||
serializers.serialize(value, specifiedType: const FullType(Exif)),
|
||||
);
|
||||
}
|
||||
value = object.location;
|
||||
if (value != null) {
|
||||
result
|
||||
..add('location')
|
||||
..add(serializers.serialize(value,
|
||||
specifiedType: const FullType(Location)));
|
||||
..add(
|
||||
serializers.serialize(value, specifiedType: const FullType(Location)),
|
||||
);
|
||||
}
|
||||
value = object.tags;
|
||||
if (value != null) {
|
||||
result
|
||||
..add('tags')
|
||||
..add(serializers.serialize(value,
|
||||
specifiedType:
|
||||
const FullType(BuiltList, const [const FullType(Tags)])));
|
||||
..add(
|
||||
serializers.serialize(
|
||||
value,
|
||||
specifiedType: const FullType(BuiltList, const [
|
||||
const FullType(Tags),
|
||||
]),
|
||||
),
|
||||
);
|
||||
}
|
||||
value = object.currentUserCollections;
|
||||
if (value != null) {
|
||||
result
|
||||
..add('current_user_collections')
|
||||
..add(serializers.serialize(value,
|
||||
specifiedType: const FullType(
|
||||
BuiltList, const [const FullType(CurrentUserCollections)])));
|
||||
..add(
|
||||
serializers.serialize(
|
||||
value,
|
||||
specifiedType: const FullType(BuiltList, const [
|
||||
const FullType(CurrentUserCollections),
|
||||
]),
|
||||
),
|
||||
);
|
||||
}
|
||||
value = object.urls;
|
||||
if (value != null) {
|
||||
result
|
||||
..add('urls')
|
||||
..add(
|
||||
serializers.serialize(value, specifiedType: const FullType(Urls)));
|
||||
serializers.serialize(value, specifiedType: const FullType(Urls)),
|
||||
);
|
||||
}
|
||||
value = object.links;
|
||||
if (value != null) {
|
||||
result
|
||||
..add('links')
|
||||
..add(
|
||||
serializers.serialize(value, specifiedType: const FullType(Links)));
|
||||
serializers.serialize(value, specifiedType: const FullType(Links)),
|
||||
);
|
||||
}
|
||||
value = object.user;
|
||||
if (value != null) {
|
||||
result
|
||||
..add('user')
|
||||
..add(
|
||||
serializers.serialize(value, specifiedType: const FullType(User)));
|
||||
serializers.serialize(value, specifiedType: const FullType(User)),
|
||||
);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@override
|
||||
Photo deserialize(Serializers serializers, Iterable<Object?> serialized,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
Photo deserialize(
|
||||
Serializers serializers,
|
||||
Iterable<Object?> serialized, {
|
||||
FullType specifiedType = FullType.unspecified,
|
||||
}) {
|
||||
final result = new PhotoBuilder();
|
||||
|
||||
final iterator = serialized.iterator;
|
||||
@@ -151,76 +177,130 @@ class _$PhotoSerializer implements StructuredSerializer<Photo> {
|
||||
final Object? value = iterator.current;
|
||||
switch (key) {
|
||||
case 'id':
|
||||
result.id = serializers.deserialize(value,
|
||||
specifiedType: const FullType(String))! as String;
|
||||
result.id =
|
||||
serializers.deserialize(
|
||||
value,
|
||||
specifiedType: const FullType(String),
|
||||
)!
|
||||
as String;
|
||||
break;
|
||||
case 'created_at':
|
||||
result.createdAt = serializers.deserialize(value,
|
||||
specifiedType: const FullType(String)) as String?;
|
||||
result.createdAt =
|
||||
serializers.deserialize(
|
||||
value,
|
||||
specifiedType: const FullType(String),
|
||||
)
|
||||
as String?;
|
||||
break;
|
||||
case 'updated_at':
|
||||
result.updatedAt = serializers.deserialize(value,
|
||||
specifiedType: const FullType(String)) as String?;
|
||||
result.updatedAt =
|
||||
serializers.deserialize(
|
||||
value,
|
||||
specifiedType: const FullType(String),
|
||||
)
|
||||
as String?;
|
||||
break;
|
||||
case 'width':
|
||||
result.width = serializers.deserialize(value,
|
||||
specifiedType: const FullType(int)) as int?;
|
||||
result.width =
|
||||
serializers.deserialize(value, specifiedType: const FullType(int))
|
||||
as int?;
|
||||
break;
|
||||
case 'height':
|
||||
result.height = serializers.deserialize(value,
|
||||
specifiedType: const FullType(int)) as int?;
|
||||
result.height =
|
||||
serializers.deserialize(value, specifiedType: const FullType(int))
|
||||
as int?;
|
||||
break;
|
||||
case 'color':
|
||||
result.color = serializers.deserialize(value,
|
||||
specifiedType: const FullType(String)) as String?;
|
||||
result.color =
|
||||
serializers.deserialize(
|
||||
value,
|
||||
specifiedType: const FullType(String),
|
||||
)
|
||||
as String?;
|
||||
break;
|
||||
case 'downloads':
|
||||
result.downloads = serializers.deserialize(value,
|
||||
specifiedType: const FullType(int)) as int?;
|
||||
result.downloads =
|
||||
serializers.deserialize(value, specifiedType: const FullType(int))
|
||||
as int?;
|
||||
break;
|
||||
case 'likes':
|
||||
result.likes = serializers.deserialize(value,
|
||||
specifiedType: const FullType(int)) as int?;
|
||||
result.likes =
|
||||
serializers.deserialize(value, specifiedType: const FullType(int))
|
||||
as int?;
|
||||
break;
|
||||
case 'liked_by_user':
|
||||
result.likedByUser = serializers.deserialize(value,
|
||||
specifiedType: const FullType(bool)) as bool?;
|
||||
result.likedByUser =
|
||||
serializers.deserialize(
|
||||
value,
|
||||
specifiedType: const FullType(bool),
|
||||
)
|
||||
as bool?;
|
||||
break;
|
||||
case 'description':
|
||||
result.description = serializers.deserialize(value,
|
||||
specifiedType: const FullType(String)) as String?;
|
||||
result.description =
|
||||
serializers.deserialize(
|
||||
value,
|
||||
specifiedType: const FullType(String),
|
||||
)
|
||||
as String?;
|
||||
break;
|
||||
case 'exif':
|
||||
result.exif.replace(serializers.deserialize(value,
|
||||
specifiedType: const FullType(Exif))! as Exif);
|
||||
result.exif.replace(
|
||||
serializers.deserialize(value, specifiedType: const FullType(Exif))!
|
||||
as Exif,
|
||||
);
|
||||
break;
|
||||
case 'location':
|
||||
result.location.replace(serializers.deserialize(value,
|
||||
specifiedType: const FullType(Location))! as Location);
|
||||
result.location.replace(
|
||||
serializers.deserialize(
|
||||
value,
|
||||
specifiedType: const FullType(Location),
|
||||
)!
|
||||
as Location,
|
||||
);
|
||||
break;
|
||||
case 'tags':
|
||||
result.tags.replace(serializers.deserialize(value,
|
||||
specifiedType:
|
||||
const FullType(BuiltList, const [const FullType(Tags)]))!
|
||||
as BuiltList<Object?>);
|
||||
result.tags.replace(
|
||||
serializers.deserialize(
|
||||
value,
|
||||
specifiedType: const FullType(BuiltList, const [
|
||||
const FullType(Tags),
|
||||
]),
|
||||
)!
|
||||
as BuiltList<Object?>,
|
||||
);
|
||||
break;
|
||||
case 'current_user_collections':
|
||||
result.currentUserCollections.replace(serializers.deserialize(value,
|
||||
specifiedType: const FullType(BuiltList, const [
|
||||
const FullType(CurrentUserCollections)
|
||||
]))! as BuiltList<Object?>);
|
||||
result.currentUserCollections.replace(
|
||||
serializers.deserialize(
|
||||
value,
|
||||
specifiedType: const FullType(BuiltList, const [
|
||||
const FullType(CurrentUserCollections),
|
||||
]),
|
||||
)!
|
||||
as BuiltList<Object?>,
|
||||
);
|
||||
break;
|
||||
case 'urls':
|
||||
result.urls.replace(serializers.deserialize(value,
|
||||
specifiedType: const FullType(Urls))! as Urls);
|
||||
result.urls.replace(
|
||||
serializers.deserialize(value, specifiedType: const FullType(Urls))!
|
||||
as Urls,
|
||||
);
|
||||
break;
|
||||
case 'links':
|
||||
result.links.replace(serializers.deserialize(value,
|
||||
specifiedType: const FullType(Links))! as Links);
|
||||
result.links.replace(
|
||||
serializers.deserialize(
|
||||
value,
|
||||
specifiedType: const FullType(Links),
|
||||
)!
|
||||
as Links,
|
||||
);
|
||||
break;
|
||||
case 'user':
|
||||
result.user.replace(serializers.deserialize(value,
|
||||
specifiedType: const FullType(User))! as User);
|
||||
result.user.replace(
|
||||
serializers.deserialize(value, specifiedType: const FullType(User))!
|
||||
as User,
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -268,25 +348,25 @@ class _$Photo extends Photo {
|
||||
factory _$Photo([void Function(PhotoBuilder)? updates]) =>
|
||||
(new PhotoBuilder()..update(updates))._build();
|
||||
|
||||
_$Photo._(
|
||||
{required this.id,
|
||||
this.createdAt,
|
||||
this.updatedAt,
|
||||
this.width,
|
||||
this.height,
|
||||
this.color,
|
||||
this.downloads,
|
||||
this.likes,
|
||||
this.likedByUser,
|
||||
this.description,
|
||||
this.exif,
|
||||
this.location,
|
||||
this.tags,
|
||||
this.currentUserCollections,
|
||||
this.urls,
|
||||
this.links,
|
||||
this.user})
|
||||
: super._() {
|
||||
_$Photo._({
|
||||
required this.id,
|
||||
this.createdAt,
|
||||
this.updatedAt,
|
||||
this.width,
|
||||
this.height,
|
||||
this.color,
|
||||
this.downloads,
|
||||
this.likes,
|
||||
this.likedByUser,
|
||||
this.description,
|
||||
this.exif,
|
||||
this.location,
|
||||
this.tags,
|
||||
this.currentUserCollections,
|
||||
this.urls,
|
||||
this.links,
|
||||
this.user,
|
||||
}) : super._() {
|
||||
BuiltValueNullFieldError.checkNotNull(id, r'Photo', 'id');
|
||||
}
|
||||
|
||||
@@ -428,8 +508,8 @@ class PhotoBuilder implements Builder<Photo, PhotoBuilder> {
|
||||
_$this._currentUserCollections ??=
|
||||
new ListBuilder<CurrentUserCollections>();
|
||||
set currentUserCollections(
|
||||
ListBuilder<CurrentUserCollections>? currentUserCollections) =>
|
||||
_$this._currentUserCollections = currentUserCollections;
|
||||
ListBuilder<CurrentUserCollections>? currentUserCollections,
|
||||
) => _$this._currentUserCollections = currentUserCollections;
|
||||
|
||||
UrlsBuilder? _urls;
|
||||
UrlsBuilder get urls => _$this._urls ??= new UrlsBuilder();
|
||||
@@ -487,25 +567,27 @@ class PhotoBuilder implements Builder<Photo, PhotoBuilder> {
|
||||
_$Photo _build() {
|
||||
_$Photo _$result;
|
||||
try {
|
||||
_$result = _$v ??
|
||||
_$result =
|
||||
_$v ??
|
||||
new _$Photo._(
|
||||
id: BuiltValueNullFieldError.checkNotNull(id, r'Photo', 'id'),
|
||||
createdAt: createdAt,
|
||||
updatedAt: updatedAt,
|
||||
width: width,
|
||||
height: height,
|
||||
color: color,
|
||||
downloads: downloads,
|
||||
likes: likes,
|
||||
likedByUser: likedByUser,
|
||||
description: description,
|
||||
exif: _exif?.build(),
|
||||
location: _location?.build(),
|
||||
tags: _tags?.build(),
|
||||
currentUserCollections: _currentUserCollections?.build(),
|
||||
urls: _urls?.build(),
|
||||
links: _links?.build(),
|
||||
user: _user?.build());
|
||||
id: BuiltValueNullFieldError.checkNotNull(id, r'Photo', 'id'),
|
||||
createdAt: createdAt,
|
||||
updatedAt: updatedAt,
|
||||
width: width,
|
||||
height: height,
|
||||
color: color,
|
||||
downloads: downloads,
|
||||
likes: likes,
|
||||
likedByUser: likedByUser,
|
||||
description: description,
|
||||
exif: _exif?.build(),
|
||||
location: _location?.build(),
|
||||
tags: _tags?.build(),
|
||||
currentUserCollections: _currentUserCollections?.build(),
|
||||
urls: _urls?.build(),
|
||||
links: _links?.build(),
|
||||
user: _user?.build(),
|
||||
);
|
||||
} catch (_) {
|
||||
late String _$failedField;
|
||||
try {
|
||||
@@ -525,7 +607,10 @@ class PhotoBuilder implements Builder<Photo, PhotoBuilder> {
|
||||
_user?.build();
|
||||
} catch (e) {
|
||||
throw new BuiltValueNestedFieldError(
|
||||
r'Photo', _$failedField, e.toString());
|
||||
r'Photo',
|
||||
_$failedField,
|
||||
e.toString(),
|
||||
);
|
||||
}
|
||||
rethrow;
|
||||
}
|
||||
|
||||
@@ -28,7 +28,9 @@ abstract class Position implements Built<Position, PositionBuilder> {
|
||||
|
||||
static Position? fromJson(String jsonString) {
|
||||
return serializers.deserializeWith(
|
||||
Position.serializer, json.decode(jsonString));
|
||||
Position.serializer,
|
||||
json.decode(jsonString),
|
||||
);
|
||||
}
|
||||
|
||||
static Serializer<Position> get serializer => _$positionSerializer;
|
||||
|
||||
@@ -19,23 +19,33 @@ class _$PositionSerializer implements StructuredSerializer<Position> {
|
||||
final String wireName = 'Position';
|
||||
|
||||
@override
|
||||
Iterable<Object?> serialize(Serializers serializers, Position object,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
Iterable<Object?> serialize(
|
||||
Serializers serializers,
|
||||
Position object, {
|
||||
FullType specifiedType = FullType.unspecified,
|
||||
}) {
|
||||
final result = <Object?>[
|
||||
'latitude',
|
||||
serializers.serialize(object.latitude,
|
||||
specifiedType: const FullType(double)),
|
||||
serializers.serialize(
|
||||
object.latitude,
|
||||
specifiedType: const FullType(double),
|
||||
),
|
||||
'longitude',
|
||||
serializers.serialize(object.longitude,
|
||||
specifiedType: const FullType(double)),
|
||||
serializers.serialize(
|
||||
object.longitude,
|
||||
specifiedType: const FullType(double),
|
||||
),
|
||||
];
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@override
|
||||
Position deserialize(Serializers serializers, Iterable<Object?> serialized,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
Position deserialize(
|
||||
Serializers serializers,
|
||||
Iterable<Object?> serialized, {
|
||||
FullType specifiedType = FullType.unspecified,
|
||||
}) {
|
||||
final result = new PositionBuilder();
|
||||
|
||||
final iterator = serialized.iterator;
|
||||
@@ -45,12 +55,20 @@ class _$PositionSerializer implements StructuredSerializer<Position> {
|
||||
final Object? value = iterator.current;
|
||||
switch (key) {
|
||||
case 'latitude':
|
||||
result.latitude = serializers.deserialize(value,
|
||||
specifiedType: const FullType(double))! as double;
|
||||
result.latitude =
|
||||
serializers.deserialize(
|
||||
value,
|
||||
specifiedType: const FullType(double),
|
||||
)!
|
||||
as double;
|
||||
break;
|
||||
case 'longitude':
|
||||
result.longitude = serializers.deserialize(value,
|
||||
specifiedType: const FullType(double))! as double;
|
||||
result.longitude =
|
||||
serializers.deserialize(
|
||||
value,
|
||||
specifiedType: const FullType(double),
|
||||
)!
|
||||
as double;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -144,12 +162,20 @@ class PositionBuilder implements Builder<Position, PositionBuilder> {
|
||||
Position build() => _build();
|
||||
|
||||
_$Position _build() {
|
||||
final _$result = _$v ??
|
||||
final _$result =
|
||||
_$v ??
|
||||
new _$Position._(
|
||||
latitude: BuiltValueNullFieldError.checkNotNull(
|
||||
latitude, r'Position', 'latitude'),
|
||||
longitude: BuiltValueNullFieldError.checkNotNull(
|
||||
longitude, r'Position', 'longitude'));
|
||||
latitude: BuiltValueNullFieldError.checkNotNull(
|
||||
latitude,
|
||||
r'Position',
|
||||
'latitude',
|
||||
),
|
||||
longitude: BuiltValueNullFieldError.checkNotNull(
|
||||
longitude,
|
||||
r'Position',
|
||||
'longitude',
|
||||
),
|
||||
);
|
||||
replace(_$result);
|
||||
return _$result;
|
||||
}
|
||||
|
||||
@@ -15,9 +15,9 @@ part 'search_photos_response.g.dart';
|
||||
|
||||
abstract class SearchPhotosResponse
|
||||
implements Built<SearchPhotosResponse, SearchPhotosResponseBuilder> {
|
||||
factory SearchPhotosResponse(
|
||||
[void Function(SearchPhotosResponseBuilder)? updates]) =
|
||||
_$SearchPhotosResponse;
|
||||
factory SearchPhotosResponse([
|
||||
void Function(SearchPhotosResponseBuilder)? updates,
|
||||
]) = _$SearchPhotosResponse;
|
||||
|
||||
SearchPhotosResponse._();
|
||||
|
||||
@@ -32,12 +32,15 @@ abstract class SearchPhotosResponse
|
||||
|
||||
String toJson() {
|
||||
return json.encode(
|
||||
serializers.serializeWith(SearchPhotosResponse.serializer, this));
|
||||
serializers.serializeWith(SearchPhotosResponse.serializer, this),
|
||||
);
|
||||
}
|
||||
|
||||
static SearchPhotosResponse? fromJson(String jsonString) {
|
||||
return serializers.deserializeWith(
|
||||
SearchPhotosResponse.serializer, json.decode(jsonString));
|
||||
SearchPhotosResponse.serializer,
|
||||
json.decode(jsonString),
|
||||
);
|
||||
}
|
||||
|
||||
static Serializer<SearchPhotosResponse> get serializer =>
|
||||
|
||||
@@ -18,20 +18,23 @@ class _$SearchPhotosResponseSerializer
|
||||
@override
|
||||
final Iterable<Type> types = const [
|
||||
SearchPhotosResponse,
|
||||
_$SearchPhotosResponse
|
||||
_$SearchPhotosResponse,
|
||||
];
|
||||
@override
|
||||
final String wireName = 'SearchPhotosResponse';
|
||||
|
||||
@override
|
||||
Iterable<Object?> serialize(
|
||||
Serializers serializers, SearchPhotosResponse object,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
Serializers serializers,
|
||||
SearchPhotosResponse object, {
|
||||
FullType specifiedType = FullType.unspecified,
|
||||
}) {
|
||||
final result = <Object?>[
|
||||
'results',
|
||||
serializers.serialize(object.results,
|
||||
specifiedType:
|
||||
const FullType(BuiltList, const [const FullType(Photo)])),
|
||||
serializers.serialize(
|
||||
object.results,
|
||||
specifiedType: const FullType(BuiltList, const [const FullType(Photo)]),
|
||||
),
|
||||
];
|
||||
Object? value;
|
||||
value = object.total;
|
||||
@@ -51,8 +54,10 @@ class _$SearchPhotosResponseSerializer
|
||||
|
||||
@override
|
||||
SearchPhotosResponse deserialize(
|
||||
Serializers serializers, Iterable<Object?> serialized,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
Serializers serializers,
|
||||
Iterable<Object?> serialized, {
|
||||
FullType specifiedType = FullType.unspecified,
|
||||
}) {
|
||||
final result = new SearchPhotosResponseBuilder();
|
||||
|
||||
final iterator = serialized.iterator;
|
||||
@@ -62,18 +67,25 @@ class _$SearchPhotosResponseSerializer
|
||||
final Object? value = iterator.current;
|
||||
switch (key) {
|
||||
case 'total':
|
||||
result.total = serializers.deserialize(value,
|
||||
specifiedType: const FullType(int)) as int?;
|
||||
result.total =
|
||||
serializers.deserialize(value, specifiedType: const FullType(int))
|
||||
as int?;
|
||||
break;
|
||||
case 'total_pages':
|
||||
result.totalPages = serializers.deserialize(value,
|
||||
specifiedType: const FullType(int)) as int?;
|
||||
result.totalPages =
|
||||
serializers.deserialize(value, specifiedType: const FullType(int))
|
||||
as int?;
|
||||
break;
|
||||
case 'results':
|
||||
result.results.replace(serializers.deserialize(value,
|
||||
specifiedType:
|
||||
const FullType(BuiltList, const [const FullType(Photo)]))!
|
||||
as BuiltList<Object?>);
|
||||
result.results.replace(
|
||||
serializers.deserialize(
|
||||
value,
|
||||
specifiedType: const FullType(BuiltList, const [
|
||||
const FullType(Photo),
|
||||
]),
|
||||
)!
|
||||
as BuiltList<Object?>,
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -90,20 +102,23 @@ class _$SearchPhotosResponse extends SearchPhotosResponse {
|
||||
@override
|
||||
final BuiltList<Photo> results;
|
||||
|
||||
factory _$SearchPhotosResponse(
|
||||
[void Function(SearchPhotosResponseBuilder)? updates]) =>
|
||||
(new SearchPhotosResponseBuilder()..update(updates))._build();
|
||||
factory _$SearchPhotosResponse([
|
||||
void Function(SearchPhotosResponseBuilder)? updates,
|
||||
]) => (new SearchPhotosResponseBuilder()..update(updates))._build();
|
||||
|
||||
_$SearchPhotosResponse._({this.total, this.totalPages, required this.results})
|
||||
: super._() {
|
||||
: super._() {
|
||||
BuiltValueNullFieldError.checkNotNull(
|
||||
results, r'SearchPhotosResponse', 'results');
|
||||
results,
|
||||
r'SearchPhotosResponse',
|
||||
'results',
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
SearchPhotosResponse rebuild(
|
||||
void Function(SearchPhotosResponseBuilder) updates) =>
|
||||
(toBuilder()..update(updates)).build();
|
||||
void Function(SearchPhotosResponseBuilder) updates,
|
||||
) => (toBuilder()..update(updates)).build();
|
||||
|
||||
@override
|
||||
SearchPhotosResponseBuilder toBuilder() =>
|
||||
@@ -185,9 +200,13 @@ class SearchPhotosResponseBuilder
|
||||
_$SearchPhotosResponse _build() {
|
||||
_$SearchPhotosResponse _$result;
|
||||
try {
|
||||
_$result = _$v ??
|
||||
_$result =
|
||||
_$v ??
|
||||
new _$SearchPhotosResponse._(
|
||||
total: total, totalPages: totalPages, results: results.build());
|
||||
total: total,
|
||||
totalPages: totalPages,
|
||||
results: results.build(),
|
||||
);
|
||||
} catch (_) {
|
||||
late String _$failedField;
|
||||
try {
|
||||
@@ -195,7 +214,10 @@ class SearchPhotosResponseBuilder
|
||||
results.build();
|
||||
} catch (e) {
|
||||
throw new BuiltValueNestedFieldError(
|
||||
r'SearchPhotosResponse', _$failedField, e.toString());
|
||||
r'SearchPhotosResponse',
|
||||
_$failedField,
|
||||
e.toString(),
|
||||
);
|
||||
}
|
||||
rethrow;
|
||||
}
|
||||
|
||||
@@ -25,7 +25,9 @@ abstract class Tags implements Built<Tags, TagsBuilder> {
|
||||
|
||||
static Tags? fromJson(String jsonString) {
|
||||
return serializers.deserializeWith(
|
||||
Tags.serializer, json.decode(jsonString));
|
||||
Tags.serializer,
|
||||
json.decode(jsonString),
|
||||
);
|
||||
}
|
||||
|
||||
static Serializer<Tags> get serializer => _$tagsSerializer;
|
||||
|
||||
@@ -19,20 +19,28 @@ class _$TagsSerializer implements StructuredSerializer<Tags> {
|
||||
final String wireName = 'Tags';
|
||||
|
||||
@override
|
||||
Iterable<Object?> serialize(Serializers serializers, Tags object,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
Iterable<Object?> serialize(
|
||||
Serializers serializers,
|
||||
Tags object, {
|
||||
FullType specifiedType = FullType.unspecified,
|
||||
}) {
|
||||
final result = <Object?>[
|
||||
'title',
|
||||
serializers.serialize(object.title,
|
||||
specifiedType: const FullType(String)),
|
||||
serializers.serialize(
|
||||
object.title,
|
||||
specifiedType: const FullType(String),
|
||||
),
|
||||
];
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@override
|
||||
Tags deserialize(Serializers serializers, Iterable<Object?> serialized,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
Tags deserialize(
|
||||
Serializers serializers,
|
||||
Iterable<Object?> serialized, {
|
||||
FullType specifiedType = FullType.unspecified,
|
||||
}) {
|
||||
final result = new TagsBuilder();
|
||||
|
||||
final iterator = serialized.iterator;
|
||||
@@ -42,8 +50,12 @@ class _$TagsSerializer implements StructuredSerializer<Tags> {
|
||||
final Object? value = iterator.current;
|
||||
switch (key) {
|
||||
case 'title':
|
||||
result.title = serializers.deserialize(value,
|
||||
specifiedType: const FullType(String))! as String;
|
||||
result.title =
|
||||
serializers.deserialize(
|
||||
value,
|
||||
specifiedType: const FullType(String),
|
||||
)!
|
||||
as String;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -86,8 +98,8 @@ class _$Tags extends Tags {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return (newBuiltValueToStringHelper(r'Tags')..add('title', title))
|
||||
.toString();
|
||||
return (newBuiltValueToStringHelper(r'Tags')
|
||||
..add('title', title)).toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,10 +136,11 @@ class TagsBuilder implements Builder<Tags, TagsBuilder> {
|
||||
Tags build() => _build();
|
||||
|
||||
_$Tags _build() {
|
||||
final _$result = _$v ??
|
||||
final _$result =
|
||||
_$v ??
|
||||
new _$Tags._(
|
||||
title:
|
||||
BuiltValueNullFieldError.checkNotNull(title, r'Tags', 'title'));
|
||||
title: BuiltValueNullFieldError.checkNotNull(title, r'Tags', 'title'),
|
||||
);
|
||||
replace(_$result);
|
||||
return _$result;
|
||||
}
|
||||
|
||||
@@ -19,11 +19,9 @@ final _unsplashBaseUrl = Uri.parse('https://api.unsplash.com/');
|
||||
/// [Unsplash API](https://unsplash.com/developers) `accessKey` to make
|
||||
/// requests to the Unsplash API.
|
||||
class Unsplash {
|
||||
Unsplash({
|
||||
required String accessKey,
|
||||
http.BaseClient? httpClient,
|
||||
}) : _accessKey = accessKey,
|
||||
_client = httpClient ?? http.Client();
|
||||
Unsplash({required String accessKey, http.BaseClient? httpClient})
|
||||
: _accessKey = accessKey,
|
||||
_client = httpClient ?? http.Client();
|
||||
|
||||
final String _accessKey;
|
||||
final http.Client _client;
|
||||
@@ -36,19 +34,21 @@ class Unsplash {
|
||||
List<num> collections = const [],
|
||||
SearchPhotosOrientation? orientation,
|
||||
}) async {
|
||||
final searchPhotosUrl = _unsplashBaseUrl
|
||||
.replace(path: '/search/photos', queryParameters: <String, String>{
|
||||
'query': query,
|
||||
if (page != 1) 'page': '$page',
|
||||
if (perPage != 10) 'per_page': '$perPage',
|
||||
if (collections.isNotEmpty) 'collections': collections.join(','),
|
||||
if (orientation == SearchPhotosOrientation.landscape)
|
||||
'orientation': 'landscape',
|
||||
if (orientation == SearchPhotosOrientation.portrait)
|
||||
'orientation': 'portrait',
|
||||
if (orientation == SearchPhotosOrientation.squarish)
|
||||
'orientation': 'squarish',
|
||||
});
|
||||
final searchPhotosUrl = _unsplashBaseUrl.replace(
|
||||
path: '/search/photos',
|
||||
queryParameters: <String, String>{
|
||||
'query': query,
|
||||
if (page != 1) 'page': '$page',
|
||||
if (perPage != 10) 'per_page': '$perPage',
|
||||
if (collections.isNotEmpty) 'collections': collections.join(','),
|
||||
if (orientation == SearchPhotosOrientation.landscape)
|
||||
'orientation': 'landscape',
|
||||
if (orientation == SearchPhotosOrientation.portrait)
|
||||
'orientation': 'portrait',
|
||||
if (orientation == SearchPhotosOrientation.squarish)
|
||||
'orientation': 'squarish',
|
||||
},
|
||||
);
|
||||
_log.info('GET $searchPhotosUrl');
|
||||
|
||||
final response = await _client.get(
|
||||
@@ -81,26 +81,30 @@ class Unsplash {
|
||||
// https://help.unsplash.com/en/articles/2511258-guideline-triggering-a-download
|
||||
|
||||
_log.info('GET ${photo.urls!.full}');
|
||||
final futureBytes = http.readBytes(Uri.parse(photo.urls!.full!), headers: {
|
||||
'Accept-Version': 'v1',
|
||||
'Authorization': 'Client-ID $_accessKey',
|
||||
});
|
||||
final futureBytes = http.readBytes(
|
||||
Uri.parse(photo.urls!.full!),
|
||||
headers: {
|
||||
'Accept-Version': 'v1',
|
||||
'Authorization': 'Client-ID $_accessKey',
|
||||
},
|
||||
);
|
||||
|
||||
_log.info('GET ${photo.links!.downloadLocation}');
|
||||
unawaited(http.get(Uri.parse(photo.links!.downloadLocation!), headers: {
|
||||
'Accept-Version': 'v1',
|
||||
'Authorization': 'Client-ID $_accessKey',
|
||||
}));
|
||||
unawaited(
|
||||
http.get(
|
||||
Uri.parse(photo.links!.downloadLocation!),
|
||||
headers: {
|
||||
'Accept-Version': 'v1',
|
||||
'Authorization': 'Client-ID $_accessKey',
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
return futureBytes;
|
||||
}
|
||||
}
|
||||
|
||||
enum SearchPhotosOrientation {
|
||||
landscape,
|
||||
portrait,
|
||||
squarish,
|
||||
}
|
||||
enum SearchPhotosOrientation { landscape, portrait, squarish }
|
||||
|
||||
class UnsplashException implements Exception {
|
||||
UnsplashException([this.message]);
|
||||
|
||||
@@ -37,7 +37,9 @@ abstract class Urls implements Built<Urls, UrlsBuilder> {
|
||||
|
||||
static Urls? fromJson(String jsonString) {
|
||||
return serializers.deserializeWith(
|
||||
Urls.serializer, json.decode(jsonString));
|
||||
Urls.serializer,
|
||||
json.decode(jsonString),
|
||||
);
|
||||
}
|
||||
|
||||
static Serializer<Urls> get serializer => _$urlsSerializer;
|
||||
|
||||
@@ -19,51 +19,62 @@ class _$UrlsSerializer implements StructuredSerializer<Urls> {
|
||||
final String wireName = 'Urls';
|
||||
|
||||
@override
|
||||
Iterable<Object?> serialize(Serializers serializers, Urls object,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
Iterable<Object?> serialize(
|
||||
Serializers serializers,
|
||||
Urls object, {
|
||||
FullType specifiedType = FullType.unspecified,
|
||||
}) {
|
||||
final result = <Object?>[];
|
||||
Object? value;
|
||||
value = object.raw;
|
||||
if (value != null) {
|
||||
result
|
||||
..add('raw')
|
||||
..add(serializers.serialize(value,
|
||||
specifiedType: const FullType(String)));
|
||||
..add(
|
||||
serializers.serialize(value, specifiedType: const FullType(String)),
|
||||
);
|
||||
}
|
||||
value = object.full;
|
||||
if (value != null) {
|
||||
result
|
||||
..add('full')
|
||||
..add(serializers.serialize(value,
|
||||
specifiedType: const FullType(String)));
|
||||
..add(
|
||||
serializers.serialize(value, specifiedType: const FullType(String)),
|
||||
);
|
||||
}
|
||||
value = object.regular;
|
||||
if (value != null) {
|
||||
result
|
||||
..add('regular')
|
||||
..add(serializers.serialize(value,
|
||||
specifiedType: const FullType(String)));
|
||||
..add(
|
||||
serializers.serialize(value, specifiedType: const FullType(String)),
|
||||
);
|
||||
}
|
||||
value = object.small;
|
||||
if (value != null) {
|
||||
result
|
||||
..add('small')
|
||||
..add(serializers.serialize(value,
|
||||
specifiedType: const FullType(String)));
|
||||
..add(
|
||||
serializers.serialize(value, specifiedType: const FullType(String)),
|
||||
);
|
||||
}
|
||||
value = object.thumb;
|
||||
if (value != null) {
|
||||
result
|
||||
..add('thumb')
|
||||
..add(serializers.serialize(value,
|
||||
specifiedType: const FullType(String)));
|
||||
..add(
|
||||
serializers.serialize(value, specifiedType: const FullType(String)),
|
||||
);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@override
|
||||
Urls deserialize(Serializers serializers, Iterable<Object?> serialized,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
Urls deserialize(
|
||||
Serializers serializers,
|
||||
Iterable<Object?> serialized, {
|
||||
FullType specifiedType = FullType.unspecified,
|
||||
}) {
|
||||
final result = new UrlsBuilder();
|
||||
|
||||
final iterator = serialized.iterator;
|
||||
@@ -73,24 +84,44 @@ class _$UrlsSerializer implements StructuredSerializer<Urls> {
|
||||
final Object? value = iterator.current;
|
||||
switch (key) {
|
||||
case 'raw':
|
||||
result.raw = serializers.deserialize(value,
|
||||
specifiedType: const FullType(String)) as String?;
|
||||
result.raw =
|
||||
serializers.deserialize(
|
||||
value,
|
||||
specifiedType: const FullType(String),
|
||||
)
|
||||
as String?;
|
||||
break;
|
||||
case 'full':
|
||||
result.full = serializers.deserialize(value,
|
||||
specifiedType: const FullType(String)) as String?;
|
||||
result.full =
|
||||
serializers.deserialize(
|
||||
value,
|
||||
specifiedType: const FullType(String),
|
||||
)
|
||||
as String?;
|
||||
break;
|
||||
case 'regular':
|
||||
result.regular = serializers.deserialize(value,
|
||||
specifiedType: const FullType(String)) as String?;
|
||||
result.regular =
|
||||
serializers.deserialize(
|
||||
value,
|
||||
specifiedType: const FullType(String),
|
||||
)
|
||||
as String?;
|
||||
break;
|
||||
case 'small':
|
||||
result.small = serializers.deserialize(value,
|
||||
specifiedType: const FullType(String)) as String?;
|
||||
result.small =
|
||||
serializers.deserialize(
|
||||
value,
|
||||
specifiedType: const FullType(String),
|
||||
)
|
||||
as String?;
|
||||
break;
|
||||
case 'thumb':
|
||||
result.thumb = serializers.deserialize(value,
|
||||
specifiedType: const FullType(String)) as String?;
|
||||
result.thumb =
|
||||
serializers.deserialize(
|
||||
value,
|
||||
specifiedType: const FullType(String),
|
||||
)
|
||||
as String?;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -115,7 +146,7 @@ class _$Urls extends Urls {
|
||||
(new UrlsBuilder()..update(updates))._build();
|
||||
|
||||
_$Urls._({this.raw, this.full, this.regular, this.small, this.thumb})
|
||||
: super._();
|
||||
: super._();
|
||||
|
||||
@override
|
||||
Urls rebuild(void Function(UrlsBuilder) updates) =>
|
||||
@@ -212,9 +243,15 @@ class UrlsBuilder implements Builder<Urls, UrlsBuilder> {
|
||||
Urls build() => _build();
|
||||
|
||||
_$Urls _build() {
|
||||
final _$result = _$v ??
|
||||
final _$result =
|
||||
_$v ??
|
||||
new _$Urls._(
|
||||
raw: raw, full: full, regular: regular, small: small, thumb: thumb);
|
||||
raw: raw,
|
||||
full: full,
|
||||
regular: regular,
|
||||
small: small,
|
||||
thumb: thumb,
|
||||
);
|
||||
replace(_$result);
|
||||
return _$result;
|
||||
}
|
||||
|
||||
@@ -56,7 +56,9 @@ abstract class User implements Built<User, UserBuilder> {
|
||||
|
||||
static User? fromJson(String jsonString) {
|
||||
return serializers.deserializeWith(
|
||||
User.serializer, json.decode(jsonString));
|
||||
User.serializer,
|
||||
json.decode(jsonString),
|
||||
);
|
||||
}
|
||||
|
||||
static Serializer<User> get serializer => _$userSerializer;
|
||||
|
||||
@@ -19,14 +19,19 @@ class _$UserSerializer implements StructuredSerializer<User> {
|
||||
final String wireName = 'User';
|
||||
|
||||
@override
|
||||
Iterable<Object?> serialize(Serializers serializers, User object,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
Iterable<Object?> serialize(
|
||||
Serializers serializers,
|
||||
User object, {
|
||||
FullType specifiedType = FullType.unspecified,
|
||||
}) {
|
||||
final result = <Object?>[
|
||||
'id',
|
||||
serializers.serialize(object.id, specifiedType: const FullType(String)),
|
||||
'username',
|
||||
serializers.serialize(object.username,
|
||||
specifiedType: const FullType(String)),
|
||||
serializers.serialize(
|
||||
object.username,
|
||||
specifiedType: const FullType(String),
|
||||
),
|
||||
'name',
|
||||
serializers.serialize(object.name, specifiedType: const FullType(String)),
|
||||
];
|
||||
@@ -35,29 +40,33 @@ class _$UserSerializer implements StructuredSerializer<User> {
|
||||
if (value != null) {
|
||||
result
|
||||
..add('updated_at')
|
||||
..add(serializers.serialize(value,
|
||||
specifiedType: const FullType(String)));
|
||||
..add(
|
||||
serializers.serialize(value, specifiedType: const FullType(String)),
|
||||
);
|
||||
}
|
||||
value = object.portfolioUrl;
|
||||
if (value != null) {
|
||||
result
|
||||
..add('portfolio_url')
|
||||
..add(serializers.serialize(value,
|
||||
specifiedType: const FullType(String)));
|
||||
..add(
|
||||
serializers.serialize(value, specifiedType: const FullType(String)),
|
||||
);
|
||||
}
|
||||
value = object.bio;
|
||||
if (value != null) {
|
||||
result
|
||||
..add('bio')
|
||||
..add(serializers.serialize(value,
|
||||
specifiedType: const FullType(String)));
|
||||
..add(
|
||||
serializers.serialize(value, specifiedType: const FullType(String)),
|
||||
);
|
||||
}
|
||||
value = object.location;
|
||||
if (value != null) {
|
||||
result
|
||||
..add('location')
|
||||
..add(serializers.serialize(value,
|
||||
specifiedType: const FullType(String)));
|
||||
..add(
|
||||
serializers.serialize(value, specifiedType: const FullType(String)),
|
||||
);
|
||||
}
|
||||
value = object.totalLikes;
|
||||
if (value != null) {
|
||||
@@ -82,14 +91,18 @@ class _$UserSerializer implements StructuredSerializer<User> {
|
||||
result
|
||||
..add('links')
|
||||
..add(
|
||||
serializers.serialize(value, specifiedType: const FullType(Links)));
|
||||
serializers.serialize(value, specifiedType: const FullType(Links)),
|
||||
);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@override
|
||||
User deserialize(Serializers serializers, Iterable<Object?> serialized,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
User deserialize(
|
||||
Serializers serializers,
|
||||
Iterable<Object?> serialized, {
|
||||
FullType specifiedType = FullType.unspecified,
|
||||
}) {
|
||||
final result = new UserBuilder();
|
||||
|
||||
final iterator = serialized.iterator;
|
||||
@@ -99,48 +112,84 @@ class _$UserSerializer implements StructuredSerializer<User> {
|
||||
final Object? value = iterator.current;
|
||||
switch (key) {
|
||||
case 'id':
|
||||
result.id = serializers.deserialize(value,
|
||||
specifiedType: const FullType(String))! as String;
|
||||
result.id =
|
||||
serializers.deserialize(
|
||||
value,
|
||||
specifiedType: const FullType(String),
|
||||
)!
|
||||
as String;
|
||||
break;
|
||||
case 'updated_at':
|
||||
result.updatedAt = serializers.deserialize(value,
|
||||
specifiedType: const FullType(String)) as String?;
|
||||
result.updatedAt =
|
||||
serializers.deserialize(
|
||||
value,
|
||||
specifiedType: const FullType(String),
|
||||
)
|
||||
as String?;
|
||||
break;
|
||||
case 'username':
|
||||
result.username = serializers.deserialize(value,
|
||||
specifiedType: const FullType(String))! as String;
|
||||
result.username =
|
||||
serializers.deserialize(
|
||||
value,
|
||||
specifiedType: const FullType(String),
|
||||
)!
|
||||
as String;
|
||||
break;
|
||||
case 'name':
|
||||
result.name = serializers.deserialize(value,
|
||||
specifiedType: const FullType(String))! as String;
|
||||
result.name =
|
||||
serializers.deserialize(
|
||||
value,
|
||||
specifiedType: const FullType(String),
|
||||
)!
|
||||
as String;
|
||||
break;
|
||||
case 'portfolio_url':
|
||||
result.portfolioUrl = serializers.deserialize(value,
|
||||
specifiedType: const FullType(String)) as String?;
|
||||
result.portfolioUrl =
|
||||
serializers.deserialize(
|
||||
value,
|
||||
specifiedType: const FullType(String),
|
||||
)
|
||||
as String?;
|
||||
break;
|
||||
case 'bio':
|
||||
result.bio = serializers.deserialize(value,
|
||||
specifiedType: const FullType(String)) as String?;
|
||||
result.bio =
|
||||
serializers.deserialize(
|
||||
value,
|
||||
specifiedType: const FullType(String),
|
||||
)
|
||||
as String?;
|
||||
break;
|
||||
case 'location':
|
||||
result.location = serializers.deserialize(value,
|
||||
specifiedType: const FullType(String)) as String?;
|
||||
result.location =
|
||||
serializers.deserialize(
|
||||
value,
|
||||
specifiedType: const FullType(String),
|
||||
)
|
||||
as String?;
|
||||
break;
|
||||
case 'total_likes':
|
||||
result.totalLikes = serializers.deserialize(value,
|
||||
specifiedType: const FullType(int)) as int?;
|
||||
result.totalLikes =
|
||||
serializers.deserialize(value, specifiedType: const FullType(int))
|
||||
as int?;
|
||||
break;
|
||||
case 'total_photos':
|
||||
result.totalPhotos = serializers.deserialize(value,
|
||||
specifiedType: const FullType(int)) as int?;
|
||||
result.totalPhotos =
|
||||
serializers.deserialize(value, specifiedType: const FullType(int))
|
||||
as int?;
|
||||
break;
|
||||
case 'total_collections':
|
||||
result.totalCollections = serializers.deserialize(value,
|
||||
specifiedType: const FullType(int)) as int?;
|
||||
result.totalCollections =
|
||||
serializers.deserialize(value, specifiedType: const FullType(int))
|
||||
as int?;
|
||||
break;
|
||||
case 'links':
|
||||
result.links.replace(serializers.deserialize(value,
|
||||
specifiedType: const FullType(Links))! as Links);
|
||||
result.links.replace(
|
||||
serializers.deserialize(
|
||||
value,
|
||||
specifiedType: const FullType(Links),
|
||||
)!
|
||||
as Links,
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -176,19 +225,19 @@ class _$User extends User {
|
||||
factory _$User([void Function(UserBuilder)? updates]) =>
|
||||
(new UserBuilder()..update(updates))._build();
|
||||
|
||||
_$User._(
|
||||
{required this.id,
|
||||
this.updatedAt,
|
||||
required this.username,
|
||||
required this.name,
|
||||
this.portfolioUrl,
|
||||
this.bio,
|
||||
this.location,
|
||||
this.totalLikes,
|
||||
this.totalPhotos,
|
||||
this.totalCollections,
|
||||
this.links})
|
||||
: super._() {
|
||||
_$User._({
|
||||
required this.id,
|
||||
this.updatedAt,
|
||||
required this.username,
|
||||
required this.name,
|
||||
this.portfolioUrl,
|
||||
this.bio,
|
||||
this.location,
|
||||
this.totalLikes,
|
||||
this.totalPhotos,
|
||||
this.totalCollections,
|
||||
this.links,
|
||||
}) : super._() {
|
||||
BuiltValueNullFieldError.checkNotNull(id, r'User', 'id');
|
||||
BuiltValueNullFieldError.checkNotNull(username, r'User', 'username');
|
||||
BuiltValueNullFieldError.checkNotNull(name, r'User', 'name');
|
||||
@@ -340,21 +389,25 @@ class UserBuilder implements Builder<User, UserBuilder> {
|
||||
_$User _build() {
|
||||
_$User _$result;
|
||||
try {
|
||||
_$result = _$v ??
|
||||
_$result =
|
||||
_$v ??
|
||||
new _$User._(
|
||||
id: BuiltValueNullFieldError.checkNotNull(id, r'User', 'id'),
|
||||
updatedAt: updatedAt,
|
||||
username: BuiltValueNullFieldError.checkNotNull(
|
||||
username, r'User', 'username'),
|
||||
name:
|
||||
BuiltValueNullFieldError.checkNotNull(name, r'User', 'name'),
|
||||
portfolioUrl: portfolioUrl,
|
||||
bio: bio,
|
||||
location: location,
|
||||
totalLikes: totalLikes,
|
||||
totalPhotos: totalPhotos,
|
||||
totalCollections: totalCollections,
|
||||
links: _links?.build());
|
||||
id: BuiltValueNullFieldError.checkNotNull(id, r'User', 'id'),
|
||||
updatedAt: updatedAt,
|
||||
username: BuiltValueNullFieldError.checkNotNull(
|
||||
username,
|
||||
r'User',
|
||||
'username',
|
||||
),
|
||||
name: BuiltValueNullFieldError.checkNotNull(name, r'User', 'name'),
|
||||
portfolioUrl: portfolioUrl,
|
||||
bio: bio,
|
||||
location: location,
|
||||
totalLikes: totalLikes,
|
||||
totalPhotos: totalPhotos,
|
||||
totalCollections: totalCollections,
|
||||
links: _links?.build(),
|
||||
);
|
||||
} catch (_) {
|
||||
late String _$failedField;
|
||||
try {
|
||||
@@ -362,7 +415,10 @@ class UserBuilder implements Builder<User, UserBuilder> {
|
||||
_links?.build();
|
||||
} catch (e) {
|
||||
throw new BuiltValueNestedFieldError(
|
||||
r'User', _$failedField, e.toString());
|
||||
r'User',
|
||||
_$failedField,
|
||||
e.toString(),
|
||||
);
|
||||
}
|
||||
rethrow;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,8 @@ import '../../unsplash_access_key.dart';
|
||||
import '../unsplash/photo.dart';
|
||||
|
||||
final _unsplashHomepage = Uri.parse(
|
||||
'https://unsplash.com/?utm_source=$unsplashAppName&utm_medium=referral');
|
||||
'https://unsplash.com/?utm_source=$unsplashAppName&utm_medium=referral',
|
||||
);
|
||||
|
||||
typedef PhotoDetailsPhotoSaveCallback = void Function(Photo);
|
||||
|
||||
@@ -36,19 +37,22 @@ class _PhotoDetailsState extends State<PhotoDetails> {
|
||||
const Text('Photo by'),
|
||||
Link(
|
||||
uri: Uri.parse(
|
||||
'https://unsplash.com/@${widget.photo.user!.username}?utm_source=$unsplashAppName&utm_medium=referral'),
|
||||
builder: (context, followLink) => HyperlinkButton(
|
||||
onPressed: followLink,
|
||||
child: Text(widget.photo.user!.name),
|
||||
'https://unsplash.com/@${widget.photo.user!.username}?utm_source=$unsplashAppName&utm_medium=referral',
|
||||
),
|
||||
builder:
|
||||
(context, followLink) => HyperlinkButton(
|
||||
onPressed: followLink,
|
||||
child: Text(widget.photo.user!.name),
|
||||
),
|
||||
),
|
||||
const Text('on'),
|
||||
Link(
|
||||
uri: _unsplashHomepage,
|
||||
builder: (context, followLink) => HyperlinkButton(
|
||||
onPressed: followLink,
|
||||
child: const Text('Unsplash'),
|
||||
),
|
||||
builder:
|
||||
(context, followLink) => HyperlinkButton(
|
||||
onPressed: followLink,
|
||||
child: const Text('Unsplash'),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
@@ -35,33 +35,34 @@ class _PhotoSearchDialogState extends State<PhotoSearchDialog> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => ContentDialog(
|
||||
title: const Text('Photo Search'),
|
||||
content: TextBox(
|
||||
autofocus: true,
|
||||
controller: _controller,
|
||||
onSubmitted: (content) {
|
||||
if (content.isNotEmpty) {
|
||||
widget.callback(content);
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
},
|
||||
),
|
||||
actions: [
|
||||
FilledButton(
|
||||
onPressed: _searchEnabled
|
||||
title: const Text('Photo Search'),
|
||||
content: TextBox(
|
||||
autofocus: true,
|
||||
controller: _controller,
|
||||
onSubmitted: (content) {
|
||||
if (content.isNotEmpty) {
|
||||
widget.callback(content);
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
},
|
||||
),
|
||||
actions: [
|
||||
FilledButton(
|
||||
onPressed:
|
||||
_searchEnabled
|
||||
? () {
|
||||
widget.callback(_controller.text);
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
widget.callback(_controller.text);
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
: null,
|
||||
child: const Text('Search'),
|
||||
),
|
||||
Button(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
],
|
||||
);
|
||||
child: const Text('Search'),
|
||||
),
|
||||
Button(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -26,16 +26,20 @@ class PolicyDialog extends StatelessWidget {
|
||||
TextSpan(
|
||||
text: 'https://policies.google.com/terms',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold, color: Colors.blue.normal),
|
||||
recognizer: TapGestureRecognizer()
|
||||
..onTap = () async {
|
||||
final url =
|
||||
Uri.parse('https://policies.google.com/terms');
|
||||
if (await url_launcher.canLaunchUrl(url)) {
|
||||
await url_launcher.launchUrl(url);
|
||||
}
|
||||
},
|
||||
)
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.blue.normal,
|
||||
),
|
||||
recognizer:
|
||||
TapGestureRecognizer()
|
||||
..onTap = () async {
|
||||
final url = Uri.parse(
|
||||
'https://policies.google.com/terms',
|
||||
);
|
||||
if (await url_launcher.canLaunchUrl(url)) {
|
||||
await url_launcher.launchUrl(url);
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -48,15 +52,18 @@ class PolicyDialog extends StatelessWidget {
|
||||
TextSpan(
|
||||
text: 'https://unsplash.com/terms',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold, color: Colors.blue.normal),
|
||||
recognizer: TapGestureRecognizer()
|
||||
..onTap = () async {
|
||||
final url = Uri.parse('https://unsplash.com/terms');
|
||||
if (await url_launcher.canLaunchUrl(url)) {
|
||||
await url_launcher.launchUrl(url);
|
||||
}
|
||||
},
|
||||
)
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.blue.normal,
|
||||
),
|
||||
recognizer:
|
||||
TapGestureRecognizer()
|
||||
..onTap = () async {
|
||||
final url = Uri.parse('https://unsplash.com/terms');
|
||||
if (await url_launcher.canLaunchUrl(url)) {
|
||||
await url_launcher.launchUrl(url);
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -173,9 +173,7 @@ class _SplitState extends State<Split> {
|
||||
child: SizedBox(
|
||||
width: isHorizontal ? Split.dividerMainAxisSize : width,
|
||||
height: isHorizontal ? height : Split.dividerMainAxisSize,
|
||||
child: Center(
|
||||
child: dragIndicator,
|
||||
),
|
||||
child: Center(child: dragIndicator),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
|
||||
@@ -9,9 +9,11 @@ import 'package:url_launcher/url_launcher.dart';
|
||||
import '../../unsplash_access_key.dart';
|
||||
|
||||
final _unsplashHomepage = Uri.parse(
|
||||
'https://unsplash.com/?utm_source=${Uri.encodeFull(unsplashAppName)}&utm_medium=referral');
|
||||
'https://unsplash.com/?utm_source=${Uri.encodeFull(unsplashAppName)}&utm_medium=referral',
|
||||
);
|
||||
final _unsplashPrivacyPolicy = Uri.parse(
|
||||
'https://unsplash.com/privacy?utm_source=${Uri.encodeFull(unsplashAppName)}&utm_medium=referral');
|
||||
'https://unsplash.com/privacy?utm_source=${Uri.encodeFull(unsplashAppName)}&utm_medium=referral',
|
||||
);
|
||||
|
||||
class UnsplashNotice extends StatefulWidget {
|
||||
const UnsplashNotice({super.key, required this.child});
|
||||
@@ -29,14 +31,17 @@ class _UnsplashNoticeState extends State<UnsplashNotice> {
|
||||
super.initState();
|
||||
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return _UnsplashDialog(accepted: () {
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return _UnsplashDialog(
|
||||
accepted: () {
|
||||
setState(() {
|
||||
noticeAccepted = true;
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -56,50 +61,53 @@ class _UnsplashDialog extends StatelessWidget {
|
||||
title: const Text('Unsplash Notice'),
|
||||
content: RichText(
|
||||
text: TextSpan(
|
||||
text: 'This is a sample desktop application provided by Google'
|
||||
' that enables you to search ',
|
||||
style: const TextStyle(color: Colors.grey),
|
||||
children: [
|
||||
TextSpan(
|
||||
text: 'Unsplash',
|
||||
recognizer: TapGestureRecognizer()
|
||||
..onTap = () async {
|
||||
if (!await launchUrl(_unsplashHomepage)) {
|
||||
throw 'Could not launch $_unsplashHomepage';
|
||||
}
|
||||
},
|
||||
style: TextStyle(color: Colors.blue),
|
||||
),
|
||||
const TextSpan(
|
||||
text: ' for photographs that interest you. When you search'
|
||||
' for and interact with photos, Unsplash will collect'
|
||||
' information about you and your use of the Unsplash'
|
||||
' services. Learn more about ',
|
||||
style: TextStyle(color: Colors.grey),
|
||||
),
|
||||
TextSpan(
|
||||
text: 'how Unsplash collects and uses data',
|
||||
recognizer: TapGestureRecognizer()
|
||||
..onTap = () async {
|
||||
if (!await launchUrl(_unsplashPrivacyPolicy)) {
|
||||
throw 'Could not launch $_unsplashPrivacyPolicy';
|
||||
}
|
||||
},
|
||||
style: TextStyle(color: Colors.blue),
|
||||
),
|
||||
const TextSpan(
|
||||
text: '.',
|
||||
style: TextStyle(color: Colors.grey),
|
||||
),
|
||||
]),
|
||||
text:
|
||||
'This is a sample desktop application provided by Google'
|
||||
' that enables you to search ',
|
||||
style: const TextStyle(color: Colors.grey),
|
||||
children: [
|
||||
TextSpan(
|
||||
text: 'Unsplash',
|
||||
recognizer:
|
||||
TapGestureRecognizer()
|
||||
..onTap = () async {
|
||||
if (!await launchUrl(_unsplashHomepage)) {
|
||||
throw 'Could not launch $_unsplashHomepage';
|
||||
}
|
||||
},
|
||||
style: TextStyle(color: Colors.blue),
|
||||
),
|
||||
const TextSpan(
|
||||
text:
|
||||
' for photographs that interest you. When you search'
|
||||
' for and interact with photos, Unsplash will collect'
|
||||
' information about you and your use of the Unsplash'
|
||||
' services. Learn more about ',
|
||||
style: TextStyle(color: Colors.grey),
|
||||
),
|
||||
TextSpan(
|
||||
text: 'how Unsplash collects and uses data',
|
||||
recognizer:
|
||||
TapGestureRecognizer()
|
||||
..onTap = () async {
|
||||
if (!await launchUrl(_unsplashPrivacyPolicy)) {
|
||||
throw 'Could not launch $_unsplashPrivacyPolicy';
|
||||
}
|
||||
},
|
||||
style: TextStyle(color: Colors.blue),
|
||||
),
|
||||
const TextSpan(text: '.', style: TextStyle(color: Colors.grey)),
|
||||
],
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
Button(
|
||||
child: const Text('Got it'),
|
||||
onPressed: () {
|
||||
accepted();
|
||||
Navigator.pop(context);
|
||||
})
|
||||
child: const Text('Got it'),
|
||||
onPressed: () {
|
||||
accepted();
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -44,30 +44,34 @@ class _UnsplashSearchContentState extends State<UnsplashSearchContent> {
|
||||
),
|
||||
),
|
||||
secondChild: Center(
|
||||
child: photoSearchModel.selectedPhoto != null
|
||||
? PhotoDetails(
|
||||
photo: photoSearchModel.selectedPhoto!,
|
||||
onPhotoSave: (photo) async {
|
||||
final saveLocation = await getSaveLocation(
|
||||
suggestedName: '${photo.id}.jpg',
|
||||
acceptedTypeGroups: [
|
||||
const XTypeGroup(
|
||||
label: 'JPG',
|
||||
extensions: ['jpg'],
|
||||
mimeTypes: ['image/jpeg'],
|
||||
),
|
||||
],
|
||||
);
|
||||
if (saveLocation != null) {
|
||||
final fileData =
|
||||
await photoSearchModel.download(photo: photo);
|
||||
final photoFile =
|
||||
XFile.fromData(fileData, mimeType: 'image/jpeg');
|
||||
await photoFile.saveTo(saveLocation.path);
|
||||
}
|
||||
},
|
||||
)
|
||||
: Container(),
|
||||
child:
|
||||
photoSearchModel.selectedPhoto != null
|
||||
? PhotoDetails(
|
||||
photo: photoSearchModel.selectedPhoto!,
|
||||
onPhotoSave: (photo) async {
|
||||
final saveLocation = await getSaveLocation(
|
||||
suggestedName: '${photo.id}.jpg',
|
||||
acceptedTypeGroups: [
|
||||
const XTypeGroup(
|
||||
label: 'JPG',
|
||||
extensions: ['jpg'],
|
||||
mimeTypes: ['image/jpeg'],
|
||||
),
|
||||
],
|
||||
);
|
||||
if (saveLocation != null) {
|
||||
final fileData = await photoSearchModel.download(
|
||||
photo: photo,
|
||||
);
|
||||
final photoFile = XFile.fromData(
|
||||
fileData,
|
||||
mimeType: 'image/jpeg',
|
||||
);
|
||||
await photoFile.saveTo(saveLocation.path);
|
||||
}
|
||||
},
|
||||
)
|
||||
: Container(),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -81,25 +85,26 @@ class _UnsplashSearchContentState extends State<UnsplashSearchContent> {
|
||||
|
||||
return TreeViewItem(
|
||||
content: Text(searchEntry.query),
|
||||
children: searchEntry.photos
|
||||
.map<TreeViewItem>(
|
||||
(photo) => TreeViewItem(
|
||||
content: Semantics(
|
||||
button: true,
|
||||
onTap: () => selectPhoto(photo),
|
||||
label: labelForPhoto(photo),
|
||||
excludeSemantics: true,
|
||||
child: GestureDetector(
|
||||
onTap: () => selectPhoto(photo),
|
||||
child: Text(
|
||||
labelForPhoto(photo),
|
||||
style: const TextStyle(color: Colors.black),
|
||||
children:
|
||||
searchEntry.photos
|
||||
.map<TreeViewItem>(
|
||||
(photo) => TreeViewItem(
|
||||
content: Semantics(
|
||||
button: true,
|
||||
onTap: () => selectPhoto(photo),
|
||||
label: labelForPhoto(photo),
|
||||
excludeSemantics: true,
|
||||
child: GestureDetector(
|
||||
onTap: () => selectPhoto(photo),
|
||||
child: Text(
|
||||
labelForPhoto(photo),
|
||||
style: const TextStyle(color: Colors.black),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
)
|
||||
.toList(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user