Skip to content

Commit 46ee9ca

Browse files
committed
Fixes
1 parent 5d8f762 commit 46ee9ca

35 files changed

+896
-130
lines changed

build.yaml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
targets:
2+
$default:
3+
builders:
4+
freezed:
5+
options:
6+
map:
7+
maybe_map: true
8+
#targets:
9+
# $default:
10+
# builders:
11+
# freezed:
12+
# enabled: true
13+
# options:
14+
# # Tells Freezed not to format .freezed.dart files.
15+
# # This can significantly speed up code-generation.
16+
# format: true
17+
# # Disable the generation of copyWith/== for the entire project
18+
# copy_with: true
19+
# equal: true
20+
# # `when` and `map` can be enabled/disabled entirely by setting them to `true`/`false`
21+
# map:
22+
# map: true
23+
# map_or_null: true
24+
# maybe_map: true
25+
# when:
26+
# when: true
27+
# when_or_null: true
28+
# maybe_when: true

lib/app/app.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ class MyApp extends StatelessWidget {
4545
),
4646
BlocProvider(
4747
create: (context) => LaunchesBloc(
48-
repository: RepositoryProvider.of<LaunchesRepository>(context),
48+
RepositoryProvider.of<LaunchesRepository>(context),
4949
)..add(
50-
LaunchesFetched(),
50+
const LaunchesEvent.load(),
5151
),
5252
),
5353
BlocProvider<InitBloc>(

lib/bloc/news/news_bloc.freezed.dart

+10
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ mixin _$NewsEvent {
3030
}
3131
}
3232

33+
/// @nodoc
34+
class $NewsEventCopyWith<$Res> {
35+
$NewsEventCopyWith(NewsEvent _, $Res Function(NewsEvent) __);
36+
}
37+
3338
/// @nodoc
3439
3540
class _Load implements NewsEvent {
@@ -87,6 +92,11 @@ mixin _$NewsState {
8792
}
8893
}
8994

95+
/// @nodoc
96+
class $NewsStateCopyWith<$Res> {
97+
$NewsStateCopyWith(NewsState _, $Res Function(NewsState) __);
98+
}
99+
90100
/// @nodoc
91101
92102
class _Initial implements NewsState {

lib/config/environment.dart

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
import 'package:bloc/bloc.dart';
12
import 'package:flutter/foundation.dart';
23
import 'package:flutter_bloc_app_template/config/build_type.dart';
4+
import 'package:talker_bloc_logger/talker_bloc_logger_observer.dart';
35

46
/// A class for managing environment configurations based on different
57
/// build types.
@@ -62,5 +64,6 @@ class Environment<T> implements Listenable {
6264
required T config,
6365
}) {
6466
_instance ??= Environment<T>._(buildType, config);
67+
Bloc.observer = TalkerBlocObserver();
6568
}
6669
}

lib/data/network/api_result.freezed.dart

+9-2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ mixin _$ApiResult<T> {
3030
}
3131
}
3232

