Line data Source code
1 : part of 'stop_details_bloc.dart';
2 :
3 : @freezed
4 : abstract class StopDetailsState with _$StopDetailsState {
5 : const factory StopDetailsState({
6 : @required bool isBus,
7 : @required bool isLoading,
8 : @required bool isError,
9 : @required String stop_name,
10 : @required String last_stop,
11 : @required List<String> arrivalTimes,
12 : @required List<StopTime> trip,
13 : @required String destination,
14 : Exception exception,
15 : }) = _StopDetailsState;
16 :
17 0 : factory StopDetailsState.initial() {
18 : return const StopDetailsState(
19 : isBus: true,
20 : isLoading: true,
21 : isError: false,
22 : stop_name: "",
23 : last_stop: "",
24 : arrivalTimes: ["", "", ""],
25 : trip: [],
26 : destination: "",
27 : );
28 : }
29 : }
30 :
31 : extension StopDetailsStateX on StopDetailsState {
32 0 : StopDetailsState loading() {
33 0 : return this.copyWith(
34 : isBus: true,
35 : isLoading: true,
36 : isError: false,
37 : );
38 : }
39 :
40 0 : StopDetailsState loaded(bool isBus, String stop_name, String last_stop,
41 : List<String> arrivalTimes, List<StopTime> trip, String destination) {
42 0 : return this.copyWith(
43 : isBus: isBus,
44 : isLoading: false,
45 : isError: false,
46 : stop_name: stop_name,
47 : last_stop: last_stop,
48 : arrivalTimes: arrivalTimes,
49 : trip: trip,
50 : destination: destination,
51 : );
52 : }
53 :
54 0 : StopDetailsState error(Exception exception) {
55 0 : return this.copyWith(
56 : isBus: true,
57 : isLoading: false,
58 : isError: true,
59 : exception: exception,
60 : );
61 : }
62 : }
|