From 6b33fcb01c692dbe430966d0b9d62f67c27fcea3 Mon Sep 17 00:00:00 2001 From: Dan Cojocaru Date: Mon, 31 Oct 2022 01:25:45 +0100 Subject: [PATCH] Add freezed, update models dir structure --- lib/api/releases.dart | 2 +- lib/api/station_data.dart | 2 +- lib/api/stations.dart | 2 +- lib/api/train_data.dart | 2 +- lib/api/trains.dart | 2 +- lib/components/badge.dart | 2 +- lib/components/future_display.dart | 2 +- lib/components/loading/loading.dart | 2 +- .../select_train_suggestions.dart | 3 +- .../select_train_suggestions_cupertino.dart | 2 +- .../select_train_suggestions_material.dart | 2 +- lib/main.dart | 11 +- lib/models.dart | 13 + lib/models/station_arrdep.dart | 18 ++ lib/models/station_arrdep.freezed.dart | 241 ++++++++++++++++ lib/models/station_arrdep.g.dart | 23 ++ lib/models/station_data.dart | 69 +---- lib/models/station_data.freezed.dart | 237 ++++++++++++++++ lib/models/station_data.g.dart | 57 +--- lib/models/station_status.dart | 17 ++ lib/models/station_status.freezed.dart | 210 ++++++++++++++ lib/models/station_status.g.dart | 23 ++ lib/models/station_train.dart | 19 ++ lib/models/station_train.freezed.dart | 267 ++++++++++++++++++ lib/models/station_train.g.dart | 28 ++ lib/models/stations_result.dart | 16 +- lib/models/stations_result.freezed.dart | 178 ++++++++++++ lib/models/stations_result.g.dart | 6 +- lib/models/trains_result.dart | 22 +- lib/models/trains_result.freezed.dart | 187 ++++++++++++ lib/models/trains_result.g.dart | 5 +- lib/pages/about/about_page.dart | 3 +- lib/pages/main/main_page.dart | 2 +- .../select_station/select_station.dart | 2 +- .../view_station/view_station.dart | 3 +- .../view_station/view_station_cupertino.dart | 2 +- .../view_station/view_station_material.dart | 2 +- .../select_train/select_train.dart | 3 +- .../view_train/train_info.dart | 3 +- .../view_train/train_info_cupertino.dart | 3 +- ...in_info_cupertino_DisplayTrainStation.dart | 2 +- .../view_train/train_info_material.dart | 5 +- ...ain_info_material_DisplayTrainStation.dart | 2 +- lib/train_info_display.dart | 3 +- lib/utils/default_ui_design.dart | 2 +- lib/utils/state_to_string.dart | 10 +- pubspec.lock | 197 ++++++------- pubspec.yaml | 15 +- test/widget_test.dart | 30 -- 49 files changed, 1641 insertions(+), 318 deletions(-) create mode 100644 lib/models.dart create mode 100644 lib/models/station_arrdep.dart create mode 100644 lib/models/station_arrdep.freezed.dart create mode 100644 lib/models/station_arrdep.g.dart create mode 100644 lib/models/station_data.freezed.dart create mode 100644 lib/models/station_status.dart create mode 100644 lib/models/station_status.freezed.dart create mode 100644 lib/models/station_status.g.dart create mode 100644 lib/models/station_train.dart create mode 100644 lib/models/station_train.freezed.dart create mode 100644 lib/models/station_train.g.dart create mode 100644 lib/models/stations_result.freezed.dart create mode 100644 lib/models/trains_result.freezed.dart delete mode 100644 test/widget_test.dart diff --git a/lib/api/releases.dart b/lib/api/releases.dart index 34192b0..75e4ce8 100644 --- a/lib/api/releases.dart +++ b/lib/api/releases.dart @@ -1,7 +1,7 @@ import 'dart:convert'; import 'package:http/http.dart' as http; -import 'package:info_tren/models/changelog_entry.dart'; +import 'package:info_tren/models.dart'; import 'package:info_tren/utils/iterable_extensions.dart'; Future> getRemoteReleases() async { diff --git a/lib/api/station_data.dart b/lib/api/station_data.dart index 828a008..1b8a2a3 100644 --- a/lib/api/station_data.dart +++ b/lib/api/station_data.dart @@ -2,7 +2,7 @@ import 'dart:convert'; import 'package:http/http.dart' as http; import 'package:info_tren/api/common.dart'; -import 'package:info_tren/models/station_data.dart'; +import 'package:info_tren/models.dart'; Future getStationData(String stationName) async { final response = await http.get(Uri.https(authority, 'v3/stations/$stationName')); diff --git a/lib/api/stations.dart b/lib/api/stations.dart index 3f48626..8b78e28 100644 --- a/lib/api/stations.dart +++ b/lib/api/stations.dart @@ -2,7 +2,7 @@ import 'dart:convert'; import 'package:http/http.dart' as http; import 'package:info_tren/api/common.dart'; -import 'package:info_tren/models/stations_result.dart'; +import 'package:info_tren/models.dart'; Future> get stations async { final result = await http.get(Uri.https(authority, 'v2/stations')); diff --git a/lib/api/train_data.dart b/lib/api/train_data.dart index 3d3b091..b451656 100644 --- a/lib/api/train_data.dart +++ b/lib/api/train_data.dart @@ -1,6 +1,6 @@ import 'package:http/http.dart' as http; import 'package:info_tren/api/common.dart'; -import 'package:info_tren/models/train_data.dart'; +import 'package:info_tren/models.dart'; Future getTrain(String trainNumber, {DateTime? date}) async { date ??= DateTime.now(); diff --git a/lib/api/trains.dart b/lib/api/trains.dart index 210fbb9..92dbaf7 100644 --- a/lib/api/trains.dart +++ b/lib/api/trains.dart @@ -2,7 +2,7 @@ import 'dart:convert'; import 'package:http/http.dart' as http; import 'package:info_tren/api/common.dart'; -import 'package:info_tren/models/trains_result.dart'; +import 'package:info_tren/models.dart'; Future> get trains async { final result = await http.get(Uri.https(authority, 'v2/trains')); diff --git a/lib/components/badge.dart b/lib/components/badge.dart index 644b58f..cf1356e 100644 --- a/lib/components/badge.dart +++ b/lib/components/badge.dart @@ -10,7 +10,7 @@ class MaterialBadge extends StatelessWidget { final bool isOnTime; final bool isDelayed; - MaterialBadge({ + const MaterialBadge({ required this.text, required this.caption, this.isNotScheduled = false, diff --git a/lib/components/future_display.dart b/lib/components/future_display.dart index 075c117..90103b4 100644 --- a/lib/components/future_display.dart +++ b/lib/components/future_display.dart @@ -1,6 +1,6 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:info_tren/models/ui_design.dart'; +import 'package:info_tren/models.dart'; import 'package:info_tren/utils/default_ui_design.dart'; class FutureDisplay extends StatelessWidget { diff --git a/lib/components/loading/loading.dart b/lib/components/loading/loading.dart index 65c8670..b29736e 100644 --- a/lib/components/loading/loading.dart +++ b/lib/components/loading/loading.dart @@ -1,7 +1,7 @@ import 'package:flutter/widgets.dart'; import 'package:info_tren/components/loading/loading_cupertino.dart'; import 'package:info_tren/components/loading/loading_material.dart'; -import 'package:info_tren/models/ui_design.dart'; +import 'package:info_tren/models.dart'; import 'package:info_tren/utils/default_ui_design.dart'; class Loading extends StatelessWidget { diff --git a/lib/components/select_train_suggestions/select_train_suggestions.dart b/lib/components/select_train_suggestions/select_train_suggestions.dart index 0e27996..42a185d 100644 --- a/lib/components/select_train_suggestions/select_train_suggestions.dart +++ b/lib/components/select_train_suggestions/select_train_suggestions.dart @@ -3,8 +3,7 @@ import 'dart:convert'; import 'package:flutter/widgets.dart'; import 'package:info_tren/components/select_train_suggestions/select_train_suggestions_cupertino.dart'; import 'package:info_tren/components/select_train_suggestions/select_train_suggestions_material.dart'; -import 'package:info_tren/models/trains_result.dart'; -import 'package:info_tren/models/ui_design.dart'; +import 'package:info_tren/models.dart'; import 'package:info_tren/utils/default_ui_design.dart'; import 'package:tuple/tuple.dart'; diff --git a/lib/components/select_train_suggestions/select_train_suggestions_cupertino.dart b/lib/components/select_train_suggestions/select_train_suggestions_cupertino.dart index 4cd83f0..9939ae6 100644 --- a/lib/components/select_train_suggestions/select_train_suggestions_cupertino.dart +++ b/lib/components/select_train_suggestions/select_train_suggestions_cupertino.dart @@ -1,7 +1,7 @@ import 'package:flutter/cupertino.dart'; import 'package:info_tren/components/cupertino_divider.dart'; import 'package:info_tren/components/select_train_suggestions/select_train_suggestions.dart'; -import 'package:info_tren/models/trains_result.dart'; +import 'package:info_tren/models.dart'; class SelectTrainSuggestionsStateCupertino extends SelectTrainSuggestionsState { @override diff --git a/lib/components/select_train_suggestions/select_train_suggestions_material.dart b/lib/components/select_train_suggestions/select_train_suggestions_material.dart index 3fc58c3..41759b5 100644 --- a/lib/components/select_train_suggestions/select_train_suggestions_material.dart +++ b/lib/components/select_train_suggestions/select_train_suggestions_material.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; import 'package:info_tren/components/select_train_suggestions/select_train_suggestions.dart'; -import 'package:info_tren/models/trains_result.dart'; +import 'package:info_tren/models.dart'; class SelectTrainSuggestionsStateMaterial extends SelectTrainSuggestionsState { @override diff --git a/lib/main.dart b/lib/main.dart index cf37bb3..046905b 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -2,9 +2,7 @@ import 'dart:io' show Platform; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; -// import 'package:flutter_redux/flutter_redux.dart'; -import 'package:info_tren/models/ui_design.dart'; +import 'package:info_tren/models.dart'; import 'package:info_tren/pages/about/about_page.dart'; import 'package:info_tren/pages/main/main_page.dart'; import 'package:info_tren/pages/station_arrdep_page/select_station/select_station.dart'; @@ -15,13 +13,6 @@ import 'package:info_tren/pages/train_info_page/select_train/select_train.dart'; void main() { - // final store = createStore(); - // runApp( - // StoreProvider( - // store: store, - // child: StartPoint(), - // ) - // ); runApp( StartPoint(), ); diff --git a/lib/models.dart b/lib/models.dart new file mode 100644 index 0000000..9d63a57 --- /dev/null +++ b/lib/models.dart @@ -0,0 +1,13 @@ +export 'package:info_tren/models/changelog_entry.dart'; +export 'package:info_tren/models/station_arrdep.dart'; +export 'package:info_tren/models/station_data.dart'; +export 'package:info_tren/models/station_status.dart'; +export 'package:info_tren/models/station_train.dart'; +export 'package:info_tren/models/stations_result.dart'; +export 'package:info_tren/models/train_data.dart' hide State; +export 'package:info_tren/models/trains_result.dart'; +export 'package:info_tren/models/ui_design.dart'; + +import 'package:info_tren/models/train_data.dart' show State; + +typedef TrainDataState = State; diff --git a/lib/models/station_arrdep.dart b/lib/models/station_arrdep.dart new file mode 100644 index 0000000..4669a94 --- /dev/null +++ b/lib/models/station_arrdep.dart @@ -0,0 +1,18 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:info_tren/models.dart'; + +part 'station_arrdep.g.dart'; +part 'station_arrdep.freezed.dart'; + +@freezed +class StationArrDep with _$StationArrDep { + const factory StationArrDep({ + required int? stoppingTime, + required DateTime time, + required StationTrain train, + required StationStatus status, + }) = _StationArrDep; + + factory StationArrDep.fromJson(Map json) => _$StationArrDepFromJson(json); +} + diff --git a/lib/models/station_arrdep.freezed.dart b/lib/models/station_arrdep.freezed.dart new file mode 100644 index 0000000..221c1dc --- /dev/null +++ b/lib/models/station_arrdep.freezed.dart @@ -0,0 +1,241 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target + +part of 'station_arrdep.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods'); + +StationArrDep _$StationArrDepFromJson(Map json) { + return _StationArrDep.fromJson(json); +} + +/// @nodoc +mixin _$StationArrDep { + int? get stoppingTime => throw _privateConstructorUsedError; + DateTime get time => throw _privateConstructorUsedError; + StationTrain get train => throw _privateConstructorUsedError; + StationStatus get status => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $StationArrDepCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $StationArrDepCopyWith<$Res> { + factory $StationArrDepCopyWith( + StationArrDep value, $Res Function(StationArrDep) then) = + _$StationArrDepCopyWithImpl<$Res, StationArrDep>; + @useResult + $Res call( + {int? stoppingTime, + DateTime time, + StationTrain train, + StationStatus status}); + + $StationTrainCopyWith<$Res> get train; + $StationStatusCopyWith<$Res> get status; +} + +/// @nodoc +class _$StationArrDepCopyWithImpl<$Res, $Val extends StationArrDep> + implements $StationArrDepCopyWith<$Res> { + _$StationArrDepCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? stoppingTime = freezed, + Object? time = null, + Object? train = null, + Object? status = null, + }) { + return _then(_value.copyWith( + stoppingTime: freezed == stoppingTime + ? _value.stoppingTime + : stoppingTime // ignore: cast_nullable_to_non_nullable + as int?, + time: null == time + ? _value.time + : time // ignore: cast_nullable_to_non_nullable + as DateTime, + train: null == train + ? _value.train + : train // ignore: cast_nullable_to_non_nullable + as StationTrain, + status: null == status + ? _value.status + : status // ignore: cast_nullable_to_non_nullable + as StationStatus, + ) as $Val); + } + + @override + @pragma('vm:prefer-inline') + $StationTrainCopyWith<$Res> get train { + return $StationTrainCopyWith<$Res>(_value.train, (value) { + return _then(_value.copyWith(train: value) as $Val); + }); + } + + @override + @pragma('vm:prefer-inline') + $StationStatusCopyWith<$Res> get status { + return $StationStatusCopyWith<$Res>(_value.status, (value) { + return _then(_value.copyWith(status: value) as $Val); + }); + } +} + +/// @nodoc +abstract class _$$_StationArrDepCopyWith<$Res> + implements $StationArrDepCopyWith<$Res> { + factory _$$_StationArrDepCopyWith( + _$_StationArrDep value, $Res Function(_$_StationArrDep) then) = + __$$_StationArrDepCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {int? stoppingTime, + DateTime time, + StationTrain train, + StationStatus status}); + + @override + $StationTrainCopyWith<$Res> get train; + @override + $StationStatusCopyWith<$Res> get status; +} + +/// @nodoc +class __$$_StationArrDepCopyWithImpl<$Res> + extends _$StationArrDepCopyWithImpl<$Res, _$_StationArrDep> + implements _$$_StationArrDepCopyWith<$Res> { + __$$_StationArrDepCopyWithImpl( + _$_StationArrDep _value, $Res Function(_$_StationArrDep) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? stoppingTime = freezed, + Object? time = null, + Object? train = null, + Object? status = null, + }) { + return _then(_$_StationArrDep( + stoppingTime: freezed == stoppingTime + ? _value.stoppingTime + : stoppingTime // ignore: cast_nullable_to_non_nullable + as int?, + time: null == time + ? _value.time + : time // ignore: cast_nullable_to_non_nullable + as DateTime, + train: null == train + ? _value.train + : train // ignore: cast_nullable_to_non_nullable + as StationTrain, + status: null == status + ? _value.status + : status // ignore: cast_nullable_to_non_nullable + as StationStatus, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$_StationArrDep implements _StationArrDep { + const _$_StationArrDep( + {required this.stoppingTime, + required this.time, + required this.train, + required this.status}); + + factory _$_StationArrDep.fromJson(Map json) => + _$$_StationArrDepFromJson(json); + + @override + final int? stoppingTime; + @override + final DateTime time; + @override + final StationTrain train; + @override + final StationStatus status; + + @override + String toString() { + return 'StationArrDep(stoppingTime: $stoppingTime, time: $time, train: $train, status: $status)'; + } + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$_StationArrDep && + (identical(other.stoppingTime, stoppingTime) || + other.stoppingTime == stoppingTime) && + (identical(other.time, time) || other.time == time) && + (identical(other.train, train) || other.train == train) && + (identical(other.status, status) || other.status == status)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => + Object.hash(runtimeType, stoppingTime, time, train, status); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$_StationArrDepCopyWith<_$_StationArrDep> get copyWith => + __$$_StationArrDepCopyWithImpl<_$_StationArrDep>(this, _$identity); + + @override + Map toJson() { + return _$$_StationArrDepToJson( + this, + ); + } +} + +abstract class _StationArrDep implements StationArrDep { + const factory _StationArrDep( + {required final int? stoppingTime, + required final DateTime time, + required final StationTrain train, + required final StationStatus status}) = _$_StationArrDep; + + factory _StationArrDep.fromJson(Map json) = + _$_StationArrDep.fromJson; + + @override + int? get stoppingTime; + @override + DateTime get time; + @override + StationTrain get train; + @override + StationStatus get status; + @override + @JsonKey(ignore: true) + _$$_StationArrDepCopyWith<_$_StationArrDep> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/lib/models/station_arrdep.g.dart b/lib/models/station_arrdep.g.dart new file mode 100644 index 0000000..b6b1d2c --- /dev/null +++ b/lib/models/station_arrdep.g.dart @@ -0,0 +1,23 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'station_arrdep.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$_StationArrDep _$$_StationArrDepFromJson(Map json) => + _$_StationArrDep( + stoppingTime: json['stoppingTime'] as int?, + time: DateTime.parse(json['time'] as String), + train: StationTrain.fromJson(json['train'] as Map), + status: StationStatus.fromJson(json['status'] as Map), + ); + +Map _$$_StationArrDepToJson(_$_StationArrDep instance) => + { + 'stoppingTime': instance.stoppingTime, + 'time': instance.time.toIso8601String(), + 'train': instance.train, + 'status': instance.status, + }; diff --git a/lib/models/station_data.dart b/lib/models/station_data.dart index eb3cf08..217a9c9 100644 --- a/lib/models/station_data.dart +++ b/lib/models/station_data.dart @@ -1,64 +1,17 @@ -import 'package:json_annotation/json_annotation.dart'; +import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:info_tren/models.dart'; part 'station_data.g.dart'; +part 'station_data.freezed.dart'; -@JsonSerializable() -class StationData { - final String date; - final String stationName; - final List? arrivals; - final List? departures; - - const StationData({required this.date, required this.stationName, required this.arrivals, required this.departures}); +@freezed +class StationData with _$StationData { + const factory StationData({ + required String date, + required String stationName, + required List? arrivals, + required List? departures, + }) = _StationData; factory StationData.fromJson(Map json) => _$StationDataFromJson(json); - Map toJson() => _$StationDataToJson(this); -} - -@JsonSerializable() -class StationArrDep { - final int? stoppingTime; - final DateTime time; - final StationTrain train; - final StationStatus status; - - const StationArrDep({required this.stoppingTime, required this.time, required this.train, required this.status,}); - - factory StationArrDep.fromJson(Map json) => _$StationArrDepFromJson(json); - Map toJson() => _$StationArrDepToJson(this); -} - -@JsonSerializable() -class StationTrain { - final String rank; - final String number; - final String operator; - final String terminus; - final List? route; - final DateTime departureDate; - - StationTrain({ - required this.rank, - required this.number, - required this.operator, - required this.terminus, - this.route, - required this.departureDate, - }); - - factory StationTrain.fromJson(Map json) => _$StationTrainFromJson(json); - Map toJson() => _$StationTrainToJson(this); -} - -@JsonSerializable() -class StationStatus { - final int delay; - final bool real; - final bool cancelled; - final String? platform; - - StationStatus({required this.delay, required this.real, required this.cancelled, required this.platform}); - - factory StationStatus.fromJson(Map json) => _$StationStatusFromJson(json); - Map toJson() => _$StationStatusToJson(this); } diff --git a/lib/models/station_data.freezed.dart b/lib/models/station_data.freezed.dart new file mode 100644 index 0000000..3c017e8 --- /dev/null +++ b/lib/models/station_data.freezed.dart @@ -0,0 +1,237 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target + +part of 'station_data.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods'); + +StationData _$StationDataFromJson(Map json) { + return _StationData.fromJson(json); +} + +/// @nodoc +mixin _$StationData { + String get date => throw _privateConstructorUsedError; + String get stationName => throw _privateConstructorUsedError; + List? get arrivals => throw _privateConstructorUsedError; + List? get departures => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $StationDataCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $StationDataCopyWith<$Res> { + factory $StationDataCopyWith( + StationData value, $Res Function(StationData) then) = + _$StationDataCopyWithImpl<$Res, StationData>; + @useResult + $Res call( + {String date, + String stationName, + List? arrivals, + List? departures}); +} + +/// @nodoc +class _$StationDataCopyWithImpl<$Res, $Val extends StationData> + implements $StationDataCopyWith<$Res> { + _$StationDataCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? date = null, + Object? stationName = null, + Object? arrivals = freezed, + Object? departures = freezed, + }) { + return _then(_value.copyWith( + date: null == date + ? _value.date + : date // ignore: cast_nullable_to_non_nullable + as String, + stationName: null == stationName + ? _value.stationName + : stationName // ignore: cast_nullable_to_non_nullable + as String, + arrivals: freezed == arrivals + ? _value.arrivals + : arrivals // ignore: cast_nullable_to_non_nullable + as List?, + departures: freezed == departures + ? _value.departures + : departures // ignore: cast_nullable_to_non_nullable + as List?, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$_StationDataCopyWith<$Res> + implements $StationDataCopyWith<$Res> { + factory _$$_StationDataCopyWith( + _$_StationData value, $Res Function(_$_StationData) then) = + __$$_StationDataCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {String date, + String stationName, + List? arrivals, + List? departures}); +} + +/// @nodoc +class __$$_StationDataCopyWithImpl<$Res> + extends _$StationDataCopyWithImpl<$Res, _$_StationData> + implements _$$_StationDataCopyWith<$Res> { + __$$_StationDataCopyWithImpl( + _$_StationData _value, $Res Function(_$_StationData) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? date = null, + Object? stationName = null, + Object? arrivals = freezed, + Object? departures = freezed, + }) { + return _then(_$_StationData( + date: null == date + ? _value.date + : date // ignore: cast_nullable_to_non_nullable + as String, + stationName: null == stationName + ? _value.stationName + : stationName // ignore: cast_nullable_to_non_nullable + as String, + arrivals: freezed == arrivals + ? _value._arrivals + : arrivals // ignore: cast_nullable_to_non_nullable + as List?, + departures: freezed == departures + ? _value._departures + : departures // ignore: cast_nullable_to_non_nullable + as List?, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$_StationData implements _StationData { + const _$_StationData( + {required this.date, + required this.stationName, + required final List? arrivals, + required final List? departures}) + : _arrivals = arrivals, + _departures = departures; + + factory _$_StationData.fromJson(Map json) => + _$$_StationDataFromJson(json); + + @override + final String date; + @override + final String stationName; + final List? _arrivals; + @override + List? get arrivals { + final value = _arrivals; + if (value == null) return null; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(value); + } + + final List? _departures; + @override + List? get departures { + final value = _departures; + if (value == null) return null; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(value); + } + + @override + String toString() { + return 'StationData(date: $date, stationName: $stationName, arrivals: $arrivals, departures: $departures)'; + } + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$_StationData && + (identical(other.date, date) || other.date == date) && + (identical(other.stationName, stationName) || + other.stationName == stationName) && + const DeepCollectionEquality().equals(other._arrivals, _arrivals) && + const DeepCollectionEquality() + .equals(other._departures, _departures)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash( + runtimeType, + date, + stationName, + const DeepCollectionEquality().hash(_arrivals), + const DeepCollectionEquality().hash(_departures)); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$_StationDataCopyWith<_$_StationData> get copyWith => + __$$_StationDataCopyWithImpl<_$_StationData>(this, _$identity); + + @override + Map toJson() { + return _$$_StationDataToJson( + this, + ); + } +} + +abstract class _StationData implements StationData { + const factory _StationData( + {required final String date, + required final String stationName, + required final List? arrivals, + required final List? departures}) = _$_StationData; + + factory _StationData.fromJson(Map json) = + _$_StationData.fromJson; + + @override + String get date; + @override + String get stationName; + @override + List? get arrivals; + @override + List? get departures; + @override + @JsonKey(ignore: true) + _$$_StationDataCopyWith<_$_StationData> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/lib/models/station_data.g.dart b/lib/models/station_data.g.dart index d351438..19b06c3 100644 --- a/lib/models/station_data.g.dart +++ b/lib/models/station_data.g.dart @@ -6,7 +6,8 @@ part of 'station_data.dart'; // JsonSerializableGenerator // ************************************************************************** -StationData _$StationDataFromJson(Map json) => StationData( +_$_StationData _$$_StationDataFromJson(Map json) => + _$_StationData( date: json['date'] as String, stationName: json['stationName'] as String, arrivals: (json['arrivals'] as List?) @@ -17,62 +18,10 @@ StationData _$StationDataFromJson(Map json) => StationData( .toList(), ); -Map _$StationDataToJson(StationData instance) => +Map _$$_StationDataToJson(_$_StationData instance) => { 'date': instance.date, 'stationName': instance.stationName, 'arrivals': instance.arrivals, 'departures': instance.departures, }; - -StationArrDep _$StationArrDepFromJson(Map json) => - StationArrDep( - stoppingTime: json['stoppingTime'] as int?, - time: DateTime.parse(json['time'] as String), - train: StationTrain.fromJson(json['train'] as Map), - status: StationStatus.fromJson(json['status'] as Map), - ); - -Map _$StationArrDepToJson(StationArrDep instance) => - { - 'stoppingTime': instance.stoppingTime, - 'time': instance.time.toIso8601String(), - 'train': instance.train, - 'status': instance.status, - }; - -StationTrain _$StationTrainFromJson(Map json) => StationTrain( - rank: json['rank'] as String, - number: json['number'] as String, - operator: json['operator'] as String, - terminus: json['terminus'] as String, - route: - (json['route'] as List?)?.map((e) => e as String).toList(), - departureDate: DateTime.parse(json['departureDate'] as String), - ); - -Map _$StationTrainToJson(StationTrain instance) => - { - 'rank': instance.rank, - 'number': instance.number, - 'operator': instance.operator, - 'terminus': instance.terminus, - 'route': instance.route, - 'departureDate': instance.departureDate.toIso8601String(), - }; - -StationStatus _$StationStatusFromJson(Map json) => - StationStatus( - delay: json['delay'] as int, - real: json['real'] as bool, - cancelled: json['cancelled'] as bool, - platform: json['platform'] as String?, - ); - -Map _$StationStatusToJson(StationStatus instance) => - { - 'delay': instance.delay, - 'real': instance.real, - 'cancelled': instance.cancelled, - 'platform': instance.platform, - }; diff --git a/lib/models/station_status.dart b/lib/models/station_status.dart new file mode 100644 index 0000000..f82b9dd --- /dev/null +++ b/lib/models/station_status.dart @@ -0,0 +1,17 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'station_status.g.dart'; +part 'station_status.freezed.dart'; + +@freezed +class StationStatus with _$StationStatus { + const factory StationStatus({ + required int delay, + required bool real, + required bool cancelled, + required String? platform, + }) = _StationStatus; + + factory StationStatus.fromJson(Map json) => _$StationStatusFromJson(json); +} + diff --git a/lib/models/station_status.freezed.dart b/lib/models/station_status.freezed.dart new file mode 100644 index 0000000..4b22514 --- /dev/null +++ b/lib/models/station_status.freezed.dart @@ -0,0 +1,210 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target + +part of 'station_status.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods'); + +StationStatus _$StationStatusFromJson(Map json) { + return _StationStatus.fromJson(json); +} + +/// @nodoc +mixin _$StationStatus { + int get delay => throw _privateConstructorUsedError; + bool get real => throw _privateConstructorUsedError; + bool get cancelled => throw _privateConstructorUsedError; + String? get platform => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $StationStatusCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $StationStatusCopyWith<$Res> { + factory $StationStatusCopyWith( + StationStatus value, $Res Function(StationStatus) then) = + _$StationStatusCopyWithImpl<$Res, StationStatus>; + @useResult + $Res call({int delay, bool real, bool cancelled, String? platform}); +} + +/// @nodoc +class _$StationStatusCopyWithImpl<$Res, $Val extends StationStatus> + implements $StationStatusCopyWith<$Res> { + _$StationStatusCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? delay = null, + Object? real = null, + Object? cancelled = null, + Object? platform = freezed, + }) { + return _then(_value.copyWith( + delay: null == delay + ? _value.delay + : delay // ignore: cast_nullable_to_non_nullable + as int, + real: null == real + ? _value.real + : real // ignore: cast_nullable_to_non_nullable + as bool, + cancelled: null == cancelled + ? _value.cancelled + : cancelled // ignore: cast_nullable_to_non_nullable + as bool, + platform: freezed == platform + ? _value.platform + : platform // ignore: cast_nullable_to_non_nullable + as String?, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$_StationStatusCopyWith<$Res> + implements $StationStatusCopyWith<$Res> { + factory _$$_StationStatusCopyWith( + _$_StationStatus value, $Res Function(_$_StationStatus) then) = + __$$_StationStatusCopyWithImpl<$Res>; + @override + @useResult + $Res call({int delay, bool real, bool cancelled, String? platform}); +} + +/// @nodoc +class __$$_StationStatusCopyWithImpl<$Res> + extends _$StationStatusCopyWithImpl<$Res, _$_StationStatus> + implements _$$_StationStatusCopyWith<$Res> { + __$$_StationStatusCopyWithImpl( + _$_StationStatus _value, $Res Function(_$_StationStatus) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? delay = null, + Object? real = null, + Object? cancelled = null, + Object? platform = freezed, + }) { + return _then(_$_StationStatus( + delay: null == delay + ? _value.delay + : delay // ignore: cast_nullable_to_non_nullable + as int, + real: null == real + ? _value.real + : real // ignore: cast_nullable_to_non_nullable + as bool, + cancelled: null == cancelled + ? _value.cancelled + : cancelled // ignore: cast_nullable_to_non_nullable + as bool, + platform: freezed == platform + ? _value.platform + : platform // ignore: cast_nullable_to_non_nullable + as String?, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$_StationStatus implements _StationStatus { + const _$_StationStatus( + {required this.delay, + required this.real, + required this.cancelled, + required this.platform}); + + factory _$_StationStatus.fromJson(Map json) => + _$$_StationStatusFromJson(json); + + @override + final int delay; + @override + final bool real; + @override + final bool cancelled; + @override + final String? platform; + + @override + String toString() { + return 'StationStatus(delay: $delay, real: $real, cancelled: $cancelled, platform: $platform)'; + } + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$_StationStatus && + (identical(other.delay, delay) || other.delay == delay) && + (identical(other.real, real) || other.real == real) && + (identical(other.cancelled, cancelled) || + other.cancelled == cancelled) && + (identical(other.platform, platform) || + other.platform == platform)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => + Object.hash(runtimeType, delay, real, cancelled, platform); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$_StationStatusCopyWith<_$_StationStatus> get copyWith => + __$$_StationStatusCopyWithImpl<_$_StationStatus>(this, _$identity); + + @override + Map toJson() { + return _$$_StationStatusToJson( + this, + ); + } +} + +abstract class _StationStatus implements StationStatus { + const factory _StationStatus( + {required final int delay, + required final bool real, + required final bool cancelled, + required final String? platform}) = _$_StationStatus; + + factory _StationStatus.fromJson(Map json) = + _$_StationStatus.fromJson; + + @override + int get delay; + @override + bool get real; + @override + bool get cancelled; + @override + String? get platform; + @override + @JsonKey(ignore: true) + _$$_StationStatusCopyWith<_$_StationStatus> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/lib/models/station_status.g.dart b/lib/models/station_status.g.dart new file mode 100644 index 0000000..edc807a --- /dev/null +++ b/lib/models/station_status.g.dart @@ -0,0 +1,23 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'station_status.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$_StationStatus _$$_StationStatusFromJson(Map json) => + _$_StationStatus( + delay: json['delay'] as int, + real: json['real'] as bool, + cancelled: json['cancelled'] as bool, + platform: json['platform'] as String?, + ); + +Map _$$_StationStatusToJson(_$_StationStatus instance) => + { + 'delay': instance.delay, + 'real': instance.real, + 'cancelled': instance.cancelled, + 'platform': instance.platform, + }; diff --git a/lib/models/station_train.dart b/lib/models/station_train.dart new file mode 100644 index 0000000..b056ec3 --- /dev/null +++ b/lib/models/station_train.dart @@ -0,0 +1,19 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'station_train.g.dart'; +part 'station_train.freezed.dart'; + +@freezed +class StationTrain with _$StationTrain { + const factory StationTrain({ + required String rank, + required String number, + required String operator, + required String terminus, + List? route, + required DateTime departureDate, + }) = _StationTrain; + + factory StationTrain.fromJson(Map json) => _$StationTrainFromJson(json); +} + diff --git a/lib/models/station_train.freezed.dart b/lib/models/station_train.freezed.dart new file mode 100644 index 0000000..365ce5b --- /dev/null +++ b/lib/models/station_train.freezed.dart @@ -0,0 +1,267 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target + +part of 'station_train.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods'); + +StationTrain _$StationTrainFromJson(Map json) { + return _StationTrain.fromJson(json); +} + +/// @nodoc +mixin _$StationTrain { + String get rank => throw _privateConstructorUsedError; + String get number => throw _privateConstructorUsedError; + String get operator => throw _privateConstructorUsedError; + String get terminus => throw _privateConstructorUsedError; + List? get route => throw _privateConstructorUsedError; + DateTime get departureDate => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $StationTrainCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $StationTrainCopyWith<$Res> { + factory $StationTrainCopyWith( + StationTrain value, $Res Function(StationTrain) then) = + _$StationTrainCopyWithImpl<$Res, StationTrain>; + @useResult + $Res call( + {String rank, + String number, + String operator, + String terminus, + List? route, + DateTime departureDate}); +} + +/// @nodoc +class _$StationTrainCopyWithImpl<$Res, $Val extends StationTrain> + implements $StationTrainCopyWith<$Res> { + _$StationTrainCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? rank = null, + Object? number = null, + Object? operator = null, + Object? terminus = null, + Object? route = freezed, + Object? departureDate = null, + }) { + return _then(_value.copyWith( + rank: null == rank + ? _value.rank + : rank // ignore: cast_nullable_to_non_nullable + as String, + number: null == number + ? _value.number + : number // ignore: cast_nullable_to_non_nullable + as String, + operator: null == operator + ? _value.operator + : operator // ignore: cast_nullable_to_non_nullable + as String, + terminus: null == terminus + ? _value.terminus + : terminus // ignore: cast_nullable_to_non_nullable + as String, + route: freezed == route + ? _value.route + : route // ignore: cast_nullable_to_non_nullable + as List?, + departureDate: null == departureDate + ? _value.departureDate + : departureDate // ignore: cast_nullable_to_non_nullable + as DateTime, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$_StationTrainCopyWith<$Res> + implements $StationTrainCopyWith<$Res> { + factory _$$_StationTrainCopyWith( + _$_StationTrain value, $Res Function(_$_StationTrain) then) = + __$$_StationTrainCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {String rank, + String number, + String operator, + String terminus, + List? route, + DateTime departureDate}); +} + +/// @nodoc +class __$$_StationTrainCopyWithImpl<$Res> + extends _$StationTrainCopyWithImpl<$Res, _$_StationTrain> + implements _$$_StationTrainCopyWith<$Res> { + __$$_StationTrainCopyWithImpl( + _$_StationTrain _value, $Res Function(_$_StationTrain) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? rank = null, + Object? number = null, + Object? operator = null, + Object? terminus = null, + Object? route = freezed, + Object? departureDate = null, + }) { + return _then(_$_StationTrain( + rank: null == rank + ? _value.rank + : rank // ignore: cast_nullable_to_non_nullable + as String, + number: null == number + ? _value.number + : number // ignore: cast_nullable_to_non_nullable + as String, + operator: null == operator + ? _value.operator + : operator // ignore: cast_nullable_to_non_nullable + as String, + terminus: null == terminus + ? _value.terminus + : terminus // ignore: cast_nullable_to_non_nullable + as String, + route: freezed == route + ? _value._route + : route // ignore: cast_nullable_to_non_nullable + as List?, + departureDate: null == departureDate + ? _value.departureDate + : departureDate // ignore: cast_nullable_to_non_nullable + as DateTime, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$_StationTrain implements _StationTrain { + const _$_StationTrain( + {required this.rank, + required this.number, + required this.operator, + required this.terminus, + final List? route, + required this.departureDate}) + : _route = route; + + factory _$_StationTrain.fromJson(Map json) => + _$$_StationTrainFromJson(json); + + @override + final String rank; + @override + final String number; + @override + final String operator; + @override + final String terminus; + final List? _route; + @override + List? get route { + final value = _route; + if (value == null) return null; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(value); + } + + @override + final DateTime departureDate; + + @override + String toString() { + return 'StationTrain(rank: $rank, number: $number, operator: $operator, terminus: $terminus, route: $route, departureDate: $departureDate)'; + } + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$_StationTrain && + (identical(other.rank, rank) || other.rank == rank) && + (identical(other.number, number) || other.number == number) && + (identical(other.operator, operator) || + other.operator == operator) && + (identical(other.terminus, terminus) || + other.terminus == terminus) && + const DeepCollectionEquality().equals(other._route, _route) && + (identical(other.departureDate, departureDate) || + other.departureDate == departureDate)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash(runtimeType, rank, number, operator, terminus, + const DeepCollectionEquality().hash(_route), departureDate); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$_StationTrainCopyWith<_$_StationTrain> get copyWith => + __$$_StationTrainCopyWithImpl<_$_StationTrain>(this, _$identity); + + @override + Map toJson() { + return _$$_StationTrainToJson( + this, + ); + } +} + +abstract class _StationTrain implements StationTrain { + const factory _StationTrain( + {required final String rank, + required final String number, + required final String operator, + required final String terminus, + final List? route, + required final DateTime departureDate}) = _$_StationTrain; + + factory _StationTrain.fromJson(Map json) = + _$_StationTrain.fromJson; + + @override + String get rank; + @override + String get number; + @override + String get operator; + @override + String get terminus; + @override + List? get route; + @override + DateTime get departureDate; + @override + @JsonKey(ignore: true) + _$$_StationTrainCopyWith<_$_StationTrain> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/lib/models/station_train.g.dart b/lib/models/station_train.g.dart new file mode 100644 index 0000000..3bd240c --- /dev/null +++ b/lib/models/station_train.g.dart @@ -0,0 +1,28 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'station_train.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$_StationTrain _$$_StationTrainFromJson(Map json) => + _$_StationTrain( + rank: json['rank'] as String, + number: json['number'] as String, + operator: json['operator'] as String, + terminus: json['terminus'] as String, + route: + (json['route'] as List?)?.map((e) => e as String).toList(), + departureDate: DateTime.parse(json['departureDate'] as String), + ); + +Map _$$_StationTrainToJson(_$_StationTrain instance) => + { + 'rank': instance.rank, + 'number': instance.number, + 'operator': instance.operator, + 'terminus': instance.terminus, + 'route': instance.route, + 'departureDate': instance.departureDate.toIso8601String(), + }; diff --git a/lib/models/stations_result.dart b/lib/models/stations_result.dart index df6db00..8106bcf 100644 --- a/lib/models/stations_result.dart +++ b/lib/models/stations_result.dart @@ -1,14 +1,14 @@ -import 'package:json_annotation/json_annotation.dart'; +import 'package:freezed_annotation/freezed_annotation.dart'; part 'stations_result.g.dart'; +part 'stations_result.freezed.dart'; -@JsonSerializable() -class StationsResult { - final String name; - final List? stoppedAtBy; - - const StationsResult({required this.name, this.stoppedAtBy}); +@freezed +class StationsResult with _$StationsResult { + const factory StationsResult({ + required String name, + List? stoppedAtBy, + }) = _StationsResult; factory StationsResult.fromJson(Map json) => _$StationsResultFromJson(json); - Map toJson() => _$StationsResultToJson(this); } diff --git a/lib/models/stations_result.freezed.dart b/lib/models/stations_result.freezed.dart new file mode 100644 index 0000000..cefa58a --- /dev/null +++ b/lib/models/stations_result.freezed.dart @@ -0,0 +1,178 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target + +part of 'stations_result.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods'); + +StationsResult _$StationsResultFromJson(Map json) { + return _StationsResult.fromJson(json); +} + +/// @nodoc +mixin _$StationsResult { + String get name => throw _privateConstructorUsedError; + List? get stoppedAtBy => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $StationsResultCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $StationsResultCopyWith<$Res> { + factory $StationsResultCopyWith( + StationsResult value, $Res Function(StationsResult) then) = + _$StationsResultCopyWithImpl<$Res, StationsResult>; + @useResult + $Res call({String name, List? stoppedAtBy}); +} + +/// @nodoc +class _$StationsResultCopyWithImpl<$Res, $Val extends StationsResult> + implements $StationsResultCopyWith<$Res> { + _$StationsResultCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? name = null, + Object? stoppedAtBy = freezed, + }) { + return _then(_value.copyWith( + name: null == name + ? _value.name + : name // ignore: cast_nullable_to_non_nullable + as String, + stoppedAtBy: freezed == stoppedAtBy + ? _value.stoppedAtBy + : stoppedAtBy // ignore: cast_nullable_to_non_nullable + as List?, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$_StationsResultCopyWith<$Res> + implements $StationsResultCopyWith<$Res> { + factory _$$_StationsResultCopyWith( + _$_StationsResult value, $Res Function(_$_StationsResult) then) = + __$$_StationsResultCopyWithImpl<$Res>; + @override + @useResult + $Res call({String name, List? stoppedAtBy}); +} + +/// @nodoc +class __$$_StationsResultCopyWithImpl<$Res> + extends _$StationsResultCopyWithImpl<$Res, _$_StationsResult> + implements _$$_StationsResultCopyWith<$Res> { + __$$_StationsResultCopyWithImpl( + _$_StationsResult _value, $Res Function(_$_StationsResult) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? name = null, + Object? stoppedAtBy = freezed, + }) { + return _then(_$_StationsResult( + name: null == name + ? _value.name + : name // ignore: cast_nullable_to_non_nullable + as String, + stoppedAtBy: freezed == stoppedAtBy + ? _value._stoppedAtBy + : stoppedAtBy // ignore: cast_nullable_to_non_nullable + as List?, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$_StationsResult implements _StationsResult { + const _$_StationsResult({required this.name, final List? stoppedAtBy}) + : _stoppedAtBy = stoppedAtBy; + + factory _$_StationsResult.fromJson(Map json) => + _$$_StationsResultFromJson(json); + + @override + final String name; + final List? _stoppedAtBy; + @override + List? get stoppedAtBy { + final value = _stoppedAtBy; + if (value == null) return null; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(value); + } + + @override + String toString() { + return 'StationsResult(name: $name, stoppedAtBy: $stoppedAtBy)'; + } + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$_StationsResult && + (identical(other.name, name) || other.name == name) && + const DeepCollectionEquality() + .equals(other._stoppedAtBy, _stoppedAtBy)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash( + runtimeType, name, const DeepCollectionEquality().hash(_stoppedAtBy)); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$_StationsResultCopyWith<_$_StationsResult> get copyWith => + __$$_StationsResultCopyWithImpl<_$_StationsResult>(this, _$identity); + + @override + Map toJson() { + return _$$_StationsResultToJson( + this, + ); + } +} + +abstract class _StationsResult implements StationsResult { + const factory _StationsResult( + {required final String name, + final List? stoppedAtBy}) = _$_StationsResult; + + factory _StationsResult.fromJson(Map json) = + _$_StationsResult.fromJson; + + @override + String get name; + @override + List? get stoppedAtBy; + @override + @JsonKey(ignore: true) + _$$_StationsResultCopyWith<_$_StationsResult> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/lib/models/stations_result.g.dart b/lib/models/stations_result.g.dart index 5b05ac6..094e274 100644 --- a/lib/models/stations_result.g.dart +++ b/lib/models/stations_result.g.dart @@ -6,15 +6,15 @@ part of 'stations_result.dart'; // JsonSerializableGenerator // ************************************************************************** -StationsResult _$StationsResultFromJson(Map json) => - StationsResult( +_$_StationsResult _$$_StationsResultFromJson(Map json) => + _$_StationsResult( name: json['name'] as String, stoppedAtBy: (json['stoppedAtBy'] as List?) ?.map((e) => e as String) .toList(), ); -Map _$StationsResultToJson(StationsResult instance) => +Map _$$_StationsResultToJson(_$_StationsResult instance) => { 'name': instance.name, 'stoppedAtBy': instance.stoppedAtBy, diff --git a/lib/models/trains_result.dart b/lib/models/trains_result.dart index f36f167..9ba0501 100644 --- a/lib/models/trains_result.dart +++ b/lib/models/trains_result.dart @@ -1,19 +1,15 @@ -import 'package:json_annotation/json_annotation.dart'; +import 'package:freezed_annotation/freezed_annotation.dart'; part 'trains_result.g.dart'; +part 'trains_result.freezed.dart'; -@JsonSerializable() -class TrainsResult { - final String rank; - final String number; - final String company; - - const TrainsResult({ - required this.rank, - required this.number, - required this.company, - }); +@freezed +class TrainsResult with _$TrainsResult { + const factory TrainsResult({ + required String rank, + required String number, + required String company, + }) = _TrainsResult; factory TrainsResult.fromJson(Map json) => _$TrainsResultFromJson(json); - Map toJson() => _$TrainsResultToJson(this); } \ No newline at end of file diff --git a/lib/models/trains_result.freezed.dart b/lib/models/trains_result.freezed.dart new file mode 100644 index 0000000..a17147a --- /dev/null +++ b/lib/models/trains_result.freezed.dart @@ -0,0 +1,187 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target + +part of 'trains_result.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods'); + +TrainsResult _$TrainsResultFromJson(Map json) { + return _TrainsResult.fromJson(json); +} + +/// @nodoc +mixin _$TrainsResult { + String get rank => throw _privateConstructorUsedError; + String get number => throw _privateConstructorUsedError; + String get company => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $TrainsResultCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $TrainsResultCopyWith<$Res> { + factory $TrainsResultCopyWith( + TrainsResult value, $Res Function(TrainsResult) then) = + _$TrainsResultCopyWithImpl<$Res, TrainsResult>; + @useResult + $Res call({String rank, String number, String company}); +} + +/// @nodoc +class _$TrainsResultCopyWithImpl<$Res, $Val extends TrainsResult> + implements $TrainsResultCopyWith<$Res> { + _$TrainsResultCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? rank = null, + Object? number = null, + Object? company = null, + }) { + return _then(_value.copyWith( + rank: null == rank + ? _value.rank + : rank // ignore: cast_nullable_to_non_nullable + as String, + number: null == number + ? _value.number + : number // ignore: cast_nullable_to_non_nullable + as String, + company: null == company + ? _value.company + : company // ignore: cast_nullable_to_non_nullable + as String, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$_TrainsResultCopyWith<$Res> + implements $TrainsResultCopyWith<$Res> { + factory _$$_TrainsResultCopyWith( + _$_TrainsResult value, $Res Function(_$_TrainsResult) then) = + __$$_TrainsResultCopyWithImpl<$Res>; + @override + @useResult + $Res call({String rank, String number, String company}); +} + +/// @nodoc +class __$$_TrainsResultCopyWithImpl<$Res> + extends _$TrainsResultCopyWithImpl<$Res, _$_TrainsResult> + implements _$$_TrainsResultCopyWith<$Res> { + __$$_TrainsResultCopyWithImpl( + _$_TrainsResult _value, $Res Function(_$_TrainsResult) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? rank = null, + Object? number = null, + Object? company = null, + }) { + return _then(_$_TrainsResult( + rank: null == rank + ? _value.rank + : rank // ignore: cast_nullable_to_non_nullable + as String, + number: null == number + ? _value.number + : number // ignore: cast_nullable_to_non_nullable + as String, + company: null == company + ? _value.company + : company // ignore: cast_nullable_to_non_nullable + as String, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$_TrainsResult implements _TrainsResult { + const _$_TrainsResult( + {required this.rank, required this.number, required this.company}); + + factory _$_TrainsResult.fromJson(Map json) => + _$$_TrainsResultFromJson(json); + + @override + final String rank; + @override + final String number; + @override + final String company; + + @override + String toString() { + return 'TrainsResult(rank: $rank, number: $number, company: $company)'; + } + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$_TrainsResult && + (identical(other.rank, rank) || other.rank == rank) && + (identical(other.number, number) || other.number == number) && + (identical(other.company, company) || other.company == company)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash(runtimeType, rank, number, company); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$_TrainsResultCopyWith<_$_TrainsResult> get copyWith => + __$$_TrainsResultCopyWithImpl<_$_TrainsResult>(this, _$identity); + + @override + Map toJson() { + return _$$_TrainsResultToJson( + this, + ); + } +} + +abstract class _TrainsResult implements TrainsResult { + const factory _TrainsResult( + {required final String rank, + required final String number, + required final String company}) = _$_TrainsResult; + + factory _TrainsResult.fromJson(Map json) = + _$_TrainsResult.fromJson; + + @override + String get rank; + @override + String get number; + @override + String get company; + @override + @JsonKey(ignore: true) + _$$_TrainsResultCopyWith<_$_TrainsResult> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/lib/models/trains_result.g.dart b/lib/models/trains_result.g.dart index 8f4adc8..dd78442 100644 --- a/lib/models/trains_result.g.dart +++ b/lib/models/trains_result.g.dart @@ -6,13 +6,14 @@ part of 'trains_result.dart'; // JsonSerializableGenerator // ************************************************************************** -TrainsResult _$TrainsResultFromJson(Map json) => TrainsResult( +_$_TrainsResult _$$_TrainsResultFromJson(Map json) => + _$_TrainsResult( rank: json['rank'] as String, number: json['number'] as String, company: json['company'] as String, ); -Map _$TrainsResultToJson(TrainsResult instance) => +Map _$$_TrainsResultToJson(_$_TrainsResult instance) => { 'rank': instance.rank, 'number': instance.number, diff --git a/lib/pages/about/about_page.dart b/lib/pages/about/about_page.dart index 8743cb2..ad07b07 100644 --- a/lib/pages/about/about_page.dart +++ b/lib/pages/about/about_page.dart @@ -1,7 +1,6 @@ import 'package:flutter/widgets.dart'; import 'package:info_tren/api/releases.dart'; -import 'package:info_tren/models/changelog_entry.dart'; -import 'package:info_tren/models/ui_design.dart'; +import 'package:info_tren/models.dart'; import 'package:info_tren/pages/about/about_page_cupertino.dart'; import 'package:info_tren/pages/about/about_page_material.dart'; import 'package:info_tren/utils/default_ui_design.dart'; diff --git a/lib/pages/main/main_page.dart b/lib/pages/main/main_page.dart index a129e12..0d742c0 100644 --- a/lib/pages/main/main_page.dart +++ b/lib/pages/main/main_page.dart @@ -1,5 +1,5 @@ import 'package:flutter/widgets.dart'; -import 'package:info_tren/models/ui_design.dart'; +import 'package:info_tren/models.dart'; import 'package:info_tren/pages/about/about_page.dart'; import 'package:info_tren/pages/main/main_page_cupertino.dart'; import 'package:info_tren/pages/main/main_page_material.dart'; diff --git a/lib/pages/station_arrdep_page/select_station/select_station.dart b/lib/pages/station_arrdep_page/select_station/select_station.dart index 4d2a59d..32cfcbe 100644 --- a/lib/pages/station_arrdep_page/select_station/select_station.dart +++ b/lib/pages/station_arrdep_page/select_station/select_station.dart @@ -1,5 +1,5 @@ import 'package:flutter/widgets.dart'; -import 'package:info_tren/models/ui_design.dart'; +import 'package:info_tren/models.dart'; import 'package:info_tren/pages/station_arrdep_page/select_station/select_station_cupertino.dart'; import 'package:info_tren/pages/station_arrdep_page/select_station/select_station_material.dart'; import 'package:info_tren/pages/station_arrdep_page/view_station/view_station.dart'; diff --git a/lib/pages/station_arrdep_page/view_station/view_station.dart b/lib/pages/station_arrdep_page/view_station/view_station.dart index 546e899..04ba124 100644 --- a/lib/pages/station_arrdep_page/view_station/view_station.dart +++ b/lib/pages/station_arrdep_page/view_station/view_station.dart @@ -1,8 +1,7 @@ import 'package:flutter/widgets.dart'; import 'package:info_tren/api/station_data.dart'; import 'package:info_tren/components/refresh_future_builder.dart'; -import 'package:info_tren/models/station_data.dart'; -import 'package:info_tren/models/ui_design.dart'; +import 'package:info_tren/models.dart'; import 'package:info_tren/pages/station_arrdep_page/view_station/view_station_cupertino.dart'; import 'package:info_tren/pages/station_arrdep_page/view_station/view_station_material.dart'; import 'package:info_tren/pages/train_info_page/view_train/train_info.dart'; diff --git a/lib/pages/station_arrdep_page/view_station/view_station_cupertino.dart b/lib/pages/station_arrdep_page/view_station/view_station_cupertino.dart index a170f1d..b652dd6 100644 --- a/lib/pages/station_arrdep_page/view_station/view_station_cupertino.dart +++ b/lib/pages/station_arrdep_page/view_station/view_station_cupertino.dart @@ -2,7 +2,7 @@ import 'package:flutter/cupertino.dart'; import 'package:info_tren/components/loading/loading.dart'; import 'package:info_tren/components/refresh_future_builder.dart'; import 'package:info_tren/components/sliver_persistent_header_padding.dart'; -import 'package:info_tren/models/station_data.dart'; +import 'package:info_tren/models.dart'; import 'package:info_tren/pages/station_arrdep_page/view_station/view_station.dart'; class ViewStationPageStateCupertino extends ViewStationPageState { diff --git a/lib/pages/station_arrdep_page/view_station/view_station_material.dart b/lib/pages/station_arrdep_page/view_station/view_station_material.dart index 6e1d41c..76c0446 100644 --- a/lib/pages/station_arrdep_page/view_station/view_station_material.dart +++ b/lib/pages/station_arrdep_page/view_station/view_station_material.dart @@ -4,7 +4,7 @@ import 'package:flutter/material.dart'; import 'package:info_tren/components/badge.dart'; import 'package:info_tren/components/loading/loading.dart'; import 'package:info_tren/components/refresh_future_builder.dart'; -import 'package:info_tren/models/station_data.dart'; +import 'package:info_tren/models.dart'; import 'package:info_tren/pages/station_arrdep_page/view_station/view_station.dart'; class ViewStationPageStateMaterial extends ViewStationPageState { diff --git a/lib/pages/train_info_page/select_train/select_train.dart b/lib/pages/train_info_page/select_train/select_train.dart index 343c507..4bd84af 100644 --- a/lib/pages/train_info_page/select_train/select_train.dart +++ b/lib/pages/train_info_page/select_train/select_train.dart @@ -3,8 +3,7 @@ import 'dart:io' show Platform; import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; import 'package:info_tren/components/select_train_suggestions/select_train_suggestions.dart'; -import 'package:info_tren/models/trains_result.dart'; -import 'package:info_tren/models/ui_design.dart'; +import 'package:info_tren/models.dart'; import 'package:info_tren/pages/train_info_page/select_train/select_train_cupertino.dart'; import 'package:info_tren/pages/train_info_page/select_train/select_train_material.dart'; import 'package:info_tren/pages/train_info_page/view_train/train_info.dart'; diff --git a/lib/pages/train_info_page/view_train/train_info.dart b/lib/pages/train_info_page/view_train/train_info.dart index 9de1296..80a4525 100644 --- a/lib/pages/train_info_page/view_train/train_info.dart +++ b/lib/pages/train_info_page/view_train/train_info.dart @@ -4,8 +4,7 @@ import 'package:flutter/cupertino.dart'; import 'package:info_tren/api/train_data.dart'; import 'package:info_tren/components/loading/loading.dart'; import 'package:info_tren/components/refresh_future_builder.dart'; -import 'package:info_tren/models/train_data.dart'; -import 'package:info_tren/models/ui_design.dart'; +import 'package:info_tren/models.dart'; import 'package:info_tren/pages/train_info_page/view_train/train_info_cupertino.dart'; import 'package:info_tren/pages/train_info_page/view_train/train_info_material.dart'; import 'package:info_tren/utils/default_ui_design.dart'; diff --git a/lib/pages/train_info_page/view_train/train_info_cupertino.dart b/lib/pages/train_info_page/view_train/train_info_cupertino.dart index a0cf70d..52e9cb7 100644 --- a/lib/pages/train_info_page/view_train/train_info_cupertino.dart +++ b/lib/pages/train_info_page/view_train/train_info_cupertino.dart @@ -4,8 +4,7 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/gestures.dart'; import 'package:info_tren/components/cupertino_divider.dart'; import 'package:info_tren/components/sliver_persistent_header_padding.dart'; -import 'package:info_tren/models/train_data.dart' hide State; -import 'package:info_tren/models/ui_design.dart'; +import 'package:info_tren/models.dart'; import 'package:info_tren/pages/train_info_page/train_info_constants.dart'; import 'package:info_tren/pages/train_info_page/view_train/train_info.dart'; import 'package:info_tren/pages/train_info_page/view_train/train_info_cupertino_DisplayTrainStation.dart'; diff --git a/lib/pages/train_info_page/view_train/train_info_cupertino_DisplayTrainStation.dart b/lib/pages/train_info_page/view_train/train_info_cupertino_DisplayTrainStation.dart index 46a37d0..5868b58 100644 --- a/lib/pages/train_info_page/view_train/train_info_cupertino_DisplayTrainStation.dart +++ b/lib/pages/train_info_page/view_train/train_info_cupertino_DisplayTrainStation.dart @@ -1,6 +1,6 @@ import 'package:flutter/cupertino.dart'; -import 'package:info_tren/models/train_data.dart'; import 'package:info_tren/components/badge.dart'; +import 'package:info_tren/models.dart'; class DisplayTrainStation extends StatelessWidget { final Station station; diff --git a/lib/pages/train_info_page/view_train/train_info_material.dart b/lib/pages/train_info_page/view_train/train_info_material.dart index 0bb41f8..0716406 100644 --- a/lib/pages/train_info_page/view_train/train_info_material.dart +++ b/lib/pages/train_info_page/view_train/train_info_material.dart @@ -1,8 +1,7 @@ import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:info_tren/components/slim_app_bar.dart'; -import 'package:info_tren/models/train_data.dart' hide State; -import 'package:info_tren/models/ui_design.dart'; +import 'package:info_tren/models.dart'; import 'package:info_tren/pages/station_arrdep_page/view_station/view_station.dart'; import 'package:info_tren/pages/train_info_page/view_train/train_info.dart'; import 'package:info_tren/pages/train_info_page/view_train/train_info_material_DisplayTrainStation.dart'; @@ -384,7 +383,7 @@ class DisplayTrainLastInfo extends StatelessWidget { padding: const EdgeInsets.all(4), child: Text( stateToString(trainData.status!.state), - style: Theme.of(context).textTheme.bodyText2?.copyWith( + style: Theme.of(context).textTheme.bodyMedium?.copyWith( fontSize: isSmallScreen(context) ? 16 : 18, ), textAlign: TextAlign.right, diff --git a/lib/pages/train_info_page/view_train/train_info_material_DisplayTrainStation.dart b/lib/pages/train_info_page/view_train/train_info_material_DisplayTrainStation.dart index 9e5e72c..e427813 100644 --- a/lib/pages/train_info_page/view_train/train_info_material_DisplayTrainStation.dart +++ b/lib/pages/train_info_page/view_train/train_info_material_DisplayTrainStation.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:info_tren/models/train_data.dart'; +import 'package:info_tren/models.dart'; import 'package:info_tren/components/badge.dart'; import 'package:info_tren/pages/train_info_page/view_train/train_info_material.dart'; diff --git a/lib/train_info_display.dart b/lib/train_info_display.dart index abf88fb..25cfb4b 100644 --- a/lib/train_info_display.dart +++ b/lib/train_info_display.dart @@ -1,8 +1,7 @@ import 'package:flutter/material.dart'; +import 'package:info_tren/models.dart'; import 'package:info_tren/stations_list.dart.old'; -import 'models/train_data.dart'; - class TrainInfoDisplayData extends StatelessWidget { final TrainData trainData; diff --git a/lib/utils/default_ui_design.dart b/lib/utils/default_ui_design.dart index 5c9cd1e..0d55efe 100644 --- a/lib/utils/default_ui_design.dart +++ b/lib/utils/default_ui_design.dart @@ -1,6 +1,6 @@ import 'dart:io'; -import 'package:info_tren/models/ui_design.dart'; +import 'package:info_tren/models.dart'; UiDesign get defaultUiDesign { if (Platform.isIOS) { diff --git a/lib/utils/state_to_string.dart b/lib/utils/state_to_string.dart index 7058d0f..44ce5e3 100644 --- a/lib/utils/state_to_string.dart +++ b/lib/utils/state_to_string.dart @@ -1,12 +1,12 @@ -import 'package:info_tren/models/train_data.dart'; +import 'package:info_tren/models.dart'; -String stateToString(State state) { +String stateToString(TrainDataState state) { switch(state) { - case State.PASSING: + case TrainDataState.PASSING: return 'trecere fără oprire'; - case State.ARRIVAL: + case TrainDataState.ARRIVAL: return 'sosire'; - case State.DEPARTURE: + case TrainDataState.DEPARTURE: return 'plecare'; } } \ No newline at end of file diff --git a/pubspec.lock b/pubspec.lock index 28597d4..3cf4a8e 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -7,14 +7,14 @@ packages: name: _fe_analyzer_shared url: "https://pub.dartlang.org" source: hosted - version: "31.0.0" + version: "50.0.0" analyzer: dependency: transitive description: name: analyzer url: "https://pub.dartlang.org" source: hosted - version: "2.8.0" + version: "5.2.0" args: dependency: transitive description: @@ -28,21 +28,21 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.9.0" + version: "2.10.0" build: dependency: transitive description: name: build url: "https://pub.dartlang.org" source: hosted - version: "2.3.0" + version: "2.3.1" build_config: dependency: transitive description: name: build_config url: "https://pub.dartlang.org" source: hosted - version: "1.0.0" + version: "1.1.1" build_daemon: dependency: transitive description: @@ -56,21 +56,21 @@ packages: name: build_resolvers url: "https://pub.dartlang.org" source: hosted - version: "2.0.6" + version: "2.1.0" build_runner: dependency: "direct dev" description: name: build_runner url: "https://pub.dartlang.org" source: hosted - version: "2.1.11" + version: "2.3.2" build_runner_core: dependency: transitive description: name: build_runner_core url: "https://pub.dartlang.org" source: hosted - version: "7.2.2" + version: "7.2.7" built_collection: dependency: transitive description: @@ -84,14 +84,14 @@ packages: name: built_value url: "https://pub.dartlang.org" source: hosted - version: "8.4.0" + version: "8.4.2" characters: dependency: transitive description: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.2.1" checked_yaml: dependency: transitive description: @@ -99,20 +99,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.1" - cli_util: - dependency: transitive - description: - name: cli_util - url: "https://pub.dartlang.org" - source: hosted - version: "0.3.5" code_builder: dependency: transitive description: name: code_builder url: "https://pub.dartlang.org" source: hosted - version: "4.2.0" + version: "4.3.0" collection: dependency: transitive description: @@ -126,7 +119,7 @@ packages: name: convert url: "https://pub.dartlang.org" source: hosted - version: "3.0.2" + version: "3.1.1" crypto: dependency: transitive description: @@ -147,7 +140,7 @@ packages: name: dart_style url: "https://pub.dartlang.org" source: hosted - version: "2.2.1" + version: "2.2.4" ffi: dependency: transitive description: @@ -161,7 +154,7 @@ packages: name: file url: "https://pub.dartlang.org" source: hosted - version: "6.1.2" + version: "6.1.4" fixnum: dependency: transitive description: @@ -174,25 +167,53 @@ packages: description: flutter source: sdk version: "0.0.0" - flutter_redux: + flutter_hooks: dependency: "direct main" description: - name: flutter_redux + name: flutter_hooks + url: "https://pub.dartlang.org" + source: hosted + version: "0.18.5+1" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.1" + flutter_riverpod: + dependency: transitive + description: + name: flutter_riverpod url: "https://pub.dartlang.org" source: hosted - version: "0.8.2" + version: "2.0.2" flutter_web_plugins: dependency: transitive description: flutter source: sdk version: "0.0.0" + freezed: + dependency: "direct dev" + description: + name: freezed + url: "https://pub.dartlang.org" + source: hosted + version: "2.2.0" + freezed_annotation: + dependency: "direct main" + description: + name: freezed_annotation + url: "https://pub.dartlang.org" + source: hosted + version: "2.2.0" frontend_server_client: dependency: transitive description: name: frontend_server_client url: "https://pub.dartlang.org" source: hosted - version: "2.1.3" + version: "3.1.0" glob: dependency: transitive description: @@ -206,14 +227,21 @@ packages: name: graphs url: "https://pub.dartlang.org" source: hosted - version: "2.1.0" + version: "2.2.0" + hooks_riverpod: + dependency: "direct main" + description: + name: hooks_riverpod + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.2" http: dependency: "direct main" description: name: http url: "https://pub.dartlang.org" source: hosted - version: "0.13.4" + version: "0.13.5" http_multi_server: dependency: transitive description: @@ -227,7 +255,7 @@ packages: name: http_parser url: "https://pub.dartlang.org" source: hosted - version: "4.0.1" + version: "4.0.2" io: dependency: transitive description: @@ -243,47 +271,54 @@ packages: source: hosted version: "0.6.4" json_annotation: - dependency: transitive + dependency: "direct main" description: name: json_annotation url: "https://pub.dartlang.org" source: hosted - version: "4.1.0" + version: "4.7.0" json_serializable: dependency: "direct dev" description: name: json_serializable url: "https://pub.dartlang.org" source: hosted - version: "5.0.2" + version: "6.5.4" + lints: + dependency: transitive + description: + name: lints + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.1" logging: dependency: transitive description: name: logging url: "https://pub.dartlang.org" source: hosted - version: "1.0.2" + version: "1.1.0" matcher: dependency: transitive description: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.12" + version: "0.12.13" material_color_utilities: dependency: transitive description: name: material_color_utilities url: "https://pub.dartlang.org" source: hosted - version: "0.1.4" + version: "0.2.0" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.7.0" + version: "1.8.0" mime: dependency: transitive description: @@ -304,42 +339,14 @@ packages: name: package_info_plus url: "https://pub.dartlang.org" source: hosted - version: "1.4.3" - package_info_plus_linux: - dependency: transitive - description: - name: package_info_plus_linux - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.5" - package_info_plus_macos: - dependency: transitive - description: - name: package_info_plus_macos - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.0" + version: "3.0.1" package_info_plus_platform_interface: dependency: transitive description: name: package_info_plus_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.0.2" - package_info_plus_web: - dependency: transitive - description: - name: package_info_plus_web - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.5" - package_info_plus_windows: - dependency: transitive - description: - name: package_info_plus_windows - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.0" + version: "2.0.1" path: dependency: transitive description: @@ -353,7 +360,7 @@ packages: name: plugin_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "2.1.2" + version: "2.1.3" pool: dependency: transitive description: @@ -367,14 +374,14 @@ packages: name: pub_semver url: "https://pub.dartlang.org" source: hosted - version: "2.1.1" + version: "2.1.2" pubspec_parse: dependency: transitive description: name: pubspec_parse url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.2.1" quiver: dependency: "direct main" description: @@ -382,27 +389,20 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "3.1.0" - redux: + riverpod: dependency: transitive description: - name: redux - url: "https://pub.dartlang.org" - source: hosted - version: "5.0.0" - rxdart: - dependency: "direct main" - description: - name: rxdart + name: riverpod url: "https://pub.dartlang.org" source: hosted - version: "0.22.6" + version: "2.0.2" shelf: dependency: transitive description: name: shelf url: "https://pub.dartlang.org" source: hosted - version: "1.3.2" + version: "1.4.0" shelf_web_socket: dependency: transitive description: @@ -421,14 +421,14 @@ packages: name: source_gen url: "https://pub.dartlang.org" source: hosted - version: "1.2.2" + version: "1.2.6" source_helper: dependency: transitive description: name: source_helper url: "https://pub.dartlang.org" source: hosted - version: "1.3.2" + version: "1.3.3" source_span: dependency: transitive description: @@ -442,28 +442,35 @@ packages: name: sprintf url: "https://pub.dartlang.org" source: hosted - version: "6.0.0" + version: "7.0.0" stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.10.0" + version: "1.11.0" + state_notifier: + dependency: transitive + description: + name: state_notifier + url: "https://pub.dartlang.org" + source: hosted + version: "0.7.2+1" stream_channel: dependency: transitive description: name: stream_channel url: "https://pub.dartlang.org" source: hosted - version: "2.1.0" + version: "2.1.1" stream_transform: dependency: transitive description: name: stream_transform url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.0.1" string_scanner: dependency: transitive description: @@ -491,7 +498,7 @@ packages: name: tuple url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.0.1" typed_data: dependency: transitive description: @@ -505,14 +512,14 @@ packages: name: url_launcher url: "https://pub.dartlang.org" source: hosted - version: "6.1.5" + version: "6.1.6" url_launcher_android: dependency: transitive description: name: url_launcher_android url: "https://pub.dartlang.org" source: hosted - version: "6.0.17" + version: "6.0.21" url_launcher_ios: dependency: transitive description: @@ -540,14 +547,14 @@ packages: name: url_launcher_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "2.1.0" + version: "2.1.1" url_launcher_web: dependency: transitive description: name: url_launcher_web url: "https://pub.dartlang.org" source: hosted - version: "2.0.12" + version: "2.0.13" url_launcher_windows: dependency: transitive description: @@ -561,14 +568,14 @@ packages: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.2" + version: "2.1.4" watcher: dependency: transitive description: name: watcher url: "https://pub.dartlang.org" source: hosted - version: "1.0.1" + version: "1.0.2" web_socket_channel: dependency: transitive description: @@ -582,7 +589,7 @@ packages: name: win32 url: "https://pub.dartlang.org" source: hosted - version: "2.7.0" + version: "3.0.1" yaml: dependency: transitive description: @@ -591,5 +598,5 @@ packages: source: hosted version: "3.1.1" sdks: - dart: ">=2.17.0 <3.0.0" - flutter: ">=2.10.0" + dart: ">=2.18.0 <3.0.0" + flutter: ">=3.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index 7d71e55..a137652 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -19,24 +19,27 @@ environment: dependencies: flutter: sdk: flutter - # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.5 - rxdart: ^0.22.0 http: ^0.13.0 tuple: ^2.0.0 - sprintf: ^6.0.0 - flutter_redux: ^0.8.2 - package_info_plus: ^1.4.3 + sprintf: ^7.0.0 + package_info_plus: ^3.0.1 quiver: ^3.1.0 url_launcher: ^6.1.5 + flutter_hooks: ^0.18.5+1 + hooks_riverpod: ^2.0.2 + freezed_annotation: ^2.2.0 + json_annotation: ^4.7.0 dev_dependencies: # flutter_test: # sdk: flutter build_runner: ^2.1.0 - json_serializable: ^5.0.0 + json_serializable: ^6.5.4 + freezed: 2.2.0 + flutter_lints: ^2.0.1 # For information on the generic Dart part of this file, see the diff --git a/test/widget_test.dart b/test/widget_test.dart deleted file mode 100644 index 3dd4562..0000000 --- a/test/widget_test.dart +++ /dev/null @@ -1,30 +0,0 @@ -// This is a basic Flutter widget test. -// -// To perform an interaction with a widget in your test, use the WidgetTester -// utility in the flutter_test package. For example, you can send tap and scroll -// gestures. You can also use WidgetTester to find child widgets in the widget -// tree, read text, and verify that the values of widget properties are correct. - -import 'package:flutter/material.dart'; -import 'package:flutter_test/flutter_test.dart'; - -import 'package:info_tren/main.dart'; - -void main() { - testWidgets('Counter increments smoke test', (WidgetTester tester) async { - // Build our app and trigger a frame. - await tester.pumpWidget(const MyApp()); - - // Verify that our counter starts at 0. - expect(find.text('0'), findsOneWidget); - expect(find.text('1'), findsNothing); - - // Tap the '+' icon and trigger a frame. - await tester.tap(find.byIcon(Icons.add)); - await tester.pump(); - - // Verify that our counter has incremented. - expect(find.text('0'), findsNothing); - expect(find.text('1'), findsOneWidget); - }); -}