33+
/// @nodoc
34+
class $ApiResultCopyWith<T, $Res> {
35+
$ApiResultCopyWith(ApiResult<T> _, $Res Function(ApiResult<T>) __);
36+
}
37+
3338
/// @nodoc
3439
3540
class Success<T> implements ApiResult<T> {
@@ -63,7 +68,8 @@ class Success<T> implements ApiResult<T> {
6368
}
6469

6570
/// @nodoc
66-
abstract mixin class $SuccessCopyWith<T, $Res> {
71+
abstract mixin class $SuccessCopyWith<T, $Res>
72+
implements $ApiResultCopyWith<T, $Res> {
6773
factory $SuccessCopyWith(Success<T> value, $Res Function(Success<T>) _then) =
6874
_$SuccessCopyWithImpl;
6975
@useResult
@@ -124,7 +130,8 @@ class Error<T> implements ApiResult<T> {
124130
}
125131

126132
/// @nodoc
127-
abstract mixin class $ErrorCopyWith<T, $Res> {
133+
abstract mixin class $ErrorCopyWith<T, $Res>
134+
implements $ApiResultCopyWith<T, $Res> {
128135
factory $ErrorCopyWith(Error<T> value, $Res Function(Error<T>) _then) =
129136
_$ErrorCopyWithImpl;
130137
@useResult

lib/data/network/data_source/launches_network_data_source.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ abstract class LaunchesDataSource {
99
int? offset,
1010
int? launchYear,
1111
int? launchSuccess,
12-
int? order,
12+
String? order,
1313
});
1414
}
1515

@@ -25,7 +25,7 @@ class LaunchesNetworkDataSource implements LaunchesDataSource {
2525
int? offset,
2626
int? launchYear,
2727
int? launchSuccess,
28-
int? order}) async {
28+
String? order}) async {
2929
try {
3030
final list = await _service.fetchLaunches(
3131
hasId: hasId,

lib/data/network/model/launch/network_launch_model.dart

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import 'package:flutter_bloc_app_template/data/network/model/launch/timestamp_serializer.dart';
12
import 'package:freezed_annotation/freezed_annotation.dart';
23

34
part 'network_launch_model.freezed.dart';
@@ -8,6 +9,9 @@ abstract class NetworkLaunchModel with _$NetworkLaunchModel {
89
const factory NetworkLaunchModel({
910
@JsonKey(name: '_id') required String id,
1011
@JsonKey(name: 'mission_name') String? missionName,
12+
@TimestampSerializer()
13+
@JsonKey(name: 'launch_date_utc')
14+
DateTime? launchDate,
1115
@JsonKey(name: 'rocket') NetworkRocketModel? rocket,
1216
@JsonKey(name: 'launch_success') @Default(false) bool success,
1317
@JsonKey(name: 'links') NetworkLaunchLinksModel? links,
@@ -23,8 +27,8 @@ abstract class NetworkLaunchModel with _$NetworkLaunchModel {
2327
abstract class NetworkRocketModel with _$NetworkRocketModel {
2428
const factory NetworkRocketModel({
2529
@JsonKey(name: 'rocket_id') required String id,
26-
@JsonKey(name: 'type') String? type,
27-
@JsonKey(name: 'name') String? name,
30+
@JsonKey(name: 'rocket_type') String? type,
31+
@JsonKey(name: 'rocket_name') String? name,
2832
}) = _NetworkRocketModel;
2933

3034
const NetworkRocketModel._();

lib/data/network/model/launch/network_launch_model.freezed.dart

+44-16
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ mixin _$NetworkLaunchModel {
1919
String get id;
2020
@JsonKey(name: 'mission_name')
2121
String? get missionName;
22+
@TimestampSerializer()
23+
@JsonKey(name: 'launch_date_utc')
24+
DateTime? get launchDate;
2225
@JsonKey(name: 'rocket')
2326
NetworkRocketModel? get rocket;
2427
@JsonKey(name: 'launch_success')
@@ -45,19 +48,21 @@ mixin _$NetworkLaunchModel {
4548
(identical(other.id, id) || other.id == id) &&
4649
(identical(other.missionName, missionName) ||
4750
other.missionName == missionName) &&
51+
(identical(other.launchDate, launchDate) ||
52+
other.launchDate == launchDate) &&
4853
(identical(other.rocket, rocket) || other.rocket == rocket) &&
4954
(identical(other.success, success) || other.success == success) &&
5055
(identical(other.links, links) || other.links == links));
5156
}
5257

5358
@JsonKey(includeFromJson: false, includeToJson: false)
5459
@override
55-
int get hashCode =>
56-
Object.hash(runtimeType, id, missionName, rocket, success, links);
60+
int get hashCode => Object.hash(
61+
runtimeType, id, missionName, launchDate, rocket, success, links);
5762

5863
@override
5964
String toString() {
60-
return 'NetworkLaunchModel(id: $id, missionName: $missionName, rocket: $rocket, success: $success, links: $links)';
65+
return 'NetworkLaunchModel(id: $id, missionName: $missionName, launchDate: $launchDate, rocket: $rocket, success: $success, links: $links)';
6166
}
6267
}
6368

@@ -70,6 +75,9 @@ abstract mixin class $NetworkLaunchModelCopyWith<$Res> {
7075
$Res call(
7176
{@JsonKey(name: '_id') String id,
7277
@JsonKey(name: 'mission_name') String? missionName,
78+
@TimestampSerializer()
79+
@JsonKey(name: 'launch_date_utc')
80+
DateTime? launchDate,
7381
@JsonKey(name: 'rocket') NetworkRocketModel? rocket,
7482
@JsonKey(name: 'launch_success') bool success,
7583
@JsonKey(name: 'links') NetworkLaunchLinksModel? links});
@@ -93,6 +101,7 @@ class _$NetworkLaunchModelCopyWithImpl<$Res>
93101
$Res call({
94102
Object? id = null,
95103
Object? missionName = freezed,
104+
Object? launchDate = freezed,
96105
Object? rocket = freezed,
97106
Object? success = null,
98107
Object? links = freezed,
@@ -106,6 +115,10 @@ class _$NetworkLaunchModelCopyWithImpl<$Res>
106115
? _self.missionName
107116
: missionName // ignore: cast_nullable_to_non_nullable
108117
as String?,
118+
launchDate: freezed == launchDate
119+
? _self.launchDate
120+
: launchDate // ignore: cast_nullable_to_non_nullable
121+
as DateTime?,
109122
rocket: freezed == rocket
110123
? _self.rocket
111124
: rocket // ignore: cast_nullable_to_non_nullable
@@ -156,6 +169,7 @@ class _NetworkLaunchModel extends NetworkLaunchModel {
156169
const _NetworkLaunchModel(
157170
{@JsonKey(name: '_id') required this.id,
158171
@JsonKey(name: 'mission_name') this.missionName,
172+
@TimestampSerializer() @JsonKey(name: 'launch_date_utc') this.launchDate,
159173
@JsonKey(name: 'rocket') this.rocket,
160174
@JsonKey(name: 'launch_success') this.success = false,
161175
@JsonKey(name: 'links') this.links})
@@ -170,6 +184,10 @@ class _NetworkLaunchModel extends NetworkLaunchModel {
170184
@JsonKey(name: 'mission_name')
171185
final String? missionName;
172186
@override
187+
@TimestampSerializer()
188+
@JsonKey(name: 'launch_date_utc')
189+
final DateTime? launchDate;
190+
@override
173191
@JsonKey(name: 'rocket')
174192
final NetworkRocketModel? rocket;
175193
@override
@@ -202,19 +220,21 @@ class _NetworkLaunchModel extends NetworkLaunchModel {
202220
(identical(other.id, id) || other.id == id) &&
203221
(identical(other.missionName, missionName) ||
204222
other.missionName == missionName) &&
223+
(identical(other.launchDate, launchDate) ||
224+
other.launchDate == launchDate) &&
205225
(identical(other.rocket, rocket) || other.rocket == rocket) &&
206226
(identical(other.success, success) || other.success == success) &&
207227
(identical(other.links, links) || other.links == links));
208228
}
209229

210230
@JsonKey(includeFromJson: false, includeToJson: false)
211231
@override
212-
int get hashCode =>
213-
Object.hash(runtimeType, id, missionName, rocket, success, links);
232+
int get hashCode => Object.hash(
233+
runtimeType, id, missionName, launchDate, rocket, success, links);
214234

215235
@override
216236
String toString() {
217-
return 'NetworkLaunchModel(id: $id, missionName: $missionName, rocket: $rocket, success: $success, links: $links)';
237+
return 'NetworkLaunchModel(id: $id, missionName: $missionName, launchDate: $launchDate, rocket: $rocket, success: $success, links: $links)';
218238
}
219239
}
220240

@@ -229,6 +249,9 @@ abstract mixin class _$NetworkLaunchModelCopyWith<$Res>
229249
$Res call(
230250
{@JsonKey(name: '_id') String id,
231251
@JsonKey(name: 'mission_name') String? missionName,
252+
@TimestampSerializer()
253+
@JsonKey(name: 'launch_date_utc')
254+
DateTime? launchDate,
232255
@JsonKey(name: 'rocket') NetworkRocketModel? rocket,
233256
@JsonKey(name: 'launch_success') bool success,
234257
@JsonKey(name: 'links') NetworkLaunchLinksModel? links});
@@ -254,6 +277,7 @@ class __$NetworkLaunchModelCopyWithImpl<$Res>
254277
$Res call({
255278
Object? id = null,
256279
Object? missionName = freezed,
280+
Object? launchDate = freezed,
257281
Object? rocket = freezed,
258282
Object? success = null,
259283
Object? links = freezed,
@@ -267,6 +291,10 @@ class __$NetworkLaunchModelCopyWithImpl<$Res>
267291
? _self.missionName
268292
: missionName // ignore: cast_nullable_to_non_nullable
269293
as String?,
294+
launchDate: freezed == launchDate
295+
? _self.launchDate
296+
: launchDate // ignore: cast_nullable_to_non_nullable
297+
as DateTime?,
270298
rocket: freezed == rocket
271299
? _self.rocket
272300
: rocket // ignore: cast_nullable_to_non_nullable
@@ -315,9 +343,9 @@ class __$NetworkLaunchModelCopyWithImpl<$Res>
315343
mixin _$NetworkRocketModel {
316344
@JsonKey(name: 'rocket_id')
317345
String get id;
318-
@JsonKey(name: 'type')
346+
@JsonKey(name: 'rocket_type')
319347
String? get type;
320-
@JsonKey(name: 'name')
348+
@JsonKey(name: 'rocket_name')
321349
String? get name;
322350

323351
/// Create a copy of NetworkRocketModel
@@ -359,8 +387,8 @@ abstract mixin class $NetworkRocketModelCopyWith<$Res> {
359387
@useResult
360388
$Res call(
361389
{@JsonKey(name: 'rocket_id') String id,
362-
@JsonKey(name: 'type') String? type,
363-
@JsonKey(name: 'name') String? name});
390+
@JsonKey(name: 'rocket_type') String? type,
391+
@JsonKey(name: 'rocket_name') String? name});
364392
}
365393

366394
/// @nodoc
@@ -402,8 +430,8 @@ class _$NetworkRocketModelCopyWithImpl<$Res>
402430
class _NetworkRocketModel extends NetworkRocketModel {
403431
const _NetworkRocketModel(
404432
{@JsonKey(name: 'rocket_id') required this.id,
405-
@JsonKey(name: 'type') this.type,
406-
@JsonKey(name: 'name') this.name})
433+
@JsonKey(name: 'rocket_type') this.type,
434+
@JsonKey(name: 'rocket_name') this.name})
407435
: super._();
408436
factory _NetworkRocketModel.fromJson(Map<String, dynamic> json) =>
409437
_$NetworkRocketModelFromJson(json);
@@ -412,10 +440,10 @@ class _NetworkRocketModel extends NetworkRocketModel {
412440
@JsonKey(name: 'rocket_id')
413441
final String id;
414442
@override
415-
@JsonKey(name: 'type')
443+
@JsonKey(name: 'rocket_type')
416444
final String? type;
417445
@override
418-
@JsonKey(name: 'name')
446+
@JsonKey(name: 'rocket_name')
419447
final String? name;
420448

421449
/// Create a copy of NetworkRocketModel
@@ -463,8 +491,8 @@ abstract mixin class _$NetworkRocketModelCopyWith<$Res>
463491
@useResult
464492
$Res call(
465493
{@JsonKey(name: 'rocket_id') String id,
466-
@JsonKey(name: 'type') String? type,
467-
@JsonKey(name: 'name') String? name});
494+
@JsonKey(name: 'rocket_type') String? type,
495+
@JsonKey(name: 'rocket_name') String? name});
468496
}
469497

470498
/// @nodoc

lib/data/network/model/launch/network_launch_model.g.dart

+7-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)