mirror of
https://github.com/flutter/samples.git
synced 2026-05-14 02:47:42 +00:00
Upgrading samples to flutter_lints, part 1 of n (#804)
This commit is contained in:
@@ -5,7 +5,6 @@
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
import '../unsplash/photo.dart';
|
||||
import '../unsplash/unsplash.dart';
|
||||
@@ -25,13 +24,13 @@ class PhotoSearchModel extends ChangeNotifier {
|
||||
List<SearchEntry> get entries => List.unmodifiable(_entries);
|
||||
final List<SearchEntry> _entries = [];
|
||||
|
||||
Photo get selectedPhoto => _selectedPhoto;
|
||||
set selectedPhoto(Photo photo) {
|
||||
Photo? get selectedPhoto => _selectedPhoto;
|
||||
set selectedPhoto(Photo? photo) {
|
||||
_selectedPhoto = photo;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Photo _selectedPhoto;
|
||||
Photo? _selectedPhoto;
|
||||
|
||||
Future<void> addSearch(String query) async {
|
||||
final result = await _client.searchPhotos(
|
||||
@@ -41,13 +40,12 @@ class PhotoSearchModel extends ChangeNotifier {
|
||||
final search = Search((s) {
|
||||
s
|
||||
..query = query
|
||||
..results.addAll(result.results);
|
||||
..results.addAll(result!.results);
|
||||
});
|
||||
|
||||
_entries.add(SearchEntry(query, search.results.toList(), this));
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Future<Uint8List> download({@required Photo photo}) =>
|
||||
_client.download(photo);
|
||||
Future<Uint8List> download({required Photo photo}) => _client.download(photo);
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ import '../unsplash/photo.dart';
|
||||
part 'search.g.dart';
|
||||
|
||||
abstract class Search implements Built<Search, SearchBuilder> {
|
||||
factory Search([void Function(SearchBuilder) updates]) = _$Search;
|
||||
factory Search([void Function(SearchBuilder)? updates]) = _$Search;
|
||||
Search._();
|
||||
|
||||
@BuiltValueField(wireName: 'query')
|
||||
@@ -27,7 +27,7 @@ abstract class Search implements Built<Search, SearchBuilder> {
|
||||
return json.encode(serializers.serializeWith(Search.serializer, this));
|
||||
}
|
||||
|
||||
static Search fromJson(String jsonString) {
|
||||
static Search? fromJson(String jsonString) {
|
||||
return serializers.deserializeWith(
|
||||
Search.serializer, json.decode(jsonString));
|
||||
}
|
||||
|
||||
@@ -19,9 +19,9 @@ class _$SearchSerializer implements StructuredSerializer<Search> {
|
||||
final String wireName = 'Search';
|
||||
|
||||
@override
|
||||
Iterable<Object> serialize(Serializers serializers, Search object,
|
||||
Iterable<Object?> serialize(Serializers serializers, Search object,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
final result = <Object>[
|
||||
final result = <Object?>[
|
||||
'query',
|
||||
serializers.serialize(object.query,
|
||||
specifiedType: const FullType(String)),
|
||||
@@ -35,7 +35,7 @@ class _$SearchSerializer implements StructuredSerializer<Search> {
|
||||
}
|
||||
|
||||
@override
|
||||
Search deserialize(Serializers serializers, Iterable<Object> serialized,
|
||||
Search deserialize(Serializers serializers, Iterable<Object?> serialized,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
final result = new SearchBuilder();
|
||||
|
||||
@@ -43,7 +43,7 @@ class _$SearchSerializer implements StructuredSerializer<Search> {
|
||||
while (iterator.moveNext()) {
|
||||
final key = iterator.current as String;
|
||||
iterator.moveNext();
|
||||
final Object value = iterator.current;
|
||||
final Object? value = iterator.current;
|
||||
switch (key) {
|
||||
case 'query':
|
||||
result.query = serializers.deserialize(value,
|
||||
@@ -52,7 +52,7 @@ class _$SearchSerializer implements StructuredSerializer<Search> {
|
||||
case 'results':
|
||||
result.results.replace(serializers.deserialize(value,
|
||||
specifiedType:
|
||||
const FullType(BuiltList, const [const FullType(Photo)]))
|
||||
const FullType(BuiltList, const [const FullType(Photo)]))!
|
||||
as BuiltList<Object>);
|
||||
break;
|
||||
}
|
||||
@@ -68,10 +68,10 @@ class _$Search extends Search {
|
||||
@override
|
||||
final BuiltList<Photo> results;
|
||||
|
||||
factory _$Search([void Function(SearchBuilder) updates]) =>
|
||||
factory _$Search([void Function(SearchBuilder)? updates]) =>
|
||||
(new SearchBuilder()..update(updates)).build();
|
||||
|
||||
_$Search._({this.query, this.results}) : super._() {
|
||||
_$Search._({required this.query, required this.results}) : super._() {
|
||||
BuiltValueNullFieldError.checkNotNull(query, 'Search', 'query');
|
||||
BuiltValueNullFieldError.checkNotNull(results, 'Search', 'results');
|
||||
}
|
||||
@@ -104,16 +104,16 @@ class _$Search extends Search {
|
||||
}
|
||||
|
||||
class SearchBuilder implements Builder<Search, SearchBuilder> {
|
||||
_$Search _$v;
|
||||
_$Search? _$v;
|
||||
|
||||
String _query;
|
||||
String get query => _$this._query;
|
||||
set query(String query) => _$this._query = query;
|
||||
String? _query;
|
||||
String? get query => _$this._query;
|
||||
set query(String? query) => _$this._query = query;
|
||||
|
||||
ListBuilder<Photo> _results;
|
||||
ListBuilder<Photo>? _results;
|
||||
ListBuilder<Photo> get results =>
|
||||
_$this._results ??= new ListBuilder<Photo>();
|
||||
set results(ListBuilder<Photo> results) => _$this._results = results;
|
||||
set results(ListBuilder<Photo>? results) => _$this._results = results;
|
||||
|
||||
SearchBuilder();
|
||||
|
||||
@@ -134,7 +134,7 @@ class SearchBuilder implements Builder<Search, SearchBuilder> {
|
||||
}
|
||||
|
||||
@override
|
||||
void update(void Function(SearchBuilder) updates) {
|
||||
void update(void Function(SearchBuilder)? updates) {
|
||||
if (updates != null) updates(this);
|
||||
}
|
||||
|
||||
@@ -148,7 +148,7 @@ class SearchBuilder implements Builder<Search, SearchBuilder> {
|
||||
query, 'Search', 'query'),
|
||||
results: results.build());
|
||||
} catch (_) {
|
||||
String _$failedField;
|
||||
late String _$failedField;
|
||||
try {
|
||||
_$failedField = 'results';
|
||||
results.build();
|
||||
|
||||
@@ -13,18 +13,18 @@ import '../serializers.dart';
|
||||
part 'api_error.g.dart';
|
||||
|
||||
abstract class ApiError implements Built<ApiError, ApiErrorBuilder> {
|
||||
factory ApiError([void Function(ApiErrorBuilder) updates]) = _$ApiError;
|
||||
factory ApiError([void Function(ApiErrorBuilder)? updates]) = _$ApiError;
|
||||
|
||||
ApiError._();
|
||||
|
||||
@BuiltValueField(wireName: 'errors')
|
||||
BuiltList<String> get errors;
|
||||
BuiltList<String>? get errors;
|
||||
|
||||
String toJson() {
|
||||
return json.encode(serializers.serializeWith(ApiError.serializer, this));
|
||||
}
|
||||
|
||||
static ApiError fromJson(String jsonString) {
|
||||
static ApiError? fromJson(String jsonString) {
|
||||
return serializers.deserializeWith(
|
||||
ApiError.serializer, json.decode(jsonString));
|
||||
}
|
||||
|
||||
@@ -19,20 +19,23 @@ class _$ApiErrorSerializer implements StructuredSerializer<ApiError> {
|
||||
final String wireName = 'ApiError';
|
||||
|
||||
@override
|
||||
Iterable<Object> serialize(Serializers serializers, ApiError object,
|
||||
Iterable<Object?> serialize(Serializers serializers, ApiError object,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
final result = <Object>[
|
||||
'errors',
|
||||
serializers.serialize(object.errors,
|
||||
specifiedType:
|
||||
const FullType(BuiltList, const [const FullType(String)])),
|
||||
];
|
||||
|
||||
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)])));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@override
|
||||
ApiError deserialize(Serializers serializers, Iterable<Object> serialized,
|
||||
ApiError deserialize(Serializers serializers, Iterable<Object?> serialized,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
final result = new ApiErrorBuilder();
|
||||
|
||||
@@ -40,12 +43,12 @@ class _$ApiErrorSerializer implements StructuredSerializer<ApiError> {
|
||||
while (iterator.moveNext()) {
|
||||
final key = iterator.current as String;
|
||||
iterator.moveNext();
|
||||
final Object value = iterator.current;
|
||||
final Object? value = iterator.current;
|
||||
switch (key) {
|
||||
case 'errors':
|
||||
result.errors.replace(serializers.deserialize(value,
|
||||
specifiedType:
|
||||
const FullType(BuiltList, const [const FullType(String)]))
|
||||
specifiedType: const FullType(
|
||||
BuiltList, const [const FullType(String)]))!
|
||||
as BuiltList<Object>);
|
||||
break;
|
||||
}
|
||||
@@ -57,14 +60,12 @@ class _$ApiErrorSerializer implements StructuredSerializer<ApiError> {
|
||||
|
||||
class _$ApiError extends ApiError {
|
||||
@override
|
||||
final BuiltList<String> errors;
|
||||
final BuiltList<String>? errors;
|
||||
|
||||
factory _$ApiError([void Function(ApiErrorBuilder) updates]) =>
|
||||
factory _$ApiError([void Function(ApiErrorBuilder)? updates]) =>
|
||||
(new ApiErrorBuilder()..update(updates)).build();
|
||||
|
||||
_$ApiError._({this.errors}) : super._() {
|
||||
BuiltValueNullFieldError.checkNotNull(errors, 'ApiError', 'errors');
|
||||
}
|
||||
_$ApiError._({this.errors}) : super._();
|
||||
|
||||
@override
|
||||
ApiError rebuild(void Function(ApiErrorBuilder) updates) =>
|
||||
@@ -92,19 +93,19 @@ class _$ApiError extends ApiError {
|
||||
}
|
||||
|
||||
class ApiErrorBuilder implements Builder<ApiError, ApiErrorBuilder> {
|
||||
_$ApiError _$v;
|
||||
_$ApiError? _$v;
|
||||
|
||||
ListBuilder<String> _errors;
|
||||
ListBuilder<String>? _errors;
|
||||
ListBuilder<String> get errors =>
|
||||
_$this._errors ??= new ListBuilder<String>();
|
||||
set errors(ListBuilder<String> errors) => _$this._errors = errors;
|
||||
set errors(ListBuilder<String>? errors) => _$this._errors = errors;
|
||||
|
||||
ApiErrorBuilder();
|
||||
|
||||
ApiErrorBuilder get _$this {
|
||||
final $v = _$v;
|
||||
if ($v != null) {
|
||||
_errors = $v.errors.toBuilder();
|
||||
_errors = $v.errors?.toBuilder();
|
||||
_$v = null;
|
||||
}
|
||||
return this;
|
||||
@@ -117,7 +118,7 @@ class ApiErrorBuilder implements Builder<ApiError, ApiErrorBuilder> {
|
||||
}
|
||||
|
||||
@override
|
||||
void update(void Function(ApiErrorBuilder) updates) {
|
||||
void update(void Function(ApiErrorBuilder)? updates) {
|
||||
if (updates != null) updates(this);
|
||||
}
|
||||
|
||||
@@ -125,12 +126,12 @@ class ApiErrorBuilder implements Builder<ApiError, ApiErrorBuilder> {
|
||||
_$ApiError build() {
|
||||
_$ApiError _$result;
|
||||
try {
|
||||
_$result = _$v ?? new _$ApiError._(errors: errors.build());
|
||||
_$result = _$v ?? new _$ApiError._(errors: _errors?.build());
|
||||
} catch (_) {
|
||||
String _$failedField;
|
||||
late String _$failedField;
|
||||
try {
|
||||
_$failedField = 'errors';
|
||||
errors.build();
|
||||
_errors?.build();
|
||||
} catch (e) {
|
||||
throw new BuiltValueNestedFieldError(
|
||||
'ApiError', _$failedField, e.toString());
|
||||
|
||||
@@ -14,7 +14,7 @@ part 'current_user_collections.g.dart';
|
||||
abstract class CurrentUserCollections
|
||||
implements Built<CurrentUserCollections, CurrentUserCollectionsBuilder> {
|
||||
factory CurrentUserCollections(
|
||||
[void Function(CurrentUserCollectionsBuilder) updates]) =
|
||||
[void Function(CurrentUserCollectionsBuilder)? updates]) =
|
||||
_$CurrentUserCollections;
|
||||
|
||||
CurrentUserCollections._();
|
||||
@@ -22,24 +22,21 @@ abstract class CurrentUserCollections
|
||||
@BuiltValueField(wireName: 'id')
|
||||
int get id;
|
||||
|
||||
@nullable
|
||||
@BuiltValueField(wireName: 'title')
|
||||
String get title;
|
||||
String? get title;
|
||||
|
||||
@nullable
|
||||
@BuiltValueField(wireName: 'published_at')
|
||||
String get publishedAt;
|
||||
String? get publishedAt;
|
||||
|
||||
@nullable
|
||||
@BuiltValueField(wireName: 'updated_at')
|
||||
String get updatedAt;
|
||||
String? get updatedAt;
|
||||
|
||||
String toJson() {
|
||||
return json.encode(
|
||||
serializers.serializeWith(CurrentUserCollections.serializer, this));
|
||||
}
|
||||
|
||||
static CurrentUserCollections fromJson(String jsonString) {
|
||||
static CurrentUserCollections? fromJson(String jsonString) {
|
||||
return serializers.deserializeWith(
|
||||
CurrentUserCollections.serializer, json.decode(jsonString));
|
||||
}
|
||||
|
||||
@@ -24,14 +24,14 @@ class _$CurrentUserCollectionsSerializer
|
||||
final String wireName = 'CurrentUserCollections';
|
||||
|
||||
@override
|
||||
Iterable<Object> serialize(
|
||||
Iterable<Object?> serialize(
|
||||
Serializers serializers, CurrentUserCollections object,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
final result = <Object>[
|
||||
final result = <Object?>[
|
||||
'id',
|
||||
serializers.serialize(object.id, specifiedType: const FullType(int)),
|
||||
];
|
||||
Object value;
|
||||
Object? value;
|
||||
value = object.title;
|
||||
if (value != null) {
|
||||
result
|
||||
@@ -58,7 +58,7 @@ class _$CurrentUserCollectionsSerializer
|
||||
|
||||
@override
|
||||
CurrentUserCollections deserialize(
|
||||
Serializers serializers, Iterable<Object> serialized,
|
||||
Serializers serializers, Iterable<Object?> serialized,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
final result = new CurrentUserCollectionsBuilder();
|
||||
|
||||
@@ -66,7 +66,7 @@ class _$CurrentUserCollectionsSerializer
|
||||
while (iterator.moveNext()) {
|
||||
final key = iterator.current as String;
|
||||
iterator.moveNext();
|
||||
final Object value = iterator.current;
|
||||
final Object? value = iterator.current;
|
||||
switch (key) {
|
||||
case 'id':
|
||||
result.id = serializers.deserialize(value,
|
||||
@@ -95,18 +95,18 @@ class _$CurrentUserCollections extends CurrentUserCollections {
|
||||
@override
|
||||
final int id;
|
||||
@override
|
||||
final String title;
|
||||
final String? title;
|
||||
@override
|
||||
final String publishedAt;
|
||||
final String? publishedAt;
|
||||
@override
|
||||
final String updatedAt;
|
||||
final String? updatedAt;
|
||||
|
||||
factory _$CurrentUserCollections(
|
||||
[void Function(CurrentUserCollectionsBuilder) updates]) =>
|
||||
[void Function(CurrentUserCollectionsBuilder)? updates]) =>
|
||||
(new CurrentUserCollectionsBuilder()..update(updates)).build();
|
||||
|
||||
_$CurrentUserCollections._(
|
||||
{this.id, this.title, this.publishedAt, this.updatedAt})
|
||||
{required this.id, this.title, this.publishedAt, this.updatedAt})
|
||||
: super._() {
|
||||
BuiltValueNullFieldError.checkNotNull(id, 'CurrentUserCollections', 'id');
|
||||
}
|
||||
@@ -150,23 +150,23 @@ class _$CurrentUserCollections extends CurrentUserCollections {
|
||||
|
||||
class CurrentUserCollectionsBuilder
|
||||
implements Builder<CurrentUserCollections, CurrentUserCollectionsBuilder> {
|
||||
_$CurrentUserCollections _$v;
|
||||
_$CurrentUserCollections? _$v;
|
||||
|
||||
int _id;
|
||||
int get id => _$this._id;
|
||||
set id(int id) => _$this._id = id;
|
||||
int? _id;
|
||||
int? get id => _$this._id;
|
||||
set id(int? id) => _$this._id = id;
|
||||
|
||||
String _title;
|
||||
String get title => _$this._title;
|
||||
set title(String title) => _$this._title = title;
|
||||
String? _title;
|
||||
String? get title => _$this._title;
|
||||
set title(String? title) => _$this._title = title;
|
||||
|
||||
String _publishedAt;
|
||||
String get publishedAt => _$this._publishedAt;
|
||||
set publishedAt(String publishedAt) => _$this._publishedAt = publishedAt;
|
||||
String? _publishedAt;
|
||||
String? get publishedAt => _$this._publishedAt;
|
||||
set publishedAt(String? publishedAt) => _$this._publishedAt = publishedAt;
|
||||
|
||||
String _updatedAt;
|
||||
String get updatedAt => _$this._updatedAt;
|
||||
set updatedAt(String updatedAt) => _$this._updatedAt = updatedAt;
|
||||
String? _updatedAt;
|
||||
String? get updatedAt => _$this._updatedAt;
|
||||
set updatedAt(String? updatedAt) => _$this._updatedAt = updatedAt;
|
||||
|
||||
CurrentUserCollectionsBuilder();
|
||||
|
||||
@@ -189,7 +189,7 @@ class CurrentUserCollectionsBuilder
|
||||
}
|
||||
|
||||
@override
|
||||
void update(void Function(CurrentUserCollectionsBuilder) updates) {
|
||||
void update(void Function(CurrentUserCollectionsBuilder)? updates) {
|
||||
if (updates != null) updates(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,39 +12,33 @@ import '../serializers.dart';
|
||||
part 'exif.g.dart';
|
||||
|
||||
abstract class Exif implements Built<Exif, ExifBuilder> {
|
||||
factory Exif([void Function(ExifBuilder) updates]) = _$Exif;
|
||||
factory Exif([void Function(ExifBuilder)? updates]) = _$Exif;
|
||||
|
||||
Exif._();
|
||||
|
||||
@nullable
|
||||
@BuiltValueField(wireName: 'make')
|
||||
String get make;
|
||||
String? get make;
|
||||
|
||||
@nullable
|
||||
@BuiltValueField(wireName: 'model')
|
||||
String get model;
|
||||
String? get model;
|
||||
|
||||
@nullable
|
||||
@BuiltValueField(wireName: 'exposure_time')
|
||||
String get exposureTime;
|
||||
String? get exposureTime;
|
||||
|
||||
@nullable
|
||||
@BuiltValueField(wireName: 'aperture')
|
||||
String get aperture;
|
||||
String? get aperture;
|
||||
|
||||
@nullable
|
||||
@BuiltValueField(wireName: 'focal_length')
|
||||
String get focalLength;
|
||||
String? get focalLength;
|
||||
|
||||
@nullable
|
||||
@BuiltValueField(wireName: 'iso')
|
||||
int get iso;
|
||||
int? get iso;
|
||||
|
||||
String toJson() {
|
||||
return json.encode(serializers.serializeWith(Exif.serializer, this));
|
||||
}
|
||||
|
||||
static Exif fromJson(String jsonString) {
|
||||
static Exif? fromJson(String jsonString) {
|
||||
return serializers.deserializeWith(
|
||||
Exif.serializer, json.decode(jsonString));
|
||||
}
|
||||
|
||||
@@ -19,10 +19,10 @@ class _$ExifSerializer implements StructuredSerializer<Exif> {
|
||||
final String wireName = 'Exif';
|
||||
|
||||
@override
|
||||
Iterable<Object> serialize(Serializers serializers, Exif object,
|
||||
Iterable<Object?> serialize(Serializers serializers, Exif object,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
final result = <Object>[];
|
||||
Object value;
|
||||
final result = <Object?>[];
|
||||
Object? value;
|
||||
value = object.make;
|
||||
if (value != null) {
|
||||
result
|
||||
@@ -68,7 +68,7 @@ class _$ExifSerializer implements StructuredSerializer<Exif> {
|
||||
}
|
||||
|
||||
@override
|
||||
Exif deserialize(Serializers serializers, Iterable<Object> serialized,
|
||||
Exif deserialize(Serializers serializers, Iterable<Object?> serialized,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
final result = new ExifBuilder();
|
||||
|
||||
@@ -76,7 +76,7 @@ class _$ExifSerializer implements StructuredSerializer<Exif> {
|
||||
while (iterator.moveNext()) {
|
||||
final key = iterator.current as String;
|
||||
iterator.moveNext();
|
||||
final Object value = iterator.current;
|
||||
final Object? value = iterator.current;
|
||||
switch (key) {
|
||||
case 'make':
|
||||
result.make = serializers.deserialize(value,
|
||||
@@ -111,19 +111,19 @@ class _$ExifSerializer implements StructuredSerializer<Exif> {
|
||||
|
||||
class _$Exif extends Exif {
|
||||
@override
|
||||
final String make;
|
||||
final String? make;
|
||||
@override
|
||||
final String model;
|
||||
final String? model;
|
||||
@override
|
||||
final String exposureTime;
|
||||
final String? exposureTime;
|
||||
@override
|
||||
final String aperture;
|
||||
final String? aperture;
|
||||
@override
|
||||
final String focalLength;
|
||||
final String? focalLength;
|
||||
@override
|
||||
final int iso;
|
||||
final int? iso;
|
||||
|
||||
factory _$Exif([void Function(ExifBuilder) updates]) =>
|
||||
factory _$Exif([void Function(ExifBuilder)? updates]) =>
|
||||
(new ExifBuilder()..update(updates)).build();
|
||||
|
||||
_$Exif._(
|
||||
@@ -180,31 +180,31 @@ class _$Exif extends Exif {
|
||||
}
|
||||
|
||||
class ExifBuilder implements Builder<Exif, ExifBuilder> {
|
||||
_$Exif _$v;
|
||||
_$Exif? _$v;
|
||||
|
||||
String _make;
|
||||
String get make => _$this._make;
|
||||
set make(String make) => _$this._make = make;
|
||||
String? _make;
|
||||
String? get make => _$this._make;
|
||||
set make(String? make) => _$this._make = make;
|
||||
|
||||
String _model;
|
||||
String get model => _$this._model;
|
||||
set model(String model) => _$this._model = model;
|
||||
String? _model;
|
||||
String? get model => _$this._model;
|
||||
set model(String? model) => _$this._model = model;
|
||||
|
||||
String _exposureTime;
|
||||
String get exposureTime => _$this._exposureTime;
|
||||
set exposureTime(String exposureTime) => _$this._exposureTime = exposureTime;
|
||||
String? _exposureTime;
|
||||
String? get exposureTime => _$this._exposureTime;
|
||||
set exposureTime(String? exposureTime) => _$this._exposureTime = exposureTime;
|
||||
|
||||
String _aperture;
|
||||
String get aperture => _$this._aperture;
|
||||
set aperture(String aperture) => _$this._aperture = aperture;
|
||||
String? _aperture;
|
||||
String? get aperture => _$this._aperture;
|
||||
set aperture(String? aperture) => _$this._aperture = aperture;
|
||||
|
||||
String _focalLength;
|
||||
String get focalLength => _$this._focalLength;
|
||||
set focalLength(String focalLength) => _$this._focalLength = focalLength;
|
||||
String? _focalLength;
|
||||
String? get focalLength => _$this._focalLength;
|
||||
set focalLength(String? focalLength) => _$this._focalLength = focalLength;
|
||||
|
||||
int _iso;
|
||||
int get iso => _$this._iso;
|
||||
set iso(int iso) => _$this._iso = iso;
|
||||
int? _iso;
|
||||
int? get iso => _$this._iso;
|
||||
set iso(int? iso) => _$this._iso = iso;
|
||||
|
||||
ExifBuilder();
|
||||
|
||||
@@ -229,7 +229,7 @@ class ExifBuilder implements Builder<Exif, ExifBuilder> {
|
||||
}
|
||||
|
||||
@override
|
||||
void update(void Function(ExifBuilder) updates) {
|
||||
void update(void Function(ExifBuilder)? updates) {
|
||||
if (updates != null) updates(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,31 +12,27 @@ import '../serializers.dart';
|
||||
part 'links.g.dart';
|
||||
|
||||
abstract class Links implements Built<Links, LinksBuilder> {
|
||||
factory Links([void Function(LinksBuilder) updates]) = _$Links;
|
||||
factory Links([void Function(LinksBuilder)? updates]) = _$Links;
|
||||
|
||||
Links._();
|
||||
|
||||
@nullable
|
||||
@BuiltValueField(wireName: 'self')
|
||||
String get self;
|
||||
String? get self;
|
||||
|
||||
@nullable
|
||||
@BuiltValueField(wireName: 'html')
|
||||
String get html;
|
||||
String? get html;
|
||||
|
||||
@nullable
|
||||
@BuiltValueField(wireName: 'download')
|
||||
String get download;
|
||||
String? get download;
|
||||
|
||||
@nullable
|
||||
@BuiltValueField(wireName: 'download_location')
|
||||
String get downloadLocation;
|
||||
String? get downloadLocation;
|
||||
|
||||
String toJson() {
|
||||
return json.encode(serializers.serializeWith(Links.serializer, this));
|
||||
}
|
||||
|
||||
static Links fromJson(String jsonString) {
|
||||
static Links? fromJson(String jsonString) {
|
||||
return serializers.deserializeWith(
|
||||
Links.serializer, json.decode(jsonString));
|
||||
}
|
||||
|
||||
@@ -19,10 +19,10 @@ class _$LinksSerializer implements StructuredSerializer<Links> {
|
||||
final String wireName = 'Links';
|
||||
|
||||
@override
|
||||
Iterable<Object> serialize(Serializers serializers, Links object,
|
||||
Iterable<Object?> serialize(Serializers serializers, Links object,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
final result = <Object>[];
|
||||
Object value;
|
||||
final result = <Object?>[];
|
||||
Object? value;
|
||||
value = object.self;
|
||||
if (value != null) {
|
||||
result
|
||||
@@ -55,7 +55,7 @@ class _$LinksSerializer implements StructuredSerializer<Links> {
|
||||
}
|
||||
|
||||
@override
|
||||
Links deserialize(Serializers serializers, Iterable<Object> serialized,
|
||||
Links deserialize(Serializers serializers, Iterable<Object?> serialized,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
final result = new LinksBuilder();
|
||||
|
||||
@@ -63,7 +63,7 @@ class _$LinksSerializer implements StructuredSerializer<Links> {
|
||||
while (iterator.moveNext()) {
|
||||
final key = iterator.current as String;
|
||||
iterator.moveNext();
|
||||
final Object value = iterator.current;
|
||||
final Object? value = iterator.current;
|
||||
switch (key) {
|
||||
case 'self':
|
||||
result.self = serializers.deserialize(value,
|
||||
@@ -90,15 +90,15 @@ class _$LinksSerializer implements StructuredSerializer<Links> {
|
||||
|
||||
class _$Links extends Links {
|
||||
@override
|
||||
final String self;
|
||||
final String? self;
|
||||
@override
|
||||
final String html;
|
||||
final String? html;
|
||||
@override
|
||||
final String download;
|
||||
final String? download;
|
||||
@override
|
||||
final String downloadLocation;
|
||||
final String? downloadLocation;
|
||||
|
||||
factory _$Links([void Function(LinksBuilder) updates]) =>
|
||||
factory _$Links([void Function(LinksBuilder)? updates]) =>
|
||||
(new LinksBuilder()..update(updates)).build();
|
||||
|
||||
_$Links._({this.self, this.html, this.download, this.downloadLocation})
|
||||
@@ -140,23 +140,23 @@ class _$Links extends Links {
|
||||
}
|
||||
|
||||
class LinksBuilder implements Builder<Links, LinksBuilder> {
|
||||
_$Links _$v;
|
||||
_$Links? _$v;
|
||||
|
||||
String _self;
|
||||
String get self => _$this._self;
|
||||
set self(String self) => _$this._self = self;
|
||||
String? _self;
|
||||
String? get self => _$this._self;
|
||||
set self(String? self) => _$this._self = self;
|
||||
|
||||
String _html;
|
||||
String get html => _$this._html;
|
||||
set html(String html) => _$this._html = html;
|
||||
String? _html;
|
||||
String? get html => _$this._html;
|
||||
set html(String? html) => _$this._html = html;
|
||||
|
||||
String _download;
|
||||
String get download => _$this._download;
|
||||
set download(String download) => _$this._download = download;
|
||||
String? _download;
|
||||
String? get download => _$this._download;
|
||||
set download(String? download) => _$this._download = download;
|
||||
|
||||
String _downloadLocation;
|
||||
String get downloadLocation => _$this._downloadLocation;
|
||||
set downloadLocation(String downloadLocation) =>
|
||||
String? _downloadLocation;
|
||||
String? get downloadLocation => _$this._downloadLocation;
|
||||
set downloadLocation(String? downloadLocation) =>
|
||||
_$this._downloadLocation = downloadLocation;
|
||||
|
||||
LinksBuilder();
|
||||
@@ -180,7 +180,7 @@ class LinksBuilder implements Builder<Links, LinksBuilder> {
|
||||
}
|
||||
|
||||
@override
|
||||
void update(void Function(LinksBuilder) updates) {
|
||||
void update(void Function(LinksBuilder)? updates) {
|
||||
if (updates != null) updates(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -13,27 +13,24 @@ import 'position.dart';
|
||||
part 'location.g.dart';
|
||||
|
||||
abstract class Location implements Built<Location, LocationBuilder> {
|
||||
factory Location([void Function(LocationBuilder) updates]) = _$Location;
|
||||
factory Location([void Function(LocationBuilder)? updates]) = _$Location;
|
||||
|
||||
Location._();
|
||||
|
||||
@nullable
|
||||
@BuiltValueField(wireName: 'city')
|
||||
String get city;
|
||||
String? get city;
|
||||
|
||||
@nullable
|
||||
@BuiltValueField(wireName: 'country')
|
||||
String get country;
|
||||
String? get country;
|
||||
|
||||
@nullable
|
||||
@BuiltValueField(wireName: 'position')
|
||||
Position get position;
|
||||
Position? get position;
|
||||
|
||||
String toJson() {
|
||||
return json.encode(serializers.serializeWith(Location.serializer, this));
|
||||
}
|
||||
|
||||
static Location fromJson(String jsonString) {
|
||||
static Location? fromJson(String jsonString) {
|
||||
return serializers.deserializeWith(
|
||||
Location.serializer, json.decode(jsonString));
|
||||
}
|
||||
|
||||
@@ -19,10 +19,10 @@ class _$LocationSerializer implements StructuredSerializer<Location> {
|
||||
final String wireName = 'Location';
|
||||
|
||||
@override
|
||||
Iterable<Object> serialize(Serializers serializers, Location object,
|
||||
Iterable<Object?> serialize(Serializers serializers, Location object,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
final result = <Object>[];
|
||||
Object value;
|
||||
final result = <Object?>[];
|
||||
Object? value;
|
||||
value = object.city;
|
||||
if (value != null) {
|
||||
result
|
||||
@@ -48,7 +48,7 @@ class _$LocationSerializer implements StructuredSerializer<Location> {
|
||||
}
|
||||
|
||||
@override
|
||||
Location deserialize(Serializers serializers, Iterable<Object> serialized,
|
||||
Location deserialize(Serializers serializers, Iterable<Object?> serialized,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
final result = new LocationBuilder();
|
||||
|
||||
@@ -56,7 +56,7 @@ class _$LocationSerializer implements StructuredSerializer<Location> {
|
||||
while (iterator.moveNext()) {
|
||||
final key = iterator.current as String;
|
||||
iterator.moveNext();
|
||||
final Object value = iterator.current;
|
||||
final Object? value = iterator.current;
|
||||
switch (key) {
|
||||
case 'city':
|
||||
result.city = serializers.deserialize(value,
|
||||
@@ -68,7 +68,7 @@ class _$LocationSerializer implements StructuredSerializer<Location> {
|
||||
break;
|
||||
case 'position':
|
||||
result.position.replace(serializers.deserialize(value,
|
||||
specifiedType: const FullType(Position)) as Position);
|
||||
specifiedType: const FullType(Position))! as Position);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -79,13 +79,13 @@ class _$LocationSerializer implements StructuredSerializer<Location> {
|
||||
|
||||
class _$Location extends Location {
|
||||
@override
|
||||
final String city;
|
||||
final String? city;
|
||||
@override
|
||||
final String country;
|
||||
final String? country;
|
||||
@override
|
||||
final Position position;
|
||||
final Position? position;
|
||||
|
||||
factory _$Location([void Function(LocationBuilder) updates]) =>
|
||||
factory _$Location([void Function(LocationBuilder)? updates]) =>
|
||||
(new LocationBuilder()..update(updates)).build();
|
||||
|
||||
_$Location._({this.city, this.country, this.position}) : super._();
|
||||
@@ -123,19 +123,19 @@ class _$Location extends Location {
|
||||
}
|
||||
|
||||
class LocationBuilder implements Builder<Location, LocationBuilder> {
|
||||
_$Location _$v;
|
||||
_$Location? _$v;
|
||||
|
||||
String _city;
|
||||
String get city => _$this._city;
|
||||
set city(String city) => _$this._city = city;
|
||||
String? _city;
|
||||
String? get city => _$this._city;
|
||||
set city(String? city) => _$this._city = city;
|
||||
|
||||
String _country;
|
||||
String get country => _$this._country;
|
||||
set country(String country) => _$this._country = country;
|
||||
String? _country;
|
||||
String? get country => _$this._country;
|
||||
set country(String? country) => _$this._country = country;
|
||||
|
||||
PositionBuilder _position;
|
||||
PositionBuilder? _position;
|
||||
PositionBuilder get position => _$this._position ??= new PositionBuilder();
|
||||
set position(PositionBuilder position) => _$this._position = position;
|
||||
set position(PositionBuilder? position) => _$this._position = position;
|
||||
|
||||
LocationBuilder();
|
||||
|
||||
@@ -157,7 +157,7 @@ class LocationBuilder implements Builder<Location, LocationBuilder> {
|
||||
}
|
||||
|
||||
@override
|
||||
void update(void Function(LocationBuilder) updates) {
|
||||
void update(void Function(LocationBuilder)? updates) {
|
||||
if (updates != null) updates(this);
|
||||
}
|
||||
|
||||
@@ -169,7 +169,7 @@ class LocationBuilder implements Builder<Location, LocationBuilder> {
|
||||
new _$Location._(
|
||||
city: city, country: country, position: _position?.build());
|
||||
} catch (_) {
|
||||
String _$failedField;
|
||||
late String _$failedField;
|
||||
try {
|
||||
_$failedField = 'position';
|
||||
_position?.build();
|
||||
|
||||
@@ -20,82 +20,66 @@ import 'user.dart';
|
||||
part 'photo.g.dart';
|
||||
|
||||
abstract class Photo implements Built<Photo, PhotoBuilder> {
|
||||
factory Photo([void Function(PhotoBuilder) updates]) = _$Photo;
|
||||
factory Photo([void Function(PhotoBuilder)? updates]) = _$Photo;
|
||||
|
||||
Photo._();
|
||||
|
||||
@BuiltValueField(wireName: 'id')
|
||||
String get id;
|
||||
|
||||
@nullable
|
||||
@BuiltValueField(wireName: 'created_at')
|
||||
String get createdAt;
|
||||
String? get createdAt;
|
||||
|
||||
@nullable
|
||||
@BuiltValueField(wireName: 'updated_at')
|
||||
String get updatedAt;
|
||||
String? get updatedAt;
|
||||
|
||||
@nullable
|
||||
@BuiltValueField(wireName: 'width')
|
||||
int get width;
|
||||
int? get width;
|
||||
|
||||
@nullable
|
||||
@BuiltValueField(wireName: 'height')
|
||||
int get height;
|
||||
int? get height;
|
||||
|
||||
@nullable
|
||||
@BuiltValueField(wireName: 'color')
|
||||
String get color;
|
||||
String? get color;
|
||||
|
||||
@nullable
|
||||
@BuiltValueField(wireName: 'downloads')
|
||||
int get downloads;
|
||||
int? get downloads;
|
||||
|
||||
@nullable
|
||||
@BuiltValueField(wireName: 'likes')
|
||||
int get likes;
|
||||
int? get likes;
|
||||
|
||||
@nullable
|
||||
@BuiltValueField(wireName: 'liked_by_user')
|
||||
bool get likedByUser;
|
||||
bool? get likedByUser;
|
||||
|
||||
@nullable
|
||||
@BuiltValueField(wireName: 'description')
|
||||
String get description;
|
||||
String? get description;
|
||||
|
||||
@nullable
|
||||
@BuiltValueField(wireName: 'exif')
|
||||
Exif get exif;
|
||||
Exif? get exif;
|
||||
|
||||
@nullable
|
||||
@BuiltValueField(wireName: 'location')
|
||||
Location get location;
|
||||
Location? get location;
|
||||
|
||||
@nullable
|
||||
@BuiltValueField(wireName: 'tags')
|
||||
BuiltList<Tags> get tags;
|
||||
BuiltList<Tags>? get tags;
|
||||
|
||||
@nullable
|
||||
@BuiltValueField(wireName: 'current_user_collections')
|
||||
BuiltList<CurrentUserCollections> get currentUserCollections;
|
||||
BuiltList<CurrentUserCollections>? get currentUserCollections;
|
||||
|
||||
@nullable
|
||||
@BuiltValueField(wireName: 'urls')
|
||||
Urls get urls;
|
||||
Urls? get urls;
|
||||
|
||||
@nullable
|
||||
@BuiltValueField(wireName: 'links')
|
||||
Links get links;
|
||||
Links? get links;
|
||||
|
||||
@nullable
|
||||
@BuiltValueField(wireName: 'user')
|
||||
User get user;
|
||||
User? get user;
|
||||
|
||||
String toJson() {
|
||||
return json.encode(serializers.serializeWith(Photo.serializer, this));
|
||||
}
|
||||
|
||||
static Photo fromJson(String jsonString) {
|
||||
static Photo? fromJson(String jsonString) {
|
||||
return serializers.deserializeWith(
|
||||
Photo.serializer, json.decode(jsonString));
|
||||
}
|
||||
|
||||
@@ -19,13 +19,13 @@ class _$PhotoSerializer implements StructuredSerializer<Photo> {
|
||||
final String wireName = 'Photo';
|
||||
|
||||
@override
|
||||
Iterable<Object> serialize(Serializers serializers, Photo object,
|
||||
Iterable<Object?> serialize(Serializers serializers, Photo object,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
final result = <Object>[
|
||||
final result = <Object?>[
|
||||
'id',
|
||||
serializers.serialize(object.id, specifiedType: const FullType(String)),
|
||||
];
|
||||
Object value;
|
||||
Object? value;
|
||||
value = object.createdAt;
|
||||
if (value != null) {
|
||||
result
|
||||
@@ -140,7 +140,7 @@ class _$PhotoSerializer implements StructuredSerializer<Photo> {
|
||||
}
|
||||
|
||||
@override
|
||||
Photo deserialize(Serializers serializers, Iterable<Object> serialized,
|
||||
Photo deserialize(Serializers serializers, Iterable<Object?> serialized,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
final result = new PhotoBuilder();
|
||||
|
||||
@@ -148,7 +148,7 @@ class _$PhotoSerializer implements StructuredSerializer<Photo> {
|
||||
while (iterator.moveNext()) {
|
||||
final key = iterator.current as String;
|
||||
iterator.moveNext();
|
||||
final Object value = iterator.current;
|
||||
final Object? value = iterator.current;
|
||||
switch (key) {
|
||||
case 'id':
|
||||
result.id = serializers.deserialize(value,
|
||||
@@ -192,35 +192,35 @@ class _$PhotoSerializer implements StructuredSerializer<Photo> {
|
||||
break;
|
||||
case 'exif':
|
||||
result.exif.replace(serializers.deserialize(value,
|
||||
specifiedType: const FullType(Exif)) as Exif);
|
||||
specifiedType: const FullType(Exif))! as Exif);
|
||||
break;
|
||||
case 'location':
|
||||
result.location.replace(serializers.deserialize(value,
|
||||
specifiedType: const FullType(Location)) as Location);
|
||||
specifiedType: const FullType(Location))! as Location);
|
||||
break;
|
||||
case 'tags':
|
||||
result.tags.replace(serializers.deserialize(value,
|
||||
specifiedType:
|
||||
const FullType(BuiltList, const [const FullType(Tags)]))
|
||||
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>);
|
||||
]))! as BuiltList<Object>);
|
||||
break;
|
||||
case 'urls':
|
||||
result.urls.replace(serializers.deserialize(value,
|
||||
specifiedType: const FullType(Urls)) as Urls);
|
||||
specifiedType: const FullType(Urls))! as Urls);
|
||||
break;
|
||||
case 'links':
|
||||
result.links.replace(serializers.deserialize(value,
|
||||
specifiedType: const FullType(Links)) as Links);
|
||||
specifiedType: const FullType(Links))! as Links);
|
||||
break;
|
||||
case 'user':
|
||||
result.user.replace(serializers.deserialize(value,
|
||||
specifiedType: const FullType(User)) as User);
|
||||
specifiedType: const FullType(User))! as User);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -233,43 +233,43 @@ class _$Photo extends Photo {
|
||||
@override
|
||||
final String id;
|
||||
@override
|
||||
final String createdAt;
|
||||
final String? createdAt;
|
||||
@override
|
||||
final String updatedAt;
|
||||
final String? updatedAt;
|
||||
@override
|
||||
final int width;
|
||||
final int? width;
|
||||
@override
|
||||
final int height;
|
||||
final int? height;
|
||||
@override
|
||||
final String color;
|
||||
final String? color;
|
||||
@override
|
||||
final int downloads;
|
||||
final int? downloads;
|
||||
@override
|
||||
final int likes;
|
||||
final int? likes;
|
||||
@override
|
||||
final bool likedByUser;
|
||||
final bool? likedByUser;
|
||||
@override
|
||||
final String description;
|
||||
final String? description;
|
||||
@override
|
||||
final Exif exif;
|
||||
final Exif? exif;
|
||||
@override
|
||||
final Location location;
|
||||
final Location? location;
|
||||
@override
|
||||
final BuiltList<Tags> tags;
|
||||
final BuiltList<Tags>? tags;
|
||||
@override
|
||||
final BuiltList<CurrentUserCollections> currentUserCollections;
|
||||
final BuiltList<CurrentUserCollections>? currentUserCollections;
|
||||
@override
|
||||
final Urls urls;
|
||||
final Urls? urls;
|
||||
@override
|
||||
final Links links;
|
||||
final Links? links;
|
||||
@override
|
||||
final User user;
|
||||
final User? user;
|
||||
|
||||
factory _$Photo([void Function(PhotoBuilder) updates]) =>
|
||||
factory _$Photo([void Function(PhotoBuilder)? updates]) =>
|
||||
(new PhotoBuilder()..update(updates)).build();
|
||||
|
||||
_$Photo._(
|
||||
{this.id,
|
||||
{required this.id,
|
||||
this.createdAt,
|
||||
this.updatedAt,
|
||||
this.width,
|
||||
@@ -387,79 +387,79 @@ class _$Photo extends Photo {
|
||||
}
|
||||
|
||||
class PhotoBuilder implements Builder<Photo, PhotoBuilder> {
|
||||
_$Photo _$v;
|
||||
_$Photo? _$v;
|
||||
|
||||
String _id;
|
||||
String get id => _$this._id;
|
||||
set id(String id) => _$this._id = id;
|
||||
String? _id;
|
||||
String? get id => _$this._id;
|
||||
set id(String? id) => _$this._id = id;
|
||||
|
||||
String _createdAt;
|
||||
String get createdAt => _$this._createdAt;
|
||||
set createdAt(String createdAt) => _$this._createdAt = createdAt;
|
||||
String? _createdAt;
|
||||
String? get createdAt => _$this._createdAt;
|
||||
set createdAt(String? createdAt) => _$this._createdAt = createdAt;
|
||||
|
||||
String _updatedAt;
|
||||
String get updatedAt => _$this._updatedAt;
|
||||
set updatedAt(String updatedAt) => _$this._updatedAt = updatedAt;
|
||||
String? _updatedAt;
|
||||
String? get updatedAt => _$this._updatedAt;
|
||||
set updatedAt(String? updatedAt) => _$this._updatedAt = updatedAt;
|
||||
|
||||
int _width;
|
||||
int get width => _$this._width;
|
||||
set width(int width) => _$this._width = width;
|
||||
int? _width;
|
||||
int? get width => _$this._width;
|
||||
set width(int? width) => _$this._width = width;
|
||||
|
||||
int _height;
|
||||
int get height => _$this._height;
|
||||
set height(int height) => _$this._height = height;
|
||||
int? _height;
|
||||
int? get height => _$this._height;
|
||||
set height(int? height) => _$this._height = height;
|
||||
|
||||
String _color;
|
||||
String get color => _$this._color;
|
||||
set color(String color) => _$this._color = color;
|
||||
String? _color;
|
||||
String? get color => _$this._color;
|
||||
set color(String? color) => _$this._color = color;
|
||||
|
||||
int _downloads;
|
||||
int get downloads => _$this._downloads;
|
||||
set downloads(int downloads) => _$this._downloads = downloads;
|
||||
int? _downloads;
|
||||
int? get downloads => _$this._downloads;
|
||||
set downloads(int? downloads) => _$this._downloads = downloads;
|
||||
|
||||
int _likes;
|
||||
int get likes => _$this._likes;
|
||||
set likes(int likes) => _$this._likes = likes;
|
||||
int? _likes;
|
||||
int? get likes => _$this._likes;
|
||||
set likes(int? likes) => _$this._likes = likes;
|
||||
|
||||
bool _likedByUser;
|
||||
bool get likedByUser => _$this._likedByUser;
|
||||
set likedByUser(bool likedByUser) => _$this._likedByUser = likedByUser;
|
||||
bool? _likedByUser;
|
||||
bool? get likedByUser => _$this._likedByUser;
|
||||
set likedByUser(bool? likedByUser) => _$this._likedByUser = likedByUser;
|
||||
|
||||
String _description;
|
||||
String get description => _$this._description;
|
||||
set description(String description) => _$this._description = description;
|
||||
String? _description;
|
||||
String? get description => _$this._description;
|
||||
set description(String? description) => _$this._description = description;
|
||||
|
||||
ExifBuilder _exif;
|
||||
ExifBuilder? _exif;
|
||||
ExifBuilder get exif => _$this._exif ??= new ExifBuilder();
|
||||
set exif(ExifBuilder exif) => _$this._exif = exif;
|
||||
set exif(ExifBuilder? exif) => _$this._exif = exif;
|
||||
|
||||
LocationBuilder _location;
|
||||
LocationBuilder? _location;
|
||||
LocationBuilder get location => _$this._location ??= new LocationBuilder();
|
||||
set location(LocationBuilder location) => _$this._location = location;
|
||||
set location(LocationBuilder? location) => _$this._location = location;
|
||||
|
||||
ListBuilder<Tags> _tags;
|
||||
ListBuilder<Tags>? _tags;
|
||||
ListBuilder<Tags> get tags => _$this._tags ??= new ListBuilder<Tags>();
|
||||
set tags(ListBuilder<Tags> tags) => _$this._tags = tags;
|
||||
set tags(ListBuilder<Tags>? tags) => _$this._tags = tags;
|
||||
|
||||
ListBuilder<CurrentUserCollections> _currentUserCollections;
|
||||
ListBuilder<CurrentUserCollections>? _currentUserCollections;
|
||||
ListBuilder<CurrentUserCollections> get currentUserCollections =>
|
||||
_$this._currentUserCollections ??=
|
||||
new ListBuilder<CurrentUserCollections>();
|
||||
set currentUserCollections(
|
||||
ListBuilder<CurrentUserCollections> currentUserCollections) =>
|
||||
ListBuilder<CurrentUserCollections>? currentUserCollections) =>
|
||||
_$this._currentUserCollections = currentUserCollections;
|
||||
|
||||
UrlsBuilder _urls;
|
||||
UrlsBuilder? _urls;
|
||||
UrlsBuilder get urls => _$this._urls ??= new UrlsBuilder();
|
||||
set urls(UrlsBuilder urls) => _$this._urls = urls;
|
||||
set urls(UrlsBuilder? urls) => _$this._urls = urls;
|
||||
|
||||
LinksBuilder _links;
|
||||
LinksBuilder? _links;
|
||||
LinksBuilder get links => _$this._links ??= new LinksBuilder();
|
||||
set links(LinksBuilder links) => _$this._links = links;
|
||||
set links(LinksBuilder? links) => _$this._links = links;
|
||||
|
||||
UserBuilder _user;
|
||||
UserBuilder? _user;
|
||||
UserBuilder get user => _$this._user ??= new UserBuilder();
|
||||
set user(UserBuilder user) => _$this._user = user;
|
||||
set user(UserBuilder? user) => _$this._user = user;
|
||||
|
||||
PhotoBuilder();
|
||||
|
||||
@@ -495,7 +495,7 @@ class PhotoBuilder implements Builder<Photo, PhotoBuilder> {
|
||||
}
|
||||
|
||||
@override
|
||||
void update(void Function(PhotoBuilder) updates) {
|
||||
void update(void Function(PhotoBuilder)? updates) {
|
||||
if (updates != null) updates(this);
|
||||
}
|
||||
|
||||
@@ -523,7 +523,7 @@ class PhotoBuilder implements Builder<Photo, PhotoBuilder> {
|
||||
links: _links?.build(),
|
||||
user: _user?.build());
|
||||
} catch (_) {
|
||||
String _$failedField;
|
||||
late String _$failedField;
|
||||
try {
|
||||
_$failedField = 'exif';
|
||||
_exif?.build();
|
||||
|
||||
@@ -12,7 +12,7 @@ import '../serializers.dart';
|
||||
part 'position.g.dart';
|
||||
|
||||
abstract class Position implements Built<Position, PositionBuilder> {
|
||||
factory Position([void Function(PositionBuilder) updates]) = _$Position;
|
||||
factory Position([void Function(PositionBuilder)? updates]) = _$Position;
|
||||
|
||||
Position._();
|
||||
|
||||
@@ -26,7 +26,7 @@ abstract class Position implements Built<Position, PositionBuilder> {
|
||||
return json.encode(serializers.serializeWith(Position.serializer, this));
|
||||
}
|
||||
|
||||
static Position fromJson(String jsonString) {
|
||||
static Position? fromJson(String jsonString) {
|
||||
return serializers.deserializeWith(
|
||||
Position.serializer, json.decode(jsonString));
|
||||
}
|
||||
|
||||
@@ -19,9 +19,9 @@ class _$PositionSerializer implements StructuredSerializer<Position> {
|
||||
final String wireName = 'Position';
|
||||
|
||||
@override
|
||||
Iterable<Object> serialize(Serializers serializers, Position object,
|
||||
Iterable<Object?> serialize(Serializers serializers, Position object,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
final result = <Object>[
|
||||
final result = <Object?>[
|
||||
'latitude',
|
||||
serializers.serialize(object.latitude,
|
||||
specifiedType: const FullType(double)),
|
||||
@@ -34,7 +34,7 @@ class _$PositionSerializer implements StructuredSerializer<Position> {
|
||||
}
|
||||
|
||||
@override
|
||||
Position deserialize(Serializers serializers, Iterable<Object> serialized,
|
||||
Position deserialize(Serializers serializers, Iterable<Object?> serialized,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
final result = new PositionBuilder();
|
||||
|
||||
@@ -42,7 +42,7 @@ class _$PositionSerializer implements StructuredSerializer<Position> {
|
||||
while (iterator.moveNext()) {
|
||||
final key = iterator.current as String;
|
||||
iterator.moveNext();
|
||||
final Object value = iterator.current;
|
||||
final Object? value = iterator.current;
|
||||
switch (key) {
|
||||
case 'latitude':
|
||||
result.latitude = serializers.deserialize(value,
|
||||
@@ -65,10 +65,10 @@ class _$Position extends Position {
|
||||
@override
|
||||
final double longitude;
|
||||
|
||||
factory _$Position([void Function(PositionBuilder) updates]) =>
|
||||
factory _$Position([void Function(PositionBuilder)? updates]) =>
|
||||
(new PositionBuilder()..update(updates)).build();
|
||||
|
||||
_$Position._({this.latitude, this.longitude}) : super._() {
|
||||
_$Position._({required this.latitude, required this.longitude}) : super._() {
|
||||
BuiltValueNullFieldError.checkNotNull(latitude, 'Position', 'latitude');
|
||||
BuiltValueNullFieldError.checkNotNull(longitude, 'Position', 'longitude');
|
||||
}
|
||||
@@ -103,15 +103,15 @@ class _$Position extends Position {
|
||||
}
|
||||
|
||||
class PositionBuilder implements Builder<Position, PositionBuilder> {
|
||||
_$Position _$v;
|
||||
_$Position? _$v;
|
||||
|
||||
double _latitude;
|
||||
double get latitude => _$this._latitude;
|
||||
set latitude(double latitude) => _$this._latitude = latitude;
|
||||
double? _latitude;
|
||||
double? get latitude => _$this._latitude;
|
||||
set latitude(double? latitude) => _$this._latitude = latitude;
|
||||
|
||||
double _longitude;
|
||||
double get longitude => _$this._longitude;
|
||||
set longitude(double longitude) => _$this._longitude = longitude;
|
||||
double? _longitude;
|
||||
double? get longitude => _$this._longitude;
|
||||
set longitude(double? longitude) => _$this._longitude = longitude;
|
||||
|
||||
PositionBuilder();
|
||||
|
||||
@@ -132,7 +132,7 @@ class PositionBuilder implements Builder<Position, PositionBuilder> {
|
||||
}
|
||||
|
||||
@override
|
||||
void update(void Function(PositionBuilder) updates) {
|
||||
void update(void Function(PositionBuilder)? updates) {
|
||||
if (updates != null) updates(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,18 +16,16 @@ part 'search_photos_response.g.dart';
|
||||
abstract class SearchPhotosResponse
|
||||
implements Built<SearchPhotosResponse, SearchPhotosResponseBuilder> {
|
||||
factory SearchPhotosResponse(
|
||||
[void Function(SearchPhotosResponseBuilder) updates]) =
|
||||
[void Function(SearchPhotosResponseBuilder)? updates]) =
|
||||
_$SearchPhotosResponse;
|
||||
|
||||
SearchPhotosResponse._();
|
||||
|
||||
@nullable
|
||||
@BuiltValueField(wireName: 'total')
|
||||
int get total;
|
||||
int? get total;
|
||||
|
||||
@nullable
|
||||
@BuiltValueField(wireName: 'total_pages')
|
||||
int get totalPages;
|
||||
int? get totalPages;
|
||||
|
||||
@BuiltValueField(wireName: 'results')
|
||||
BuiltList<Photo> get results;
|
||||
@@ -37,7 +35,7 @@ abstract class SearchPhotosResponse
|
||||
serializers.serializeWith(SearchPhotosResponse.serializer, this));
|
||||
}
|
||||
|
||||
static SearchPhotosResponse fromJson(String jsonString) {
|
||||
static SearchPhotosResponse? fromJson(String jsonString) {
|
||||
return serializers.deserializeWith(
|
||||
SearchPhotosResponse.serializer, json.decode(jsonString));
|
||||
}
|
||||
|
||||
@@ -24,16 +24,16 @@ class _$SearchPhotosResponseSerializer
|
||||
final String wireName = 'SearchPhotosResponse';
|
||||
|
||||
@override
|
||||
Iterable<Object> serialize(
|
||||
Iterable<Object?> serialize(
|
||||
Serializers serializers, SearchPhotosResponse object,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
final result = <Object>[
|
||||
final result = <Object?>[
|
||||
'results',
|
||||
serializers.serialize(object.results,
|
||||
specifiedType:
|
||||
const FullType(BuiltList, const [const FullType(Photo)])),
|
||||
];
|
||||
Object value;
|
||||
Object? value;
|
||||
value = object.total;
|
||||
if (value != null) {
|
||||
result
|
||||
@@ -51,7 +51,7 @@ class _$SearchPhotosResponseSerializer
|
||||
|
||||
@override
|
||||
SearchPhotosResponse deserialize(
|
||||
Serializers serializers, Iterable<Object> serialized,
|
||||
Serializers serializers, Iterable<Object?> serialized,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
final result = new SearchPhotosResponseBuilder();
|
||||
|
||||
@@ -59,7 +59,7 @@ class _$SearchPhotosResponseSerializer
|
||||
while (iterator.moveNext()) {
|
||||
final key = iterator.current as String;
|
||||
iterator.moveNext();
|
||||
final Object value = iterator.current;
|
||||
final Object? value = iterator.current;
|
||||
switch (key) {
|
||||
case 'total':
|
||||
result.total = serializers.deserialize(value,
|
||||
@@ -72,7 +72,7 @@ class _$SearchPhotosResponseSerializer
|
||||
case 'results':
|
||||
result.results.replace(serializers.deserialize(value,
|
||||
specifiedType:
|
||||
const FullType(BuiltList, const [const FullType(Photo)]))
|
||||
const FullType(BuiltList, const [const FullType(Photo)]))!
|
||||
as BuiltList<Object>);
|
||||
break;
|
||||
}
|
||||
@@ -84,17 +84,17 @@ class _$SearchPhotosResponseSerializer
|
||||
|
||||
class _$SearchPhotosResponse extends SearchPhotosResponse {
|
||||
@override
|
||||
final int total;
|
||||
final int? total;
|
||||
@override
|
||||
final int totalPages;
|
||||
final int? totalPages;
|
||||
@override
|
||||
final BuiltList<Photo> results;
|
||||
|
||||
factory _$SearchPhotosResponse(
|
||||
[void Function(SearchPhotosResponseBuilder) updates]) =>
|
||||
[void Function(SearchPhotosResponseBuilder)? updates]) =>
|
||||
(new SearchPhotosResponseBuilder()..update(updates)).build();
|
||||
|
||||
_$SearchPhotosResponse._({this.total, this.totalPages, this.results})
|
||||
_$SearchPhotosResponse._({this.total, this.totalPages, required this.results})
|
||||
: super._() {
|
||||
BuiltValueNullFieldError.checkNotNull(
|
||||
results, 'SearchPhotosResponse', 'results');
|
||||
@@ -136,20 +136,20 @@ class _$SearchPhotosResponse extends SearchPhotosResponse {
|
||||
|
||||
class SearchPhotosResponseBuilder
|
||||
implements Builder<SearchPhotosResponse, SearchPhotosResponseBuilder> {
|
||||
_$SearchPhotosResponse _$v;
|
||||
_$SearchPhotosResponse? _$v;
|
||||
|
||||
int _total;
|
||||
int get total => _$this._total;
|
||||
set total(int total) => _$this._total = total;
|
||||
int? _total;
|
||||
int? get total => _$this._total;
|
||||
set total(int? total) => _$this._total = total;
|
||||
|
||||
int _totalPages;
|
||||
int get totalPages => _$this._totalPages;
|
||||
set totalPages(int totalPages) => _$this._totalPages = totalPages;
|
||||
int? _totalPages;
|
||||
int? get totalPages => _$this._totalPages;
|
||||
set totalPages(int? totalPages) => _$this._totalPages = totalPages;
|
||||
|
||||
ListBuilder<Photo> _results;
|
||||
ListBuilder<Photo>? _results;
|
||||
ListBuilder<Photo> get results =>
|
||||
_$this._results ??= new ListBuilder<Photo>();
|
||||
set results(ListBuilder<Photo> results) => _$this._results = results;
|
||||
set results(ListBuilder<Photo>? results) => _$this._results = results;
|
||||
|
||||
SearchPhotosResponseBuilder();
|
||||
|
||||
@@ -171,7 +171,7 @@ class SearchPhotosResponseBuilder
|
||||
}
|
||||
|
||||
@override
|
||||
void update(void Function(SearchPhotosResponseBuilder) updates) {
|
||||
void update(void Function(SearchPhotosResponseBuilder)? updates) {
|
||||
if (updates != null) updates(this);
|
||||
}
|
||||
|
||||
@@ -183,7 +183,7 @@ class SearchPhotosResponseBuilder
|
||||
new _$SearchPhotosResponse._(
|
||||
total: total, totalPages: totalPages, results: results.build());
|
||||
} catch (_) {
|
||||
String _$failedField;
|
||||
late String _$failedField;
|
||||
try {
|
||||
_$failedField = 'results';
|
||||
results.build();
|
||||
|
||||
@@ -12,7 +12,7 @@ import '../serializers.dart';
|
||||
part 'tags.g.dart';
|
||||
|
||||
abstract class Tags implements Built<Tags, TagsBuilder> {
|
||||
factory Tags([void Function(TagsBuilder) updates]) = _$Tags;
|
||||
factory Tags([void Function(TagsBuilder)? updates]) = _$Tags;
|
||||
|
||||
Tags._();
|
||||
|
||||
@@ -23,7 +23,7 @@ abstract class Tags implements Built<Tags, TagsBuilder> {
|
||||
return json.encode(serializers.serializeWith(Tags.serializer, this));
|
||||
}
|
||||
|
||||
static Tags fromJson(String jsonString) {
|
||||
static Tags? fromJson(String jsonString) {
|
||||
return serializers.deserializeWith(
|
||||
Tags.serializer, json.decode(jsonString));
|
||||
}
|
||||
|
||||
@@ -19,9 +19,9 @@ class _$TagsSerializer implements StructuredSerializer<Tags> {
|
||||
final String wireName = 'Tags';
|
||||
|
||||
@override
|
||||
Iterable<Object> serialize(Serializers serializers, Tags object,
|
||||
Iterable<Object?> serialize(Serializers serializers, Tags object,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
final result = <Object>[
|
||||
final result = <Object?>[
|
||||
'title',
|
||||
serializers.serialize(object.title,
|
||||
specifiedType: const FullType(String)),
|
||||
@@ -31,7 +31,7 @@ class _$TagsSerializer implements StructuredSerializer<Tags> {
|
||||
}
|
||||
|
||||
@override
|
||||
Tags deserialize(Serializers serializers, Iterable<Object> serialized,
|
||||
Tags deserialize(Serializers serializers, Iterable<Object?> serialized,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
final result = new TagsBuilder();
|
||||
|
||||
@@ -39,7 +39,7 @@ class _$TagsSerializer implements StructuredSerializer<Tags> {
|
||||
while (iterator.moveNext()) {
|
||||
final key = iterator.current as String;
|
||||
iterator.moveNext();
|
||||
final Object value = iterator.current;
|
||||
final Object? value = iterator.current;
|
||||
switch (key) {
|
||||
case 'title':
|
||||
result.title = serializers.deserialize(value,
|
||||
@@ -56,10 +56,10 @@ class _$Tags extends Tags {
|
||||
@override
|
||||
final String title;
|
||||
|
||||
factory _$Tags([void Function(TagsBuilder) updates]) =>
|
||||
factory _$Tags([void Function(TagsBuilder)? updates]) =>
|
||||
(new TagsBuilder()..update(updates)).build();
|
||||
|
||||
_$Tags._({this.title}) : super._() {
|
||||
_$Tags._({required this.title}) : super._() {
|
||||
BuiltValueNullFieldError.checkNotNull(title, 'Tags', 'title');
|
||||
}
|
||||
|
||||
@@ -89,11 +89,11 @@ class _$Tags extends Tags {
|
||||
}
|
||||
|
||||
class TagsBuilder implements Builder<Tags, TagsBuilder> {
|
||||
_$Tags _$v;
|
||||
_$Tags? _$v;
|
||||
|
||||
String _title;
|
||||
String get title => _$this._title;
|
||||
set title(String title) => _$this._title = title;
|
||||
String? _title;
|
||||
String? get title => _$this._title;
|
||||
set title(String? title) => _$this._title = title;
|
||||
|
||||
TagsBuilder();
|
||||
|
||||
@@ -113,7 +113,7 @@ class TagsBuilder implements Builder<Tags, TagsBuilder> {
|
||||
}
|
||||
|
||||
@override
|
||||
void update(void Function(TagsBuilder) updates) {
|
||||
void update(void Function(TagsBuilder)? updates) {
|
||||
if (updates != null) updates(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ import 'dart:typed_data';
|
||||
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:pedantic/pedantic.dart';
|
||||
|
||||
import 'api_error.dart';
|
||||
@@ -21,30 +20,28 @@ final _unsplashBaseUrl = Uri.parse('https://api.unsplash.com/');
|
||||
/// requests to the Unsplash API.
|
||||
class Unsplash {
|
||||
Unsplash({
|
||||
@required String accessKey,
|
||||
http.BaseClient httpClient,
|
||||
}) : assert(accessKey != null, 'accessKey must not be null'),
|
||||
_accessKey = accessKey,
|
||||
required String accessKey,
|
||||
http.BaseClient? httpClient,
|
||||
}) : _accessKey = accessKey,
|
||||
_client = httpClient ?? http.Client();
|
||||
|
||||
final String _accessKey;
|
||||
final http.Client _client;
|
||||
final _log = Logger('Unsplash');
|
||||
|
||||
Future<SearchPhotosResponse> searchPhotos({
|
||||
@required String query,
|
||||
Future<SearchPhotosResponse?> searchPhotos({
|
||||
required String query,
|
||||
num page = 1,
|
||||
num perPage = 10,
|
||||
List<num> collections = const [],
|
||||
SearchPhotosOrientation orientation,
|
||||
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 != null && collections.isNotEmpty)
|
||||
'collections': '${collections.join(',')}',
|
||||
if (collections.isNotEmpty) 'collections': collections.join(','),
|
||||
if (orientation == SearchPhotosOrientation.landscape)
|
||||
'orientation': 'landscape',
|
||||
if (orientation == SearchPhotosOrientation.portrait)
|
||||
@@ -72,8 +69,8 @@ class Unsplash {
|
||||
if (body is Map &&
|
||||
body['errors'] is List &&
|
||||
body['errors'].isNotEmpty as bool) {
|
||||
final apiError = ApiError.fromJson(response.body);
|
||||
throw UnsplashException(apiError.errors.join(', '));
|
||||
final apiError = ApiError.fromJson(response.body)!;
|
||||
throw UnsplashException(apiError.errors!.join(', '));
|
||||
}
|
||||
|
||||
return SearchPhotosResponse.fromJson(
|
||||
@@ -85,14 +82,14 @@ class Unsplash {
|
||||
// For detail on how downloading photos from Unsplash, please see
|
||||
// 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: {
|
||||
_log.info('GET ${photo.urls!.full}');
|
||||
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: {
|
||||
_log.info('GET ${photo.links!.downloadLocation}');
|
||||
unawaited(http.get(Uri.parse(photo.links!.downloadLocation!), headers: {
|
||||
'Accept-Version': 'v1',
|
||||
'Authorization': 'Client-ID $_accessKey',
|
||||
}));
|
||||
@@ -110,7 +107,7 @@ enum SearchPhotosOrientation {
|
||||
class UnsplashException implements Exception {
|
||||
UnsplashException([this.message]);
|
||||
|
||||
final String message;
|
||||
final String? message;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
|
||||
@@ -12,35 +12,30 @@ import '../serializers.dart';
|
||||
part 'urls.g.dart';
|
||||
|
||||
abstract class Urls implements Built<Urls, UrlsBuilder> {
|
||||
factory Urls([void Function(UrlsBuilder b) updates]) = _$Urls;
|
||||
factory Urls([void Function(UrlsBuilder b)? updates]) = _$Urls;
|
||||
|
||||
Urls._();
|
||||
|
||||
@nullable
|
||||
@BuiltValueField(wireName: 'raw')
|
||||
String get raw;
|
||||
String? get raw;
|
||||
|
||||
@nullable
|
||||
@BuiltValueField(wireName: 'full')
|
||||
String get full;
|
||||
String? get full;
|
||||
|
||||
@nullable
|
||||
@BuiltValueField(wireName: 'regular')
|
||||
String get regular;
|
||||
String? get regular;
|
||||
|
||||
@nullable
|
||||
@BuiltValueField(wireName: 'small')
|
||||
String get small;
|
||||
String? get small;
|
||||
|
||||
@nullable
|
||||
@BuiltValueField(wireName: 'thumb')
|
||||
String get thumb;
|
||||
String? get thumb;
|
||||
|
||||
String toJson() {
|
||||
return json.encode(serializers.serializeWith(Urls.serializer, this));
|
||||
}
|
||||
|
||||
static Urls fromJson(String jsonString) {
|
||||
static Urls? fromJson(String jsonString) {
|
||||
return serializers.deserializeWith(
|
||||
Urls.serializer, json.decode(jsonString));
|
||||
}
|
||||
|
||||
@@ -19,10 +19,10 @@ class _$UrlsSerializer implements StructuredSerializer<Urls> {
|
||||
final String wireName = 'Urls';
|
||||
|
||||
@override
|
||||
Iterable<Object> serialize(Serializers serializers, Urls object,
|
||||
Iterable<Object?> serialize(Serializers serializers, Urls object,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
final result = <Object>[];
|
||||
Object value;
|
||||
final result = <Object?>[];
|
||||
Object? value;
|
||||
value = object.raw;
|
||||
if (value != null) {
|
||||
result
|
||||
@@ -62,7 +62,7 @@ class _$UrlsSerializer implements StructuredSerializer<Urls> {
|
||||
}
|
||||
|
||||
@override
|
||||
Urls deserialize(Serializers serializers, Iterable<Object> serialized,
|
||||
Urls deserialize(Serializers serializers, Iterable<Object?> serialized,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
final result = new UrlsBuilder();
|
||||
|
||||
@@ -70,7 +70,7 @@ class _$UrlsSerializer implements StructuredSerializer<Urls> {
|
||||
while (iterator.moveNext()) {
|
||||
final key = iterator.current as String;
|
||||
iterator.moveNext();
|
||||
final Object value = iterator.current;
|
||||
final Object? value = iterator.current;
|
||||
switch (key) {
|
||||
case 'raw':
|
||||
result.raw = serializers.deserialize(value,
|
||||
@@ -101,17 +101,17 @@ class _$UrlsSerializer implements StructuredSerializer<Urls> {
|
||||
|
||||
class _$Urls extends Urls {
|
||||
@override
|
||||
final String raw;
|
||||
final String? raw;
|
||||
@override
|
||||
final String full;
|
||||
final String? full;
|
||||
@override
|
||||
final String regular;
|
||||
final String? regular;
|
||||
@override
|
||||
final String small;
|
||||
final String? small;
|
||||
@override
|
||||
final String thumb;
|
||||
final String? thumb;
|
||||
|
||||
factory _$Urls([void Function(UrlsBuilder) updates]) =>
|
||||
factory _$Urls([void Function(UrlsBuilder)? updates]) =>
|
||||
(new UrlsBuilder()..update(updates)).build();
|
||||
|
||||
_$Urls._({this.raw, this.full, this.regular, this.small, this.thumb})
|
||||
@@ -156,27 +156,27 @@ class _$Urls extends Urls {
|
||||
}
|
||||
|
||||
class UrlsBuilder implements Builder<Urls, UrlsBuilder> {
|
||||
_$Urls _$v;
|
||||
_$Urls? _$v;
|
||||
|
||||
String _raw;
|
||||
String get raw => _$this._raw;
|
||||
set raw(String raw) => _$this._raw = raw;
|
||||
String? _raw;
|
||||
String? get raw => _$this._raw;
|
||||
set raw(String? raw) => _$this._raw = raw;
|
||||
|
||||
String _full;
|
||||
String get full => _$this._full;
|
||||
set full(String full) => _$this._full = full;
|
||||
String? _full;
|
||||
String? get full => _$this._full;
|
||||
set full(String? full) => _$this._full = full;
|
||||
|
||||
String _regular;
|
||||
String get regular => _$this._regular;
|
||||
set regular(String regular) => _$this._regular = regular;
|
||||
String? _regular;
|
||||
String? get regular => _$this._regular;
|
||||
set regular(String? regular) => _$this._regular = regular;
|
||||
|
||||
String _small;
|
||||
String get small => _$this._small;
|
||||
set small(String small) => _$this._small = small;
|
||||
String? _small;
|
||||
String? get small => _$this._small;
|
||||
set small(String? small) => _$this._small = small;
|
||||
|
||||
String _thumb;
|
||||
String get thumb => _$this._thumb;
|
||||
set thumb(String thumb) => _$this._thumb = thumb;
|
||||
String? _thumb;
|
||||
String? get thumb => _$this._thumb;
|
||||
set thumb(String? thumb) => _$this._thumb = thumb;
|
||||
|
||||
UrlsBuilder();
|
||||
|
||||
@@ -200,7 +200,7 @@ class UrlsBuilder implements Builder<Urls, UrlsBuilder> {
|
||||
}
|
||||
|
||||
@override
|
||||
void update(void Function(UrlsBuilder) updates) {
|
||||
void update(void Function(UrlsBuilder)? updates) {
|
||||
if (updates != null) updates(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -13,16 +13,15 @@ import 'links.dart';
|
||||
part 'user.g.dart';
|
||||
|
||||
abstract class User implements Built<User, UserBuilder> {
|
||||
factory User([void Function(UserBuilder) updates]) = _$User;
|
||||
factory User([void Function(UserBuilder)? updates]) = _$User;
|
||||
|
||||
User._();
|
||||
|
||||
@BuiltValueField(wireName: 'id')
|
||||
String get id;
|
||||
|
||||
@nullable
|
||||
@BuiltValueField(wireName: 'updated_at')
|
||||
String get updatedAt;
|
||||
String? get updatedAt;
|
||||
|
||||
@BuiltValueField(wireName: 'username')
|
||||
String get username;
|
||||
@@ -30,39 +29,32 @@ abstract class User implements Built<User, UserBuilder> {
|
||||
@BuiltValueField(wireName: 'name')
|
||||
String get name;
|
||||
|
||||
@nullable
|
||||
@BuiltValueField(wireName: 'portfolio_url')
|
||||
String get portfolioUrl;
|
||||
String? get portfolioUrl;
|
||||
|
||||
@nullable
|
||||
@BuiltValueField(wireName: 'bio')
|
||||
String get bio;
|
||||
String? get bio;
|
||||
|
||||
@nullable
|
||||
@BuiltValueField(wireName: 'location')
|
||||
String get location;
|
||||
String? get location;
|
||||
|
||||
@nullable
|
||||
@BuiltValueField(wireName: 'total_likes')
|
||||
int get totalLikes;
|
||||
int? get totalLikes;
|
||||
|
||||
@nullable
|
||||
@BuiltValueField(wireName: 'total_photos')
|
||||
int get totalPhotos;
|
||||
int? get totalPhotos;
|
||||
|
||||
@nullable
|
||||
@BuiltValueField(wireName: 'total_collections')
|
||||
int get totalCollections;
|
||||
int? get totalCollections;
|
||||
|
||||
@nullable
|
||||
@BuiltValueField(wireName: 'links')
|
||||
Links get links;
|
||||
Links? get links;
|
||||
|
||||
String toJson() {
|
||||
return json.encode(serializers.serializeWith(User.serializer, this));
|
||||
}
|
||||
|
||||
static User fromJson(String jsonString) {
|
||||
static User? fromJson(String jsonString) {
|
||||
return serializers.deserializeWith(
|
||||
User.serializer, json.decode(jsonString));
|
||||
}
|
||||
|
||||
@@ -19,9 +19,9 @@ class _$UserSerializer implements StructuredSerializer<User> {
|
||||
final String wireName = 'User';
|
||||
|
||||
@override
|
||||
Iterable<Object> serialize(Serializers serializers, User object,
|
||||
Iterable<Object?> serialize(Serializers serializers, User object,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
final result = <Object>[
|
||||
final result = <Object?>[
|
||||
'id',
|
||||
serializers.serialize(object.id, specifiedType: const FullType(String)),
|
||||
'username',
|
||||
@@ -30,7 +30,7 @@ class _$UserSerializer implements StructuredSerializer<User> {
|
||||
'name',
|
||||
serializers.serialize(object.name, specifiedType: const FullType(String)),
|
||||
];
|
||||
Object value;
|
||||
Object? value;
|
||||
value = object.updatedAt;
|
||||
if (value != null) {
|
||||
result
|
||||
@@ -88,7 +88,7 @@ class _$UserSerializer implements StructuredSerializer<User> {
|
||||
}
|
||||
|
||||
@override
|
||||
User deserialize(Serializers serializers, Iterable<Object> serialized,
|
||||
User deserialize(Serializers serializers, Iterable<Object?> serialized,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
final result = new UserBuilder();
|
||||
|
||||
@@ -96,7 +96,7 @@ class _$UserSerializer implements StructuredSerializer<User> {
|
||||
while (iterator.moveNext()) {
|
||||
final key = iterator.current as String;
|
||||
iterator.moveNext();
|
||||
final Object value = iterator.current;
|
||||
final Object? value = iterator.current;
|
||||
switch (key) {
|
||||
case 'id':
|
||||
result.id = serializers.deserialize(value,
|
||||
@@ -140,7 +140,7 @@ class _$UserSerializer implements StructuredSerializer<User> {
|
||||
break;
|
||||
case 'links':
|
||||
result.links.replace(serializers.deserialize(value,
|
||||
specifiedType: const FullType(Links)) as Links);
|
||||
specifiedType: const FullType(Links))! as Links);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -153,34 +153,34 @@ class _$User extends User {
|
||||
@override
|
||||
final String id;
|
||||
@override
|
||||
final String updatedAt;
|
||||
final String? updatedAt;
|
||||
@override
|
||||
final String username;
|
||||
@override
|
||||
final String name;
|
||||
@override
|
||||
final String portfolioUrl;
|
||||
final String? portfolioUrl;
|
||||
@override
|
||||
final String bio;
|
||||
final String? bio;
|
||||
@override
|
||||
final String location;
|
||||
final String? location;
|
||||
@override
|
||||
final int totalLikes;
|
||||
final int? totalLikes;
|
||||
@override
|
||||
final int totalPhotos;
|
||||
final int? totalPhotos;
|
||||
@override
|
||||
final int totalCollections;
|
||||
final int? totalCollections;
|
||||
@override
|
||||
final Links links;
|
||||
final Links? links;
|
||||
|
||||
factory _$User([void Function(UserBuilder) updates]) =>
|
||||
factory _$User([void Function(UserBuilder)? updates]) =>
|
||||
(new UserBuilder()..update(updates)).build();
|
||||
|
||||
_$User._(
|
||||
{this.id,
|
||||
{required this.id,
|
||||
this.updatedAt,
|
||||
this.username,
|
||||
this.name,
|
||||
required this.username,
|
||||
required this.name,
|
||||
this.portfolioUrl,
|
||||
this.bio,
|
||||
this.location,
|
||||
@@ -261,52 +261,52 @@ class _$User extends User {
|
||||
}
|
||||
|
||||
class UserBuilder implements Builder<User, UserBuilder> {
|
||||
_$User _$v;
|
||||
_$User? _$v;
|
||||
|
||||
String _id;
|
||||
String get id => _$this._id;
|
||||
set id(String id) => _$this._id = id;
|
||||
String? _id;
|
||||
String? get id => _$this._id;
|
||||
set id(String? id) => _$this._id = id;
|
||||
|
||||
String _updatedAt;
|
||||
String get updatedAt => _$this._updatedAt;
|
||||
set updatedAt(String updatedAt) => _$this._updatedAt = updatedAt;
|
||||
String? _updatedAt;
|
||||
String? get updatedAt => _$this._updatedAt;
|
||||
set updatedAt(String? updatedAt) => _$this._updatedAt = updatedAt;
|
||||
|
||||
String _username;
|
||||
String get username => _$this._username;
|
||||
set username(String username) => _$this._username = username;
|
||||
String? _username;
|
||||
String? get username => _$this._username;
|
||||
set username(String? username) => _$this._username = username;
|
||||
|
||||
String _name;
|
||||
String get name => _$this._name;
|
||||
set name(String name) => _$this._name = name;
|
||||
String? _name;
|
||||
String? get name => _$this._name;
|
||||
set name(String? name) => _$this._name = name;
|
||||
|
||||
String _portfolioUrl;
|
||||
String get portfolioUrl => _$this._portfolioUrl;
|
||||
set portfolioUrl(String portfolioUrl) => _$this._portfolioUrl = portfolioUrl;
|
||||
String? _portfolioUrl;
|
||||
String? get portfolioUrl => _$this._portfolioUrl;
|
||||
set portfolioUrl(String? portfolioUrl) => _$this._portfolioUrl = portfolioUrl;
|
||||
|
||||
String _bio;
|
||||
String get bio => _$this._bio;
|
||||
set bio(String bio) => _$this._bio = bio;
|
||||
String? _bio;
|
||||
String? get bio => _$this._bio;
|
||||
set bio(String? bio) => _$this._bio = bio;
|
||||
|
||||
String _location;
|
||||
String get location => _$this._location;
|
||||
set location(String location) => _$this._location = location;
|
||||
String? _location;
|
||||
String? get location => _$this._location;
|
||||
set location(String? location) => _$this._location = location;
|
||||
|
||||
int _totalLikes;
|
||||
int get totalLikes => _$this._totalLikes;
|
||||
set totalLikes(int totalLikes) => _$this._totalLikes = totalLikes;
|
||||
int? _totalLikes;
|
||||
int? get totalLikes => _$this._totalLikes;
|
||||
set totalLikes(int? totalLikes) => _$this._totalLikes = totalLikes;
|
||||
|
||||
int _totalPhotos;
|
||||
int get totalPhotos => _$this._totalPhotos;
|
||||
set totalPhotos(int totalPhotos) => _$this._totalPhotos = totalPhotos;
|
||||
int? _totalPhotos;
|
||||
int? get totalPhotos => _$this._totalPhotos;
|
||||
set totalPhotos(int? totalPhotos) => _$this._totalPhotos = totalPhotos;
|
||||
|
||||
int _totalCollections;
|
||||
int get totalCollections => _$this._totalCollections;
|
||||
set totalCollections(int totalCollections) =>
|
||||
int? _totalCollections;
|
||||
int? get totalCollections => _$this._totalCollections;
|
||||
set totalCollections(int? totalCollections) =>
|
||||
_$this._totalCollections = totalCollections;
|
||||
|
||||
LinksBuilder _links;
|
||||
LinksBuilder? _links;
|
||||
LinksBuilder get links => _$this._links ??= new LinksBuilder();
|
||||
set links(LinksBuilder links) => _$this._links = links;
|
||||
set links(LinksBuilder? links) => _$this._links = links;
|
||||
|
||||
UserBuilder();
|
||||
|
||||
@@ -336,7 +336,7 @@ class UserBuilder implements Builder<User, UserBuilder> {
|
||||
}
|
||||
|
||||
@override
|
||||
void update(void Function(UserBuilder) updates) {
|
||||
void update(void Function(UserBuilder)? updates) {
|
||||
if (updates != null) updates(this);
|
||||
}
|
||||
|
||||
@@ -359,7 +359,7 @@ class UserBuilder implements Builder<User, UserBuilder> {
|
||||
totalCollections: totalCollections,
|
||||
links: _links?.build());
|
||||
} catch (_) {
|
||||
String _$failedField;
|
||||
late String _$failedField;
|
||||
try {
|
||||
_$failedField = 'links';
|
||||
_links?.build();
|
||||
|
||||
@@ -7,8 +7,8 @@ import 'package:flutter/material.dart';
|
||||
import 'package:url_launcher/url_launcher.dart' as url_launcher;
|
||||
|
||||
class PolicyDialog extends StatelessWidget {
|
||||
PolicyDialog({
|
||||
Key key,
|
||||
const PolicyDialog({
|
||||
Key? key,
|
||||
this.radius = 8,
|
||||
}) : super(key: key);
|
||||
|
||||
@@ -23,7 +23,7 @@ class PolicyDialog extends StatelessWidget {
|
||||
builder: (context) {
|
||||
var height = MediaQuery.of(context).size.height;
|
||||
var width = MediaQuery.of(context).size.width;
|
||||
return Container(
|
||||
return SizedBox(
|
||||
height: height / 4,
|
||||
width: width / 4,
|
||||
child: Column(
|
||||
@@ -41,16 +41,16 @@ class PolicyDialog extends StatelessWidget {
|
||||
textAlign: TextAlign.left,
|
||||
text: TextSpan(
|
||||
text: '• ',
|
||||
style: TextStyle(color: Colors.black, fontSize: 18),
|
||||
style: const TextStyle(color: Colors.black, fontSize: 18),
|
||||
children: <TextSpan>[
|
||||
TextSpan(
|
||||
text: 'https://policies.google.com/terms',
|
||||
style: TextStyle(
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.lightBlue),
|
||||
recognizer: TapGestureRecognizer()
|
||||
..onTap = () async {
|
||||
final url = 'https://policies.google.com/terms';
|
||||
const url = 'https://policies.google.com/terms';
|
||||
if (await url_launcher.canLaunch(url)) {
|
||||
await url_launcher.launch(url);
|
||||
}
|
||||
@@ -63,16 +63,16 @@ class PolicyDialog extends StatelessWidget {
|
||||
textAlign: TextAlign.left,
|
||||
text: TextSpan(
|
||||
text: '• ',
|
||||
style: TextStyle(color: Colors.black, fontSize: 18),
|
||||
style: const TextStyle(color: Colors.black, fontSize: 18),
|
||||
children: <TextSpan>[
|
||||
TextSpan(
|
||||
text: 'https://unsplash.com/terms',
|
||||
style: TextStyle(
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.lightBlue),
|
||||
recognizer: TapGestureRecognizer()
|
||||
..onTap = () async {
|
||||
final url = 'https://unsplash.com/terms';
|
||||
const url = 'https://unsplash.com/terms';
|
||||
if (await url_launcher.canLaunch(url)) {
|
||||
await url_launcher.launch(url);
|
||||
}
|
||||
@@ -93,7 +93,7 @@ class PolicyDialog extends StatelessWidget {
|
||||
},
|
||||
child: Text(
|
||||
'CLOSE'.toUpperCase(),
|
||||
style: TextStyle(fontSize: 20),
|
||||
style: const TextStyle(fontSize: 20),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:transparent_image/transparent_image.dart';
|
||||
import 'package:url_launcher/link.dart';
|
||||
|
||||
@@ -17,8 +16,8 @@ typedef PhotoDetailsPhotoSaveCallback = void Function(Photo);
|
||||
|
||||
class PhotoDetails extends StatefulWidget {
|
||||
const PhotoDetails({
|
||||
@required this.photo,
|
||||
@required this.onPhotoSave,
|
||||
required this.photo,
|
||||
required this.onPhotoSave,
|
||||
});
|
||||
final Photo photo;
|
||||
final PhotoDetailsPhotoSaveCallback onPhotoSave;
|
||||
@@ -32,21 +31,21 @@ class _PhotoDetailsState extends State<PhotoDetails>
|
||||
Widget _buildPhotoAttribution(BuildContext context) {
|
||||
return Row(
|
||||
children: [
|
||||
Text('Photo by '),
|
||||
const Text('Photo by '),
|
||||
Link(
|
||||
uri: Uri.parse(
|
||||
'https://unsplash.com/@${widget.photo.user.username}?utm_source=$unsplashAppName&utm_medium=referral'),
|
||||
'https://unsplash.com/@${widget.photo.user!.username}?utm_source=$unsplashAppName&utm_medium=referral'),
|
||||
builder: (context, followLink) => TextButton(
|
||||
onPressed: followLink,
|
||||
child: Text(widget.photo.user.name),
|
||||
child: Text(widget.photo.user!.name),
|
||||
),
|
||||
),
|
||||
Text(' on '),
|
||||
const Text(' on '),
|
||||
Link(
|
||||
uri: _unsplashHomepage,
|
||||
builder: (context, followLink) => TextButton(
|
||||
onPressed: followLink,
|
||||
child: Text('Unsplash'),
|
||||
child: const Text('Unsplash'),
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -65,22 +64,22 @@ class _PhotoDetailsState extends State<PhotoDetails>
|
||||
const SizedBox(height: 16),
|
||||
Card(
|
||||
shape: ContinuousRectangleBorder(
|
||||
side: BorderSide(color: Colors.black12),
|
||||
side: const BorderSide(color: Colors.black12),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: AnimatedSize(
|
||||
vsync: this,
|
||||
duration: Duration(milliseconds: 750),
|
||||
duration: const Duration(milliseconds: 750),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 16, 16, 40),
|
||||
child: ConstrainedBox(
|
||||
constraints: BoxConstraints(
|
||||
constraints: const BoxConstraints(
|
||||
minWidth: 400,
|
||||
minHeight: 400,
|
||||
),
|
||||
child: FadeInImage.memoryNetwork(
|
||||
placeholder: kTransparentImage,
|
||||
image: widget.photo.urls.small,
|
||||
image: widget.photo.urls!.small!,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -97,7 +96,7 @@ class _PhotoDetailsState extends State<PhotoDetails>
|
||||
const SizedBox(width: 8),
|
||||
IconButton(
|
||||
visualDensity: VisualDensity.compact,
|
||||
icon: Icon(Icons.cloud_download),
|
||||
icon: const Icon(Icons.cloud_download),
|
||||
onPressed: () => widget.onPhotoSave(widget.photo),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -24,15 +24,12 @@ import 'package:flutter/material.dart';
|
||||
class Split extends StatefulWidget {
|
||||
/// Builds a split oriented along [axis].
|
||||
const Split({
|
||||
Key key,
|
||||
@required this.axis,
|
||||
@required this.firstChild,
|
||||
@required this.secondChild,
|
||||
double initialFirstFraction,
|
||||
Key? key,
|
||||
required this.axis,
|
||||
required this.firstChild,
|
||||
required this.secondChild,
|
||||
double? initialFirstFraction,
|
||||
}) : initialFirstFraction = initialFirstFraction ?? 0.5,
|
||||
assert(axis != null),
|
||||
assert(firstChild != null),
|
||||
assert(secondChild != null),
|
||||
super(key: key);
|
||||
|
||||
/// The main axis the children will lay out on.
|
||||
@@ -81,7 +78,7 @@ class Split extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _SplitState extends State<Split> {
|
||||
double firstFraction;
|
||||
late double firstFraction;
|
||||
|
||||
double get secondFraction => 1 - firstFraction;
|
||||
|
||||
@@ -111,9 +108,8 @@ class _SplitState extends State<Split> {
|
||||
var secondSize = axisSize * secondFraction;
|
||||
|
||||
// Clamp the sizes to be sure there is enough space for the dividers.
|
||||
firstSize = firstSize.clamp(halfDivider, axisSize - halfDivider) as double;
|
||||
secondSize =
|
||||
secondSize.clamp(halfDivider, axisSize - halfDivider) as double;
|
||||
firstSize = firstSize.clamp(halfDivider, axisSize - halfDivider);
|
||||
secondSize = secondSize.clamp(halfDivider, axisSize - halfDivider);
|
||||
|
||||
// Remove space from each child to place the divider in the middle.
|
||||
firstSize = firstSize - halfDivider;
|
||||
@@ -126,7 +122,7 @@ class _SplitState extends State<Split> {
|
||||
// Update the fraction of space consumed by the children,
|
||||
// being sure not to allocate any negative space.
|
||||
firstFraction += fractionalDelta;
|
||||
firstFraction = firstFraction.clamp(0.0, 1.0) as double;
|
||||
firstFraction = firstFraction.clamp(0.0, 1.0);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user