diff --git a/.github/workflows/flutter_android_build.yml b/.github/workflows/flutter_android_build.yml index 42a417da..edfb1cbf 100644 --- a/.github/workflows/flutter_android_build.yml +++ b/.github/workflows/flutter_android_build.yml @@ -52,7 +52,6 @@ jobs: echo "ANDROID_KEY_PASSWORD=$ANDROID_KEY_PASSWORD" >> "$GITHUB_ENV" flutter pub get flutter pub run build_runner build --delete-conflicting-outputs - - run: flutter test - run: flutter build appbundle --flavor dev -t lib/main_dev.dart - run: flutter build appbundle --flavor inte -t lib/main_inte.dart - run: flutter build appbundle --flavor prod -t lib/main_prod.dart \ No newline at end of file diff --git a/.github/workflows/flutter_build_test_analyze.yml b/.github/workflows/flutter_build_test_analyze.yml new file mode 100644 index 00000000..0d04f9ef --- /dev/null +++ b/.github/workflows/flutter_build_test_analyze.yml @@ -0,0 +1,46 @@ +# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven + +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +name: Flutter Build Test Analyze + +defaults: + run: + working-directory: das_client + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +on: + push: + paths: + - 'das_client/**' + pull_request: + paths: + - 'das_client/**' + branches: [ "main" ] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: '17' + - uses: subosito/flutter-action@v2 + with: + flutter-version: '3.24.3' + - name: Prepare Flutter Build + run: | + flutter pub get + flutter pub run build_runner build --delete-conflicting-outputs + - run: flutter analyze + - run: flutter pub run custom_lint + - run: flutter test \ No newline at end of file diff --git a/.github/workflows/flutter_ios_build.yml b/.github/workflows/flutter_ios_build.yml index 1282e592..5423c2f2 100644 --- a/.github/workflows/flutter_ios_build.yml +++ b/.github/workflows/flutter_ios_build.yml @@ -41,7 +41,6 @@ jobs: run: | flutter pub get flutter pub run build_runner build --delete-conflicting-outputs - - run: flutter test - name: Build iOS App DEV run: flutter build ipa --flavor dev -t lib/main_dev.dart --release --no-codesign - name: Build iOS App INTE diff --git a/das_client/analysis_options.yaml b/das_client/analysis_options.yaml index b20cb6f7..34428d46 100644 --- a/das_client/analysis_options.yaml +++ b/das_client/analysis_options.yaml @@ -23,17 +23,13 @@ linter: # producing the lint. rules: always_use_package_imports: true - constant_identifier_names: false - library_prefixes: false - unnecessary_library_name: false - # avoid_print: false # Uncomment to disable the `avoid_print` rule - # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule + prefer_single_quotes: true # Additional information about this file can be found at # https://dart.dev/guides/language/analysis-options analyzer: + plugins: + - custom_lint exclude: - lib/**.g.dart - test/**.mocks.dart - errors: - invalid_annotation_target: ignore \ No newline at end of file diff --git a/das_client/das_custom_lints/lib/das_custom_lints.dart b/das_client/das_custom_lints/lib/das_custom_lints.dart new file mode 100644 index 00000000..42a4b1fd --- /dev/null +++ b/das_client/das_custom_lints/lib/das_custom_lints.dart @@ -0,0 +1,16 @@ +import 'package:custom_lint_builder/custom_lint_builder.dart'; +import 'package:das_custom_lints/dont_use_src_folder_imports.dart'; + +// Entrypoint of plugin +PluginBase createPlugin() => _DasCustomLints(); + +// The class listing all the [LintRule]s and [Assist]s defined by our plugin +class _DasCustomLints extends PluginBase { + // Lint rules + @override + List getLintRules(CustomLintConfigs configs) => [DontUseSrcFolderImports()]; + + // Assists + @override + List getAssists() => []; +} diff --git a/das_client/das_custom_lints/lib/dont_use_src_folder_imports.dart b/das_client/das_custom_lints/lib/dont_use_src_folder_imports.dart new file mode 100644 index 00000000..13eaa238 --- /dev/null +++ b/das_client/das_custom_lints/lib/dont_use_src_folder_imports.dart @@ -0,0 +1,56 @@ +import 'package:analyzer/error/listener.dart'; +import 'package:custom_lint_builder/custom_lint_builder.dart'; +import 'package:analyzer/error/error.dart'; + +// Lint rule to use src folder imports +class DontUseSrcFolderImports extends DartLintRule { + const DontUseSrcFolderImports() : super(code: _code); + + // Lint rule metadata + static const _code = LintCode( + name: 'dont_use_src_folder_imports', + problemMessage: 'Don\'t use source folder imports', + errorSeverity: ErrorSeverity.ERROR, + ); + + // `run` is where you analyze a file and report lint errors + // Invoked on a file automatically on every file edit + @override + void run( + CustomLintResolver resolver, + ErrorReporter reporter, + CustomLintContext context, + ) { + + // A call back fn that runs on all import declarations in a file + context.registry.addImportDirective((importDirective) { + var importUri = importDirective.uri.stringValue; + + if (importUri == null || !importUri.contains('/src/')) return; + + var filePath = importDirective.element!.source.fullName; + // ignore imports from outside the lib folder (mainly tests) + if (!filePath.contains('/lib/')) return; + + importUri = importUri.substring(importUri.indexOf('/') + 1); + filePath = filePath.substring(filePath.indexOf('/lib/') + 5); + + final importParts = importUri.split('/src/'); + final fileParts = filePath.split('/src/'); + + // allow it if its part of the same package + if (fileParts[0].startsWith(importParts[0])) return; + + // report a lint error with the `code` and the respective import directive + reporter.atNode(importDirective, LintCode( + name: _code.name, + problemMessage: 'Don\'t use source folder imports for importing ${importDirective.uri.stringValue}', + errorSeverity: ErrorSeverity.ERROR, + )); + }); + } + + // Possible fixes for the lint error go here + @override + List getFixes() => []; +} diff --git a/das_client/das_custom_lints/pubspec.lock b/das_client/das_custom_lints/pubspec.lock new file mode 100644 index 00000000..66b23fcd --- /dev/null +++ b/das_client/das_custom_lints/pubspec.lock @@ -0,0 +1,370 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + _fe_analyzer_shared: + dependency: transitive + description: + name: _fe_analyzer_shared + sha256: f256b0c0ba6c7577c15e2e4e114755640a875e885099367bf6e012b19314c834 + url: "https://pub.dev" + source: hosted + version: "72.0.0" + _macros: + dependency: transitive + description: dart + source: sdk + version: "0.3.2" + analyzer: + dependency: "direct main" + description: + name: analyzer + sha256: b652861553cd3990d8ed361f7979dc6d7053a9ac8843fa73820ab68ce5410139 + url: "https://pub.dev" + source: hosted + version: "6.7.0" + analyzer_plugin: + dependency: "direct main" + description: + name: analyzer_plugin + sha256: "9661b30b13a685efaee9f02e5d01ed9f2b423bd889d28a304d02d704aee69161" + url: "https://pub.dev" + source: hosted + version: "0.11.3" + args: + dependency: transitive + description: + name: args + sha256: "4cab82a83ffef80b262ddedf47a0a8e56ee6fbf7fe21e6e768b02792034dd440" + url: "https://pub.dev" + source: hosted + version: "2.4.0" + async: + dependency: transitive + description: + name: async + sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" + url: "https://pub.dev" + source: hosted + version: "2.11.0" + boolean_selector: + dependency: transitive + description: + name: boolean_selector + sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" + url: "https://pub.dev" + source: hosted + version: "2.1.1" + checked_yaml: + dependency: transitive + description: + name: checked_yaml + sha256: "3d1505d91afa809d177efd4eed5bb0eb65805097a1463abdd2add076effae311" + url: "https://pub.dev" + source: hosted + version: "2.0.2" + ci: + dependency: transitive + description: + name: ci + sha256: "145d095ce05cddac4d797a158bc4cf3b6016d1fe63d8c3d2fbd7212590adca13" + url: "https://pub.dev" + source: hosted + version: "0.1.0" + cli_util: + dependency: transitive + description: + name: cli_util + sha256: b8db3080e59b2503ca9e7922c3df2072cf13992354d5e944074ffa836fba43b7 + url: "https://pub.dev" + source: hosted + version: "0.4.0" + collection: + dependency: transitive + description: + name: collection + sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c" + url: "https://pub.dev" + source: hosted + version: "1.17.1" + convert: + dependency: transitive + description: + name: convert + sha256: "0f08b14755d163f6e2134cb58222dd25ea2a2ee8a195e53983d57c075324d592" + url: "https://pub.dev" + source: hosted + version: "3.1.1" + crypto: + dependency: transitive + description: + name: crypto + sha256: aa274aa7774f8964e4f4f38cc994db7b6158dd36e9187aaceaddc994b35c6c67 + url: "https://pub.dev" + source: hosted + version: "3.0.2" + custom_lint: + dependency: transitive + description: + name: custom_lint + sha256: "3486c470bb93313a9417f926c7dd694a2e349220992d7b9d14534dc49c15bba9" + url: "https://pub.dev" + source: hosted + version: "0.7.0" + custom_lint_builder: + dependency: "direct main" + description: + name: custom_lint_builder + sha256: "42cdc41994eeeddab0d7a722c7093ec52bd0761921eeb2cbdbf33d192a234759" + url: "https://pub.dev" + source: hosted + version: "0.7.0" + custom_lint_core: + dependency: transitive + description: + name: custom_lint_core + sha256: "02450c3e45e2a6e8b26c4d16687596ab3c4644dd5792e3313aa9ceba5a49b7f5" + url: "https://pub.dev" + source: hosted + version: "0.7.0" + custom_lint_visitor: + dependency: transitive + description: + name: custom_lint_visitor + sha256: "8aeb3b6ae2bb765e7716b93d1d10e8356d04e0ff6d7592de6ee04e0dd7d6587d" + url: "https://pub.dev" + source: hosted + version: "1.0.0+6.7.0" + dart_style: + dependency: transitive + description: + name: dart_style + sha256: "7856d364b589d1f08986e140938578ed36ed948581fbc3bc9aef1805039ac5ab" + url: "https://pub.dev" + source: hosted + version: "2.3.7" + file: + dependency: transitive + description: + name: file + sha256: "1b92bec4fc2a72f59a8e15af5f52cd441e4a7860b49499d69dfa817af20e925d" + url: "https://pub.dev" + source: hosted + version: "6.1.4" + fixnum: + dependency: transitive + description: + name: fixnum + sha256: b6dc7065e46c974bc7c5f143080a6764ec7a4be6da1285ececdc37be96de53be + url: "https://pub.dev" + source: hosted + version: "1.1.1" + freezed_annotation: + dependency: transitive + description: + name: freezed_annotation + sha256: aeac15850ef1b38ee368d4c53ba9a847e900bb2c53a4db3f6881cbb3cb684338 + url: "https://pub.dev" + source: hosted + version: "2.2.0" + glob: + dependency: transitive + description: + name: glob + sha256: "0e7014b3b7d4dac1ca4d6114f82bf1782ee86745b9b42a92c9289c23d8a0ab63" + url: "https://pub.dev" + source: hosted + version: "2.1.2" + hotreloader: + dependency: transitive + description: + name: hotreloader + sha256: "728c0613556c1d153f7e7f4a367cffacc3f5a677d7f6497a1c2b35add4e6dacf" + url: "https://pub.dev" + source: hosted + version: "3.0.6" + json_annotation: + dependency: transitive + description: + name: json_annotation + sha256: c33da08e136c3df0190bd5bbe51ae1df4a7d96e7954d1d7249fea2968a72d317 + url: "https://pub.dev" + source: hosted + version: "4.8.0" + logging: + dependency: transitive + description: + name: logging + sha256: "04094f2eb032cbb06c6f6e8d3607edcfcb0455e2bb6cbc010cb01171dcb64e6d" + url: "https://pub.dev" + source: hosted + version: "1.1.1" + macros: + dependency: transitive + description: + name: macros + sha256: "0acaed5d6b7eab89f63350bccd82119e6c602df0f391260d0e32b5e23db79536" + url: "https://pub.dev" + source: hosted + version: "0.1.2-main.4" + matcher: + dependency: transitive + description: + name: matcher + sha256: "6501fbd55da300384b768785b83e5ce66991266cec21af89ab9ae7f5ce1c4cbb" + url: "https://pub.dev" + source: hosted + version: "0.12.15" + meta: + dependency: transitive + description: + name: meta + sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c + url: "https://pub.dev" + source: hosted + version: "1.16.0" + package_config: + dependency: transitive + description: + name: package_config + sha256: "1c5b77ccc91e4823a5af61ee74e6b972db1ef98c2ff5a18d3161c982a55448bd" + url: "https://pub.dev" + source: hosted + version: "2.1.0" + path: + dependency: transitive + description: + name: path + sha256: "75cca69d1490965be98c73ceaea117e8a04dd21217b37b292c9ddbec0d955bc5" + url: "https://pub.dev" + source: hosted + version: "1.9.1" + pub_semver: + dependency: transitive + description: + name: pub_semver + sha256: "40d3ab1bbd474c4c2328c91e3a7df8c6dd629b79ece4c4bd04bee496a224fb0c" + url: "https://pub.dev" + source: hosted + version: "2.1.4" + pubspec_parse: + dependency: transitive + description: + name: pubspec_parse + sha256: ec85d7d55339d85f44ec2b682a82fea340071e8978257e5a43e69f79e98ef50c + url: "https://pub.dev" + source: hosted + version: "1.2.2" + rxdart: + dependency: transitive + description: + name: rxdart + sha256: "5c3004a4a8dbb94bd4bf5412a4def4acdaa12e12f269737a5751369e12d1a962" + url: "https://pub.dev" + source: hosted + version: "0.28.0" + source_span: + dependency: transitive + description: + name: source_span + sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" + url: "https://pub.dev" + source: hosted + version: "1.10.0" + sprintf: + dependency: transitive + description: + name: sprintf + sha256: "1fc9ffe69d4df602376b52949af107d8f5703b77cda567c4d7d86a0693120f23" + url: "https://pub.dev" + source: hosted + version: "7.0.0" + stack_trace: + dependency: transitive + description: + name: stack_trace + sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 + url: "https://pub.dev" + source: hosted + version: "1.11.0" + stream_channel: + dependency: transitive + description: + name: stream_channel + sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" + url: "https://pub.dev" + source: hosted + version: "2.1.1" + stream_transform: + dependency: transitive + description: + name: stream_transform + sha256: "14a00e794c7c11aa145a170587321aedce29769c08d7f58b1d141da75e3b1c6f" + url: "https://pub.dev" + source: hosted + version: "2.1.0" + string_scanner: + dependency: transitive + description: + name: string_scanner + sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" + url: "https://pub.dev" + source: hosted + version: "1.2.0" + term_glyph: + dependency: transitive + description: + name: term_glyph + sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 + url: "https://pub.dev" + source: hosted + version: "1.2.1" + test_api: + dependency: transitive + description: + name: test_api + sha256: daadc9baabec998b062c9091525aa95786508b1c48e9c30f1f891b8bf6ff2e64 + url: "https://pub.dev" + source: hosted + version: "0.5.2" + typed_data: + dependency: transitive + description: + name: typed_data + sha256: "26f87ade979c47a150c9eaab93ccd2bebe70a27dc0b4b29517f2904f04eb11a5" + url: "https://pub.dev" + source: hosted + version: "1.3.1" + uuid: + dependency: transitive + description: + name: uuid + sha256: a5be9ef6618a7ac1e964353ef476418026db906c4facdedaa299b7a2e71690ff + url: "https://pub.dev" + source: hosted + version: "4.5.1" + vm_service: + dependency: transitive + description: + name: vm_service + sha256: "518254c0d3ee20667a1feef39eefe037df87439851e4b3cb277e5b3f37afa2f0" + url: "https://pub.dev" + source: hosted + version: "11.4.0" + watcher: + dependency: transitive + description: + name: watcher + sha256: "3d2ad6751b3c16cf07c7fca317a1413b3f26530319181b37e3b9039b84fc01d8" + url: "https://pub.dev" + source: hosted + version: "1.1.0" + yaml: + dependency: transitive + description: + name: yaml + sha256: "23812a9b125b48d4007117254bca50abb6c712352927eece9e155207b1db2370" + url: "https://pub.dev" + source: hosted + version: "3.1.1" +sdks: + dart: ">=3.4.0 <4.0.0" diff --git a/das_client/das_custom_lints/pubspec.yaml b/das_client/das_custom_lints/pubspec.yaml new file mode 100644 index 00000000..04f7a793 --- /dev/null +++ b/das_client/das_custom_lints/pubspec.yaml @@ -0,0 +1,11 @@ +name: das_custom_lints +version: 0.0.1 +publish_to: none + +environment: + sdk: ">=3.3.0 <4.0.0" + +dependencies: + analyzer: ^6.7.0 + analyzer_plugin: ^0.11.2 + custom_lint_builder: ^0.7.0 diff --git a/das_client/integration_test/auth/integrationtest_authenticator.dart b/das_client/integration_test/auth/integrationtest_authenticator.dart index 77e7f28c..7991d5da 100644 --- a/das_client/integration_test/auth/integrationtest_authenticator.dart +++ b/das_client/integration_test/auth/integrationtest_authenticator.dart @@ -24,7 +24,7 @@ class IntegrationtestAuthenticator implements Authenticator { @override Future userId({String? tokenId}) async { - return "tester@testeee.com"; + return 'tester@testeee.com'; } OidcToken _token() { diff --git a/das_client/integration_test/auth/mqtt_client_user_connector.dart b/das_client/integration_test/auth/mqtt_client_user_connector.dart index 2fbfadaa..7b700783 100644 --- a/das_client/integration_test/auth/mqtt_client_user_connector.dart +++ b/das_client/integration_test/auth/mqtt_client_user_connector.dart @@ -3,32 +3,32 @@ import 'package:fimber/fimber.dart'; import 'package:mqtt_client/mqtt_client.dart'; class MqttClientUserConnector implements MqttClientConnector { - static const mqttUsername = "MQTT_USERNAME"; - static const mqttPassword = "MQTT_PASSWORD"; + static const mqttUsername = 'MQTT_USERNAME'; + static const mqttPassword = 'MQTT_PASSWORD'; @override Future connect(MqttClient client, String company, String train) async { - Fimber.i("Connecting to mqtt using static login and password"); + Fimber.i('Connecting to mqtt using static login and password'); if (!const bool.hasEnvironment(mqttUsername) || !const bool.hasEnvironment(mqttPassword)) { - Fimber.e("$mqttUsername or $mqttPassword not defined"); + Fimber.e('$mqttUsername or $mqttPassword not defined'); return false; } try { var mqttClientConnectionStatus = await client.connect(const String.fromEnvironment(mqttUsername), const String.fromEnvironment(mqttPassword)); - Fimber.i("mqttClientConnectionStatus=$mqttClientConnectionStatus"); + Fimber.i('mqttClientConnectionStatus=$mqttClientConnectionStatus'); if (mqttClientConnectionStatus?.state == MqttConnectionState.connected) { - Fimber.i("Successfully connected to MQTT broker"); + Fimber.i('Successfully connected to MQTT broker'); return true; } } catch (e) { - Fimber.e("Exception during connect", ex: e); + Fimber.e('Exception during connect', ex: e); } - Fimber.w("Failed to connect to MQTT broker"); + Fimber.w('Failed to connect to MQTT broker'); return false; } } diff --git a/das_client/lib/auth/token_spec.dart b/das_client/lib/auth/token_spec.dart index 1f93229f..4add4c3a 100644 --- a/das_client/lib/auth/token_spec.dart +++ b/das_client/lib/auth/token_spec.dart @@ -4,7 +4,7 @@ import 'package:meta/meta.dart'; @sealed @immutable class TokenSpec { - static const String defaultTokenId = "T1"; + static const String defaultTokenId = 'T1'; const TokenSpec({ required this.id, diff --git a/das_client/lib/bloc/fahrbild_cubit.dart b/das_client/lib/bloc/fahrbild_cubit.dart index ea883fbf..4d1e7162 100644 --- a/das_client/lib/bloc/fahrbild_cubit.dart +++ b/das_client/lib/bloc/fahrbild_cubit.dart @@ -33,7 +33,7 @@ class FahrbildCubit extends Cubit { final company = currentState.company; final trainNumber = currentState.trainNumber; if (company == null || trainNumber == null) { - Fimber.i("company or trainNumber null"); + Fimber.i('company or trainNumber null'); return; } @@ -81,7 +81,7 @@ class FahrbildCubit extends Cubit { void reset() { if (state is BaseFahrbildState) { - Fimber.i("Reseting fahrbild cubit in state $state"); + Fimber.i('Reseting fahrbild cubit in state $state'); emit(SelectingFahrbildState( trainNumber: (state as BaseFahrbildState).trainNumber, company: (state as BaseFahrbildState).company)); } diff --git a/das_client/lib/bloc/fahrbild_state.dart b/das_client/lib/bloc/fahrbild_state.dart index 863eba2f..4ffd173f 100644 --- a/das_client/lib/bloc/fahrbild_state.dart +++ b/das_client/lib/bloc/fahrbild_state.dart @@ -20,7 +20,7 @@ abstract class BaseFahrbildState extends FahrbildState { @override String toString() { - return "${runtimeType.toString()}(company=$company, trainNumber=$trainNumber, date=$date)"; + return '${runtimeType.toString()}(company=$company, trainNumber=$trainNumber, date=$date)'; } } diff --git a/das_client/lib/flavor.dart b/das_client/lib/flavor.dart index 8d74bfbd..0791f06c 100644 --- a/das_client/lib/flavor.dart +++ b/das_client/lib/flavor.dart @@ -57,7 +57,7 @@ enum Flavor { const _authenticatorConfigTmsDev = AuthenticatorConfig( discoveryUrl: - "https://login.microsoftonline.com/2cda5d11-f0ac-46b3-967d-af1b2e1bd01a/v2.0/.well-known/openid-configuration", + 'https://login.microsoftonline.com/2cda5d11-f0ac-46b3-967d-af1b2e1bd01a/v2.0/.well-known/openid-configuration', clientId: '8af8281c-4f1d-47b5-ad77-526b1da61b2b', redirectUrl: 'ch.sbb.das://sbbauth/redirect', tokenSpecs: TokenSpecProvider([ @@ -70,7 +70,7 @@ const _authenticatorConfigTmsDev = AuthenticatorConfig( ); const _authenticatorConfigMockDev = AuthenticatorConfig( - discoveryUrl: "https://login.microsoftonline.com/common/v2.0/.well-known/openid-configuration", + discoveryUrl: 'https://login.microsoftonline.com/common/v2.0/.well-known/openid-configuration', clientId: '6025180f-123b-4f2f-9703-16e08fc221f0', redirectUrl: 'ch.sbb.das://sbbauth/redirect', tokenSpecs: TokenSpecProvider([ @@ -83,7 +83,7 @@ const _authenticatorConfigMockDev = AuthenticatorConfig( ); const _authenticatorConfigInte = AuthenticatorConfig( - discoveryUrl: "https://login.microsoftonline.com/common/v2.0/.well-known/openid-configuration", + discoveryUrl: 'https://login.microsoftonline.com/common/v2.0/.well-known/openid-configuration', clientId: '6025180f-123b-4f2f-9703-16e08fc221f0', redirectUrl: 'ch.sbb.das://sbbauth/redirect', tokenSpecs: TokenSpecProvider([ @@ -96,7 +96,7 @@ const _authenticatorConfigInte = AuthenticatorConfig( ); const _authenticatorConfigProd = AuthenticatorConfig( - discoveryUrl: "https://login.microsoftonline.com/common/v2.0/.well-known/openid-configuration", + discoveryUrl: 'https://login.microsoftonline.com/common/v2.0/.well-known/openid-configuration', clientId: '6025180f-123b-4f2f-9703-16e08fc221f0', redirectUrl: 'ch.sbb.das://sbbauth/redirect', tokenSpecs: TokenSpecProvider([ diff --git a/das_client/lib/i18n/i18n.dart b/das_client/lib/i18n/i18n.dart index 1ce16a09..1f9b9af7 100644 --- a/das_client/lib/i18n/i18n.dart +++ b/das_client/lib/i18n/i18n.dart @@ -1,5 +1,3 @@ -library i18n; - import 'package:flutter/widgets.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; diff --git a/das_client/lib/logging/logging_component.dart b/das_client/lib/logging/logging_component.dart index aaa370cc..bcbbf436 100644 --- a/das_client/lib/logging/logging_component.dart +++ b/das_client/lib/logging/logging_component.dart @@ -1,9 +1,9 @@ -library logging; - import 'package:das_client/logging/src/das_log_tree.dart'; import 'package:das_client/logging/src/log_service.dart'; import 'package:fimber/fimber.dart'; +export 'package:das_client/logging/src/log_entry.dart'; + class LoggingComponent { const LoggingComponent._(); diff --git a/das_client/lib/logging/src/das_log_tree.dart b/das_client/lib/logging/src/das_log_tree.dart index 747b3fd0..9809942e 100644 --- a/das_client/lib/logging/src/das_log_tree.dart +++ b/das_client/lib/logging/src/das_log_tree.dart @@ -33,7 +33,7 @@ class DasLogTree extends LogTree { } void _processAndroidDeviceInfo(AndroidDeviceInfo deviceInfo) { - metadata['systemName'] = "android"; + metadata['systemName'] = 'android'; metadata['systemVersion'] = deviceInfo.version.sdkInt.toString(); metadata['model'] = deviceInfo.model; } @@ -46,7 +46,7 @@ class DasLogTree extends LogTree { @override List getLevels() { - return ["I", "W", "E"]; + return ['I', 'W', 'E']; } @override @@ -57,16 +57,16 @@ class DasLogTree extends LogTree { void logInternal(String level, String message, {String? tag, ex, StackTrace? stacktrace}) async { await _initialized; - final messageBuilder = StringBuffer("$tag:\t $message"); + final messageBuilder = StringBuffer('$tag:\t $message'); if (ex != null) { - messageBuilder.write("\n$ex"); + messageBuilder.write('\n$ex'); } if (stacktrace != null) { final tmpStacktrace = stacktrace.toString().split('\n'); final stackTraceMessage = - tmpStacktrace.map((stackLine) => "\t$stackLine").join("\n"); - messageBuilder.write("\n$stackTraceMessage"); + tmpStacktrace.map((stackLine) => '\t$stackLine').join('\n'); + messageBuilder.write('\n$stackTraceMessage'); } _logService.save(LogEntry(messageBuilder.toString(), _getLogLevel(level), metadata)); @@ -74,15 +74,15 @@ class DasLogTree extends LogTree { LogLevel _getLogLevel(String level) { switch (level) { - case "D": + case 'D': return LogLevel.debug; - case "W": + case 'W': return LogLevel.warning; - case "E": + case 'E': return LogLevel.error; - case "V": + case 'V': return LogLevel.trace; - case "I": + case 'I': default: return LogLevel.info; } diff --git a/das_client/lib/logging/src/log_entry.dart b/das_client/lib/logging/src/log_entry.dart index 79fc7172..522c47a8 100644 --- a/das_client/lib/logging/src/log_entry.dart +++ b/das_client/lib/logging/src/log_entry.dart @@ -3,7 +3,7 @@ import 'package:das_client/logging/src/log_level.dart'; class LogEntry { LogEntry(this.message, this.level, this.metadata) : time = DateTime.now().millisecondsSinceEpoch / 1000, - source = "das_client"; + source = 'das_client'; final double time; final String source; diff --git a/das_client/lib/logging/src/log_service.dart b/das_client/lib/logging/src/log_service.dart index 0009402f..2429df5e 100644 --- a/das_client/lib/logging/src/log_service.dart +++ b/das_client/lib/logging/src/log_service.dart @@ -11,8 +11,8 @@ import 'package:synchronized/synchronized.dart'; class LogService { static const _rolloverTimeMinutes = 1; static const _maxFileSize = 50 * 1024; - static const _prefix = "das-log"; - static const _lastSavedFileName = "$_prefix-lastSavedFile.json"; + static const _prefix = 'das-log'; + static const _lastSavedFileName = '$_prefix-lastSavedFile.json'; final _lock = Lock(); final _senderLock = Lock(); @@ -31,7 +31,7 @@ class LogService { } Future _getLogPath() async { - return "${(await getApplicationSupportDirectory()).path}/logs"; + return '${(await getApplicationSupportDirectory()).path}/logs'; } void save(LogEntry log) { @@ -41,16 +41,16 @@ class LogService { void _saveInternal(LogEntry log) async { await _initialized; _lock.synchronized(() { - var lastSavedFile = File("$_logPath/$_lastSavedFileName"); + var lastSavedFile = File('$_logPath/$_lastSavedFileName'); if (!(lastSavedFile.existsSync())) { lastSavedFile.createSync(recursive: true); } - lastSavedFile.writeAsStringSync("${jsonEncode(log)},", mode: FileMode.append); + lastSavedFile.writeAsStringSync('${jsonEncode(log)},', mode: FileMode.append); // Check rollover if (lastSavedFile.lengthSync() > _maxFileSize || _nextRolloverTimeStamp.isBefore(DateTime.now())) { - Fimber.d("Rolling over log file"); - lastSavedFile.renameSync("$_logPath/$_prefix-${DateTime.now().millisecondsSinceEpoch}.json"); + Fimber.d('Rolling over log file'); + lastSavedFile.renameSync('$_logPath/$_prefix-${DateTime.now().millisecondsSinceEpoch}.json'); _nextRolloverTimeStamp = DateTime.now().add(const Duration(minutes: _rolloverTimeMinutes)); _sendLogs(); } @@ -64,7 +64,7 @@ class LogService { Fimber.d('Found ${files.length} log files in log directory: $_logPath'); for (var file in files) { - if (file is File && file.path.endsWith(".json") && !file.path.contains(_lastSavedFileName)) { + if (file is File && file.path.endsWith('.json') && !file.path.contains(_lastSavedFileName)) { Fimber.d('Sending ${file.path} to backend'); var content = file.readAsStringSync(); diff --git a/das_client/lib/model/db/journey_profile_entity.dart b/das_client/lib/model/db/journey_profile_entity.dart index 03d37724..e7e6e524 100644 --- a/das_client/lib/model/db/journey_profile_entity.dart +++ b/das_client/lib/model/db/journey_profile_entity.dart @@ -4,7 +4,7 @@ import 'package:isar/isar.dart'; part 'journey_profile_entity.g.dart'; -@Collection(accessor: "journeyProfile") +@Collection(accessor: 'journeyProfile') class JourneyProfileEntity { JourneyProfileEntity( {required this.id, diff --git a/das_client/lib/model/db/segment_profile_entity.dart b/das_client/lib/model/db/segment_profile_entity.dart index 86c8ff2d..c33088e2 100644 --- a/das_client/lib/model/db/segment_profile_entity.dart +++ b/das_client/lib/model/db/segment_profile_entity.dart @@ -4,7 +4,7 @@ import 'package:isar/isar.dart'; part 'segment_profile_entity.g.dart'; -@Collection(accessor: "segmentProfile") +@Collection(accessor: 'segmentProfile') class SegmentProfileEntity { SegmentProfileEntity( {required this.id, diff --git a/das_client/lib/model/sfera/b2g_request.dart b/das_client/lib/model/sfera/b2g_request.dart index df14980c..766ae47b 100644 --- a/das_client/lib/model/sfera/b2g_request.dart +++ b/das_client/lib/model/sfera/b2g_request.dart @@ -3,7 +3,7 @@ import 'package:das_client/model/sfera/sfera_xml_element.dart'; import 'package:das_client/model/sfera/sp_request.dart'; class B2gRequest extends SferaXmlElement { - static const String elementType = "B2G_Request"; + static const String elementType = 'B2G_Request'; B2gRequest({super.type = elementType, super.attributes, super.children, super.value}); diff --git a/das_client/lib/model/sfera/das_operating_modes_selected.dart b/das_client/lib/model/sfera/das_operating_modes_selected.dart index 4e35b7fa..452ebba7 100644 --- a/das_client/lib/model/sfera/das_operating_modes_selected.dart +++ b/das_client/lib/model/sfera/das_operating_modes_selected.dart @@ -4,18 +4,18 @@ import 'package:das_client/model/sfera/enums/xml_enum.dart'; import 'package:das_client/model/sfera/sfera_xml_element.dart'; class DasOperatingModesSelected extends SferaXmlElement { - static const String elementType = "DAS_OperatingModeSelected"; + static const String elementType = 'DAS_OperatingModeSelected'; DasOperatingModesSelected({super.type = elementType, super.attributes, super.children, super.value}); - DasArchitecture get architecture => XmlEnum.valueOf(DasArchitecture.values, attributes["DAS_architecture"]!)!; + DasArchitecture get architecture => XmlEnum.valueOf(DasArchitecture.values, attributes['DAS_architecture']!)!; - DasConnectivity get connectivity => XmlEnum.valueOf(DasConnectivity.values, attributes["DAS_connectivity"]!)!; + DasConnectivity get connectivity => XmlEnum.valueOf(DasConnectivity.values, attributes['DAS_connectivity']!)!; @override bool validate() { - return validateHasEnumAttribute(DasArchitecture.values, "DAS_architecture") && - validateHasEnumAttribute(DasConnectivity.values, "DAS_connectivity") && + return validateHasEnumAttribute(DasArchitecture.values, 'DAS_architecture') && + validateHasEnumAttribute(DasConnectivity.values, 'DAS_connectivity') && super.validate(); } } diff --git a/das_client/lib/model/sfera/das_operating_modes_supported.dart b/das_client/lib/model/sfera/das_operating_modes_supported.dart index ea1a3034..0117526e 100644 --- a/das_client/lib/model/sfera/das_operating_modes_supported.dart +++ b/das_client/lib/model/sfera/das_operating_modes_supported.dart @@ -4,24 +4,24 @@ import 'package:das_client/model/sfera/enums/das_driving_mode.dart'; import 'package:das_client/model/sfera/sfera_xml_element.dart'; class DasOperatingModesSupported extends SferaXmlElement { - static const String elementType = "DAS_OperatingModesSupported"; + static const String elementType = 'DAS_OperatingModesSupported'; DasOperatingModesSupported({super.type = elementType, super.attributes, super.children, super.value}); factory DasOperatingModesSupported.create( DasDrivingMode drivingMode, DasArchitecture architecture, DasConnectivity connectivity) { final operatingMode = DasOperatingModesSupported(); - operatingMode.attributes["DAS_drivingMode"] = drivingMode.xmlValue; - operatingMode.attributes["DAS_architecture"] = architecture.xmlValue; - operatingMode.attributes["DAS_connectivity"] = connectivity.xmlValue; + operatingMode.attributes['DAS_drivingMode'] = drivingMode.xmlValue; + operatingMode.attributes['DAS_architecture'] = architecture.xmlValue; + operatingMode.attributes['DAS_connectivity'] = connectivity.xmlValue; return operatingMode; } @override bool validate() { - return validateHasAttribute("DAS_drivingMode") && - validateHasAttribute("DAS_architecture") && - validateHasAttribute("DAS_connectivity") && + return validateHasAttribute('DAS_drivingMode') && + validateHasAttribute('DAS_architecture') && + validateHasAttribute('DAS_connectivity') && super.validate(); } } diff --git a/das_client/lib/model/sfera/enums/das_architecture.dart b/das_client/lib/model/sfera/enums/das_architecture.dart index 8c342e93..b2a28eab 100644 --- a/das_client/lib/model/sfera/enums/das_architecture.dart +++ b/das_client/lib/model/sfera/enums/das_architecture.dart @@ -1,8 +1,8 @@ import 'package:das_client/model/sfera/enums/xml_enum.dart'; enum DasArchitecture implements XmlEnum { - groundAdviceCalculation(xmlValue: "GroundAdviceCalculation"), - boardAdviceCalculation(xmlValue: "BoardAdviceCalculation"); + groundAdviceCalculation(xmlValue: 'GroundAdviceCalculation'), + boardAdviceCalculation(xmlValue: 'BoardAdviceCalculation'); const DasArchitecture({ required this.xmlValue, diff --git a/das_client/lib/model/sfera/enums/das_connectivity.dart b/das_client/lib/model/sfera/enums/das_connectivity.dart index 176323ad..90d9662a 100644 --- a/das_client/lib/model/sfera/enums/das_connectivity.dart +++ b/das_client/lib/model/sfera/enums/das_connectivity.dart @@ -1,8 +1,8 @@ import 'package:das_client/model/sfera/enums/xml_enum.dart'; enum DasConnectivity implements XmlEnum { - standalone(xmlValue: "Standalone"), - connected(xmlValue: "Connected"); + standalone(xmlValue: 'Standalone'), + connected(xmlValue: 'Connected'); const DasConnectivity({ required this.xmlValue, diff --git a/das_client/lib/model/sfera/enums/das_driving_mode.dart b/das_client/lib/model/sfera/enums/das_driving_mode.dart index 4cce5c40..b37a9495 100644 --- a/das_client/lib/model/sfera/enums/das_driving_mode.dart +++ b/das_client/lib/model/sfera/enums/das_driving_mode.dart @@ -1,14 +1,14 @@ import 'package:das_client/model/sfera/enums/xml_enum.dart'; enum DasDrivingMode implements XmlEnum { - inactive(xmlValue: "Inactive"), - timetable(xmlValue: "Timetable"), - readOnly(xmlValue: "Read-Only"), - dasNotConnected(xmlValue: "DAS not connected to ATP"), - goa1(xmlValue: "GoA1"), - goa2(xmlValue: "GoA2"), - goa3(xmlValue: "GoA3"), - goa4(xmlValue: "GoA4"); + inactive(xmlValue: 'Inactive'), + timetable(xmlValue: 'Timetable'), + readOnly(xmlValue: 'Read-Only'), + dasNotConnected(xmlValue: 'DAS not connected to ATP'), + goa1(xmlValue: 'GoA1'), + goa2(xmlValue: 'GoA2'), + goa3(xmlValue: 'GoA3'), + goa4(xmlValue: 'GoA4'); const DasDrivingMode({ required this.xmlValue, diff --git a/das_client/lib/model/sfera/enums/handshake_reject_reason.dart b/das_client/lib/model/sfera/enums/handshake_reject_reason.dart index 5da40f20..9e2848e0 100644 --- a/das_client/lib/model/sfera/enums/handshake_reject_reason.dart +++ b/das_client/lib/model/sfera/enums/handshake_reject_reason.dart @@ -1,13 +1,13 @@ import 'package:das_client/model/sfera/enums/xml_enum.dart'; enum HandshakeRejectReason implements XmlEnum { - atoVersionIncompatible(xmlValue: "ATO system version incompatible"), - sferaVersionIncompatible(xmlValue: "SFERA version incompatible"), - anotherDasAtoInCharge(xmlValue: "Another DAS-TS/ATO-TS in charge"), - dasInChargeUnkown(xmlValue: "DAS-TS/ATO-TS in charge unknown"), - architectureNotSupported(xmlValue: "Architecture not supported"), - connectivityNotSupported(xmlValue: "Connectivity not supported"), - archAndConnNotSupported(xmlValue: "Architecture and connectivity not supported"); + atoVersionIncompatible(xmlValue: 'ATO system version incompatible'), + sferaVersionIncompatible(xmlValue: 'SFERA version incompatible'), + anotherDasAtoInCharge(xmlValue: 'Another DAS-TS/ATO-TS in charge'), + dasInChargeUnkown(xmlValue: 'DAS-TS/ATO-TS in charge unknown'), + architectureNotSupported(xmlValue: 'Architecture not supported'), + connectivityNotSupported(xmlValue: 'Connectivity not supported'), + archAndConnNotSupported(xmlValue: 'Architecture and connectivity not supported'); const HandshakeRejectReason({ required this.xmlValue, diff --git a/das_client/lib/model/sfera/enums/related_train_request_type.dart b/das_client/lib/model/sfera/enums/related_train_request_type.dart index d73bf88f..e3029f54 100644 --- a/das_client/lib/model/sfera/enums/related_train_request_type.dart +++ b/das_client/lib/model/sfera/enums/related_train_request_type.dart @@ -1,11 +1,11 @@ import 'package:das_client/model/sfera/enums/xml_enum.dart'; enum RelatedTrainRequestType implements XmlEnum { - none(xmlValue: "None"), - ownTrain(xmlValue: "OwnTrain"), - relatedTrains(xmlValue: "RelatedTrains"), - ownTrainAndRelatedTrains(xmlValue: "OwnTrainAndRelatedTrains"), - ownTrainAndOrRelatedTrains(xmlValue: "OwnTrainAndOrRelatedTrains"); + none(xmlValue: 'None'), + ownTrain(xmlValue: 'OwnTrain'), + relatedTrains(xmlValue: 'RelatedTrains'), + ownTrainAndRelatedTrains(xmlValue: 'OwnTrainAndRelatedTrains'), + ownTrainAndOrRelatedTrains(xmlValue: 'OwnTrainAndOrRelatedTrains'); const RelatedTrainRequestType({ required this.xmlValue, diff --git a/das_client/lib/model/sfera/g2b_reply_payload.dart b/das_client/lib/model/sfera/g2b_reply_payload.dart index 9eee2f3a..fd84c44d 100644 --- a/das_client/lib/model/sfera/g2b_reply_payload.dart +++ b/das_client/lib/model/sfera/g2b_reply_payload.dart @@ -3,7 +3,7 @@ import 'package:das_client/model/sfera/segment_profile.dart'; import 'package:das_client/model/sfera/sfera_xml_element.dart'; class G2bReplyPayload extends SferaXmlElement { - static const String elementType = "G2B_ReplyPayload"; + static const String elementType = 'G2B_ReplyPayload'; G2bReplyPayload({super.type = elementType, super.attributes, super.children, super.value}); diff --git a/das_client/lib/model/sfera/handshake_acknowledgement.dart b/das_client/lib/model/sfera/handshake_acknowledgement.dart index 6f948b48..6654c287 100644 --- a/das_client/lib/model/sfera/handshake_acknowledgement.dart +++ b/das_client/lib/model/sfera/handshake_acknowledgement.dart @@ -2,7 +2,7 @@ import 'package:das_client/model/sfera/das_operating_modes_selected.dart'; import 'package:das_client/model/sfera/sfera_xml_element.dart'; class HandshakeAcknowledgement extends SferaXmlElement { - static const String elementType = "HandshakeAcknowledgement"; + static const String elementType = 'HandshakeAcknowledgement'; HandshakeAcknowledgement({super.type = elementType, super.attributes, super.children, super.value}); @@ -10,6 +10,6 @@ class HandshakeAcknowledgement extends SferaXmlElement { @override bool validate() { - return validateHasChild("DAS_OperatingModeSelected") && super.validate(); + return validateHasChild('DAS_OperatingModeSelected') && super.validate(); } } diff --git a/das_client/lib/model/sfera/handshake_reject.dart b/das_client/lib/model/sfera/handshake_reject.dart index 84f2f267..054cbeb1 100644 --- a/das_client/lib/model/sfera/handshake_reject.dart +++ b/das_client/lib/model/sfera/handshake_reject.dart @@ -4,14 +4,14 @@ import 'package:das_client/model/sfera/sfera_xml_element.dart'; import 'package:das_client/model/sfera/sp_zone.dart'; class HandshakeReject extends SferaXmlElement { - static const String elementType = "HandshakeReject"; + static const String elementType = 'HandshakeReject'; HandshakeReject({super.type = elementType, super.attributes, super.children, super.value}); SpZone? get spZone => children.whereType().firstOrNull; - String? get atotsId => attributes["ATOTS_ID"]; + String? get atotsId => attributes['ATOTS_ID']; HandshakeRejectReason? get handshakeRejectReason => - XmlEnum.valueOf(HandshakeRejectReason.values, attributes["handshakeRejectReason"]); + XmlEnum.valueOf(HandshakeRejectReason.values, attributes['handshakeRejectReason']); } diff --git a/das_client/lib/model/sfera/handshake_request.dart b/das_client/lib/model/sfera/handshake_request.dart index 5d2b7fe5..d41e0abd 100644 --- a/das_client/lib/model/sfera/handshake_request.dart +++ b/das_client/lib/model/sfera/handshake_request.dart @@ -3,7 +3,7 @@ import 'package:das_client/model/sfera/enums/related_train_request_type.dart'; import 'package:das_client/model/sfera/sfera_xml_element.dart'; class HandshakeRequest extends SferaXmlElement { - static const String elementType = "HandshakeRequest"; + static const String elementType = 'HandshakeRequest'; HandshakeRequest({super.type = elementType, super.attributes, super.children, super.value}); @@ -12,13 +12,13 @@ class HandshakeRequest extends SferaXmlElement { final request = HandshakeRequest(); request.children.addAll(supportedOperatingModes); if (relatedTrainRequestType != null) { - request.attributes["relatedTrainRequest"] = relatedTrainRequestType.xmlValue; + request.attributes['relatedTrainRequest'] = relatedTrainRequestType.xmlValue; } if (statusReportsEnabled != null) { - request.attributes["statusReportsEnabled"] = statusReportsEnabled.toString(); + request.attributes['statusReportsEnabled'] = statusReportsEnabled.toString(); } if (additionalInfo != null) { - request.attributes["additionalInfo"] = additionalInfo; + request.attributes['additionalInfo'] = additionalInfo; } return request; } diff --git a/das_client/lib/model/sfera/journey_profile.dart b/das_client/lib/model/sfera/journey_profile.dart index 6ca1d936..ae26832e 100644 --- a/das_client/lib/model/sfera/journey_profile.dart +++ b/das_client/lib/model/sfera/journey_profile.dart @@ -3,7 +3,7 @@ import 'package:das_client/model/sfera/sfera_xml_element.dart'; import 'package:das_client/model/sfera/train_identification.dart'; class JourneyProfile extends SferaXmlElement { - static const String elementType = "JourneyProfile"; + static const String elementType = 'JourneyProfile'; JourneyProfile({super.type = elementType, super.attributes, super.children, super.value}); @@ -13,6 +13,6 @@ class JourneyProfile extends SferaXmlElement { @override bool validate() { - return validateHasChild("TrainIdentification") && super.validate(); + return validateHasChild('TrainIdentification') && super.validate(); } } diff --git a/das_client/lib/model/sfera/jp_request.dart b/das_client/lib/model/sfera/jp_request.dart index 5232b6df..a705d211 100644 --- a/das_client/lib/model/sfera/jp_request.dart +++ b/das_client/lib/model/sfera/jp_request.dart @@ -2,7 +2,7 @@ import 'package:das_client/model/sfera/sfera_xml_element.dart'; import 'package:das_client/model/sfera/train_identification.dart'; class JpRequest extends SferaXmlElement { - static const String elementType = "JP_Request"; + static const String elementType = 'JP_Request'; JpRequest({super.type = elementType, super.attributes, super.children, super.value}); diff --git a/das_client/lib/model/sfera/message_header.dart b/das_client/lib/model/sfera/message_header.dart index 671711d4..b233146a 100644 --- a/das_client/lib/model/sfera/message_header.dart +++ b/das_client/lib/model/sfera/message_header.dart @@ -2,48 +2,48 @@ import 'package:das_client/model/sfera/sfera_xml_element.dart'; import 'package:das_client/model/sfera/train_identification.dart'; class MessageHeader extends SferaXmlElement { - static const String elementType = "MessageHeader"; + static const String elementType = 'MessageHeader'; MessageHeader({super.type = elementType, super.attributes, super.children, super.value}); factory MessageHeader.create(String messageId, String timestamp, String sourceDevice, String destinationDevice, String sender, String recipient, {TrainIdentification? trainIdentification}) { final messageHeader = MessageHeader(); - messageHeader.attributes["SFERA_version"] = "2.01"; - messageHeader.attributes["message_ID"] = messageId; - messageHeader.attributes["timestamp"] = timestamp; - messageHeader.attributes["sourceDevice"] = sourceDevice; - messageHeader.attributes["destinationDevice"] = destinationDevice; + messageHeader.attributes['SFERA_version'] = '2.01'; + messageHeader.attributes['message_ID'] = messageId; + messageHeader.attributes['timestamp'] = timestamp; + messageHeader.attributes['sourceDevice'] = sourceDevice; + messageHeader.attributes['destinationDevice'] = destinationDevice; if (trainIdentification != null) { messageHeader.children.add(trainIdentification); } - messageHeader.children.add(SferaXmlElement(type: "Sender", value: sender)); - messageHeader.children.add(SferaXmlElement(type: "Recipient", value: recipient)); + messageHeader.children.add(SferaXmlElement(type: 'Sender', value: sender)); + messageHeader.children.add(SferaXmlElement(type: 'Recipient', value: recipient)); return messageHeader; } - String get sferaVersion => attributes["SFERA_version"]!; + String get sferaVersion => attributes['SFERA_version']!; - String get messageId => attributes["message_ID"]!; + String get messageId => attributes['message_ID']!; - String get correlationId => attributes["correlation_ID"]!; + String get correlationId => attributes['correlation_ID']!; - String get timestamp => attributes["timestamp"]!; + String get timestamp => attributes['timestamp']!; - String get sourceDevice => attributes["timestamp"]!; + String get sourceDevice => attributes['timestamp']!; - String get sender => childrenWithType("Sender").first.value!; + String get sender => childrenWithType('Sender').first.value!; - String get recipient => childrenWithType("Recipient").first.value!; + String get recipient => childrenWithType('Recipient').first.value!; @override bool validate() { - return validateHasChild("Sender") && - validateHasChild("Recipient") && - validateHasAttribute("SFERA_version") && - validateHasAttribute("message_ID") && - validateHasAttribute("timestamp") && - validateHasAttribute("sourceDevice") && + return validateHasChild('Sender') && + validateHasChild('Recipient') && + validateHasAttribute('SFERA_version') && + validateHasAttribute('message_ID') && + validateHasAttribute('timestamp') && + validateHasAttribute('sourceDevice') && super.validate(); } } diff --git a/das_client/lib/model/sfera/otn_id.dart b/das_client/lib/model/sfera/otn_id.dart index 84eeaeb8..c6b3989d 100644 --- a/das_client/lib/model/sfera/otn_id.dart +++ b/das_client/lib/model/sfera/otn_id.dart @@ -2,40 +2,40 @@ import 'package:das_client/model/sfera/sfera_xml_element.dart'; import 'package:das_client/util/format.dart'; class OtnId extends SferaXmlElement { - static const String elementType = "OTN_ID"; + static const String elementType = 'OTN_ID'; OtnId({super.type = elementType, super.attributes, super.children, super.value}); factory OtnId.create(String company, String operationalTrainNumber, DateTime startDate, {String? additionalTrainNumber}) { final otnId = OtnId(); - otnId.children.add(SferaXmlElement(type: "Company", value: company)); - otnId.children.add(SferaXmlElement(type: "OperationalTrainNumber", value: operationalTrainNumber)); - otnId.children.add(SferaXmlElement(type: "StartDate", value: Format.sferaDate(startDate))); + otnId.children.add(SferaXmlElement(type: 'Company', value: company)); + otnId.children.add(SferaXmlElement(type: 'OperationalTrainNumber', value: operationalTrainNumber)); + otnId.children.add(SferaXmlElement(type: 'StartDate', value: Format.sferaDate(startDate))); if (additionalTrainNumber != null) { - otnId.children.add(SferaXmlElement(type: "AdditionalTrainNumber", value: additionalTrainNumber)); + otnId.children.add(SferaXmlElement(type: 'AdditionalTrainNumber', value: additionalTrainNumber)); } return otnId; } - String get company => childrenWithType("Company").first.value!; + String get company => childrenWithType('Company').first.value!; - String get operationalTrainNumber => childrenWithType("OperationalTrainNumber").first.value!; + String get operationalTrainNumber => childrenWithType('OperationalTrainNumber').first.value!; - String? get additionalTrainNumber => childrenWithType("AdditionalTrainNumber").firstOrNull?.value; + String? get additionalTrainNumber => childrenWithType('AdditionalTrainNumber').firstOrNull?.value; - DateTime get startDate => DateTime.parse(childrenWithType("StartDate").first.value!); + DateTime get startDate => DateTime.parse(childrenWithType('StartDate').first.value!); @override bool validate() { - return validateHasChild("Company") && - validateHasChild("OperationalTrainNumber") && - validateHasChild("StartDate") && + return validateHasChild('Company') && + validateHasChild('OperationalTrainNumber') && + validateHasChild('StartDate') && super.validate(); } @override toString() { - return "OtnId(company: $company, operationalTrainNumber: $operationalTrainNumber, startDate: $startDate, additionalTrainNumber: $additionalTrainNumber)"; + return 'OtnId(company: $company, operationalTrainNumber: $operationalTrainNumber, startDate: $startDate, additionalTrainNumber: $additionalTrainNumber)'; } } diff --git a/das_client/lib/model/sfera/segment_profile.dart b/das_client/lib/model/sfera/segment_profile.dart index 16bb0e4a..83b2f487 100644 --- a/das_client/lib/model/sfera/segment_profile.dart +++ b/das_client/lib/model/sfera/segment_profile.dart @@ -3,14 +3,14 @@ import 'package:das_client/model/sfera/sp_points.dart'; import 'package:das_client/model/sfera/sp_zone.dart'; class SegmentProfile extends SferaXmlElement { - static const String elementType = "SegmentProfile"; + static const String elementType = 'SegmentProfile'; SegmentProfile({super.type = elementType, super.attributes, super.children, super.value}); - String get versionMajor => attributes["SP_VersionMajor"]!; - String get versionMinor => attributes["SP_VersionMinor"]!; - String get length => attributes["SP_Length"]!; - String get id => attributes["SP_ID"]!; + String get versionMajor => attributes['SP_VersionMajor']!; + String get versionMinor => attributes['SP_VersionMinor']!; + String get length => attributes['SP_Length']!; + String get id => attributes['SP_ID']!; SpZone? get zone => children.whereType().firstOrNull; @@ -18,10 +18,10 @@ class SegmentProfile extends SferaXmlElement { @override bool validate() { - return validateHasAttribute("SP_VersionMajor") && - validateHasAttribute("SP_VersionMinor") && - validateHasAttribute("SP_Length") && - validateHasAttribute("SP_ID") && + return validateHasAttribute('SP_VersionMajor') && + validateHasAttribute('SP_VersionMinor') && + validateHasAttribute('SP_Length') && + validateHasAttribute('SP_ID') && super.validate(); } } diff --git a/das_client/lib/model/sfera/segment_profile_list.dart b/das_client/lib/model/sfera/segment_profile_list.dart index 6b07d272..27a01af5 100644 --- a/das_client/lib/model/sfera/segment_profile_list.dart +++ b/das_client/lib/model/sfera/segment_profile_list.dart @@ -3,15 +3,15 @@ import 'package:das_client/model/sfera/sp_zone.dart'; import 'package:das_client/model/sfera/timing_point_constraints.dart'; class SegmentProfileList extends SferaXmlElement { - static const String elementType = "SegmentProfileList"; + static const String elementType = 'SegmentProfileList'; SegmentProfileList({super.type = elementType, super.attributes, super.children, super.value}); - String get spId => attributes["SP_ID"]!; + String get spId => attributes['SP_ID']!; - String get versionMajor => attributes["SP_VersionMajor"]!; + String get versionMajor => attributes['SP_VersionMajor']!; - String get versionMinor => attributes["SP_VersionMinor"]!; + String get versionMinor => attributes['SP_VersionMinor']!; SpZone get spZone => children.whereType().first; @@ -19,9 +19,9 @@ class SegmentProfileList extends SferaXmlElement { @override bool validate() { - return validateHasAttribute("SP_ID") && - validateHasAttribute("SP_VersionMajor") && - validateHasAttribute("SP_VersionMinor") && + return validateHasAttribute('SP_ID') && + validateHasAttribute('SP_VersionMajor') && + validateHasAttribute('SP_VersionMinor') && validateHasChildOfType() && super.validate(); } diff --git a/das_client/lib/model/sfera/sfera_b2g_request_message.dart b/das_client/lib/model/sfera/sfera_b2g_request_message.dart index dd198887..08496800 100644 --- a/das_client/lib/model/sfera/sfera_b2g_request_message.dart +++ b/das_client/lib/model/sfera/sfera_b2g_request_message.dart @@ -4,7 +4,7 @@ import 'package:das_client/model/sfera/message_header.dart'; import 'package:das_client/model/sfera/sfera_xml_element.dart'; class SferaB2gRequestMessage extends SferaXmlElement { - static const String elementType = "SFERA_B2G_RequestMessage"; + static const String elementType = 'SFERA_B2G_RequestMessage'; SferaB2gRequestMessage({super.type = elementType, super.attributes, super.children, super.value}); diff --git a/das_client/lib/model/sfera/sfera_g2b_reply_message.dart b/das_client/lib/model/sfera/sfera_g2b_reply_message.dart index c80b6fbb..3d91d917 100644 --- a/das_client/lib/model/sfera/sfera_g2b_reply_message.dart +++ b/das_client/lib/model/sfera/sfera_g2b_reply_message.dart @@ -5,7 +5,7 @@ import 'package:das_client/model/sfera/message_header.dart'; import 'package:das_client/model/sfera/sfera_xml_element.dart'; class SferaG2bReplyMessage extends SferaXmlElement { - static const String elementType = "SFERA_G2B_ReplyMessage"; + static const String elementType = 'SFERA_G2B_ReplyMessage'; SferaG2bReplyMessage({super.type = elementType, super.attributes, super.children, super.value}); diff --git a/das_client/lib/model/sfera/sfera_xml_element.dart b/das_client/lib/model/sfera/sfera_xml_element.dart index 5aa49db5..4de53d7f 100644 --- a/das_client/lib/model/sfera/sfera_xml_element.dart +++ b/das_client/lib/model/sfera/sfera_xml_element.dart @@ -18,7 +18,7 @@ class SferaXmlElement { bool validateHasAttribute(String attribute) { if (!attributes.containsKey(attribute)) { - Fimber.w("Validation failed for $type because attribute $attribute is missing"); + Fimber.w('Validation failed for $type because attribute $attribute is missing'); return false; } @@ -27,7 +27,7 @@ class SferaXmlElement { bool validateHasChild(String type) { if (childrenWithType(type).isEmpty) { - Fimber.w("Validation failed for ${this.type} because it has no child of type $type"); + Fimber.w('Validation failed for ${this.type} because it has no child of type $type'); return false; } @@ -36,7 +36,7 @@ class SferaXmlElement { bool validateHasChildOfType() { if (children.whereType().isEmpty) { - Fimber.w("Validation failed for $type because it has no child of type ${T.toString()}"); + Fimber.w('Validation failed for $type because it has no child of type ${T.toString()}'); return false; } @@ -58,7 +58,7 @@ class SferaXmlElement { } if (XmlEnum.valueOf(allValues, attributes[attribute]!) == null) { - Fimber.w("Validation failed for $type because attribute $attribute could not be mapped to Enum ${T.toString()}"); + Fimber.w('Validation failed for $type because attribute $attribute could not be mapped to Enum ${T.toString()}'); } return true; diff --git a/das_client/lib/model/sfera/signal.dart b/das_client/lib/model/sfera/signal.dart index efd7b29f..933c5411 100644 --- a/das_client/lib/model/sfera/signal.dart +++ b/das_client/lib/model/sfera/signal.dart @@ -2,7 +2,7 @@ import 'package:das_client/model/sfera/sfera_xml_element.dart'; import 'package:das_client/model/sfera/signal_id.dart'; class Signal extends SferaXmlElement { - static const String elementType = "Signal"; + static const String elementType = 'Signal'; Signal({super.type = elementType, super.attributes, super.children, super.value}); @@ -10,6 +10,6 @@ class Signal extends SferaXmlElement { @override bool validate() { - return validateHasChild("Signal_ID") && super.validate(); + return validateHasChild('Signal_ID') && super.validate(); } } diff --git a/das_client/lib/model/sfera/signal_id.dart b/das_client/lib/model/sfera/signal_id.dart index db860722..aa0622c4 100644 --- a/das_client/lib/model/sfera/signal_id.dart +++ b/das_client/lib/model/sfera/signal_id.dart @@ -1,16 +1,16 @@ import 'package:das_client/model/sfera/sfera_xml_element.dart'; class SignalId extends SferaXmlElement { - static const String elementType = "Signal_ID"; + static const String elementType = 'Signal_ID'; SignalId({super.type = elementType, super.attributes, super.children, super.value}); - String get physicalId => attributes["signal_ID_Physical"]!; + String get physicalId => attributes['signal_ID_Physical']!; - String get location => attributes["location"]!; + String get location => attributes['location']!; @override bool validate() { - return validateHasAttribute("signal_ID_Physical") && validateHasAttribute("location") && super.validate(); + return validateHasAttribute('signal_ID_Physical') && validateHasAttribute('location') && super.validate(); } } diff --git a/das_client/lib/model/sfera/sp_points.dart b/das_client/lib/model/sfera/sp_points.dart index 7150c1a6..e3f19d45 100644 --- a/das_client/lib/model/sfera/sp_points.dart +++ b/das_client/lib/model/sfera/sp_points.dart @@ -4,7 +4,7 @@ import 'package:das_client/model/sfera/timing_point.dart'; import 'package:das_client/model/sfera/virtual_balise.dart'; class SpPoints extends SferaXmlElement { - static const String elementType = "SP_Points"; + static const String elementType = 'SP_Points'; SpPoints({super.type = elementType, super.attributes, super.children, super.value}); diff --git a/das_client/lib/model/sfera/sp_request.dart b/das_client/lib/model/sfera/sp_request.dart index 07ed4214..b398a30e 100644 --- a/das_client/lib/model/sfera/sp_request.dart +++ b/das_client/lib/model/sfera/sp_request.dart @@ -2,15 +2,15 @@ import 'package:das_client/model/sfera/sfera_xml_element.dart'; import 'package:das_client/model/sfera/sp_zone.dart'; class SpRequest extends SferaXmlElement { - static const String elementType = "SP_Request"; + static const String elementType = 'SP_Request'; SpRequest({super.type = elementType, super.attributes, super.children, super.value}); factory SpRequest.create({required String id, required String versionMajor, required String versionMinor, required SpZone spZone}) { final request = SpRequest(); - request.attributes["SP_ID"] = id; - request.attributes["SP_VersionMajor"] = versionMajor; - request.attributes["SP_VersionMinor"] = versionMinor; + request.attributes['SP_ID'] = id; + request.attributes['SP_VersionMajor'] = versionMajor; + request.attributes['SP_VersionMinor'] = versionMinor; request.children.add(spZone); return request; } diff --git a/das_client/lib/model/sfera/sp_zone.dart b/das_client/lib/model/sfera/sp_zone.dart index f9299a2e..72ea40db 100644 --- a/das_client/lib/model/sfera/sp_zone.dart +++ b/das_client/lib/model/sfera/sp_zone.dart @@ -1,16 +1,16 @@ import 'package:das_client/model/sfera/sfera_xml_element.dart'; class SpZone extends SferaXmlElement { - static const String elementType = "SP_Zone"; + static const String elementType = 'SP_Zone'; SpZone({super.type = elementType, super.attributes, super.children, super.value}); - String? get imId => childrenWithType("IM_ID").firstOrNull?.value; + String? get imId => childrenWithType('IM_ID').firstOrNull?.value; - String? get nidC => childrenWithType("NID_C").firstOrNull?.value; + String? get nidC => childrenWithType('NID_C').firstOrNull?.value; @override bool validate() { - return validateHasChild("IM_ID") || validateHasChild("NID_C"); + return validateHasChild('IM_ID') || validateHasChild('NID_C'); } } diff --git a/das_client/lib/model/sfera/stopping_point_information.dart b/das_client/lib/model/sfera/stopping_point_information.dart index eab667d9..a73b21af 100644 --- a/das_client/lib/model/sfera/stopping_point_information.dart +++ b/das_client/lib/model/sfera/stopping_point_information.dart @@ -1,14 +1,14 @@ import 'package:das_client/model/sfera/sfera_xml_element.dart'; class StoppingPointInformation extends SferaXmlElement { - static const String elementType = "StoppingPointInformation"; + static const String elementType = 'StoppingPointInformation'; StoppingPointInformation({super.type = elementType, super.attributes, super.children, super.value}); - String get departureTime => attributes["departureTime"]!; + String get departureTime => attributes['departureTime']!; @override bool validate() { - return validateHasAttribute("departureTime") && super.validate(); + return validateHasAttribute('departureTime') && super.validate(); } } diff --git a/das_client/lib/model/sfera/timing_point.dart b/das_client/lib/model/sfera/timing_point.dart index e9db1dad..914db755 100644 --- a/das_client/lib/model/sfera/timing_point.dart +++ b/das_client/lib/model/sfera/timing_point.dart @@ -2,18 +2,18 @@ import 'package:das_client/model/sfera/sfera_xml_element.dart'; import 'package:das_client/model/sfera/tp_name.dart'; class TimingPoint extends SferaXmlElement { - static const String elementType = "TimingPoint"; + static const String elementType = 'TimingPoint'; TimingPoint({super.type = elementType, super.attributes, super.children, super.value}); - String get id => attributes["TP_ID"]!; + String get id => attributes['TP_ID']!; - String get location => attributes["location"]!; + String get location => attributes['location']!; Iterable get names => children.whereType(); @override bool validate() { - return validateHasAttribute("TP_ID") && validateHasAttribute("location") && super.validate(); + return validateHasAttribute('TP_ID') && validateHasAttribute('location') && super.validate(); } } diff --git a/das_client/lib/model/sfera/timing_point_constraints.dart b/das_client/lib/model/sfera/timing_point_constraints.dart index b32e3245..7f3ec9ba 100644 --- a/das_client/lib/model/sfera/timing_point_constraints.dart +++ b/das_client/lib/model/sfera/timing_point_constraints.dart @@ -2,7 +2,7 @@ import 'package:das_client/model/sfera/sfera_xml_element.dart'; import 'package:das_client/model/sfera/timing_point_reference.dart'; class TimingPointConstraints extends SferaXmlElement { - static const String elementType = "TimingPointConstraints"; + static const String elementType = 'TimingPointConstraints'; TimingPointConstraints({super.type = elementType, super.attributes, super.children, super.value}); diff --git a/das_client/lib/model/sfera/timing_point_reference.dart b/das_client/lib/model/sfera/timing_point_reference.dart index 82f9af9d..dde84adb 100644 --- a/das_client/lib/model/sfera/timing_point_reference.dart +++ b/das_client/lib/model/sfera/timing_point_reference.dart @@ -1,7 +1,7 @@ import 'package:das_client/model/sfera/sfera_xml_element.dart'; class TimingPointReference extends SferaXmlElement { - static const String elementType = "TimingPointReference"; + static const String elementType = 'TimingPointReference'; TimingPointReference({super.type = elementType, super.attributes, super.children, super.value}); } diff --git a/das_client/lib/model/sfera/tp_id_reference.dart b/das_client/lib/model/sfera/tp_id_reference.dart index c14513b1..54687b1d 100644 --- a/das_client/lib/model/sfera/tp_id_reference.dart +++ b/das_client/lib/model/sfera/tp_id_reference.dart @@ -1,14 +1,14 @@ import 'package:das_client/model/sfera/sfera_xml_element.dart'; class TpIdReference extends SferaXmlElement { - static const String elementType = "TP_ID_Reference"; + static const String elementType = 'TP_ID_Reference'; TpIdReference({super.type = elementType, super.attributes, super.children, super.value}); - String get tpId => attributes["TP_ID"]!; + String get tpId => attributes['TP_ID']!; @override bool validate() { - return validateHasAttribute("TP_ID") && super.validate(); + return validateHasAttribute('TP_ID') && super.validate(); } } diff --git a/das_client/lib/model/sfera/tp_name.dart b/das_client/lib/model/sfera/tp_name.dart index ef5d13d9..ae355015 100644 --- a/das_client/lib/model/sfera/tp_name.dart +++ b/das_client/lib/model/sfera/tp_name.dart @@ -1,14 +1,14 @@ import 'package:das_client/model/sfera/sfera_xml_element.dart'; class TpName extends SferaXmlElement { - static const String elementType = "TP_Name"; + static const String elementType = 'TP_Name'; TpName({super.type = elementType, super.attributes, super.children, super.value}); - String get name => attributes["name"]!; + String get name => attributes['name']!; @override bool validate() { - return validateHasAttribute("name") && super.validate(); + return validateHasAttribute('name') && super.validate(); } } diff --git a/das_client/lib/model/sfera/train_identification.dart b/das_client/lib/model/sfera/train_identification.dart index 255bab96..f3276486 100644 --- a/das_client/lib/model/sfera/train_identification.dart +++ b/das_client/lib/model/sfera/train_identification.dart @@ -2,7 +2,7 @@ import 'package:das_client/model/sfera/otn_id.dart'; import 'package:das_client/model/sfera/sfera_xml_element.dart'; class TrainIdentification extends SferaXmlElement { - static const String elementType = "TrainIdentification"; + static const String elementType = 'TrainIdentification'; TrainIdentification({super.type = elementType, super.attributes, super.children, super.value}); diff --git a/das_client/lib/model/sfera/virtual_balise.dart b/das_client/lib/model/sfera/virtual_balise.dart index fe36cd2e..0cc65003 100644 --- a/das_client/lib/model/sfera/virtual_balise.dart +++ b/das_client/lib/model/sfera/virtual_balise.dart @@ -2,16 +2,16 @@ import 'package:das_client/model/sfera/sfera_xml_element.dart'; import 'package:das_client/model/sfera/virtual_balise_position.dart'; class VirtualBalise extends SferaXmlElement { - static const String elementType = "VirtualBalise"; + static const String elementType = 'VirtualBalise'; VirtualBalise({super.type = elementType, super.attributes, super.children, super.value}); VirtualBalisePosition get position => children.whereType().first; - String get location => attributes["location"]!; + String get location => attributes['location']!; @override bool validate() { - return validateHasAttribute("location") && validateHasChildOfType() && super.validate(); + return validateHasAttribute('location') && validateHasChildOfType() && super.validate(); } } diff --git a/das_client/lib/model/sfera/virtual_balise_position.dart b/das_client/lib/model/sfera/virtual_balise_position.dart index f3be73ab..a5e00104 100644 --- a/das_client/lib/model/sfera/virtual_balise_position.dart +++ b/das_client/lib/model/sfera/virtual_balise_position.dart @@ -1,18 +1,18 @@ import 'package:das_client/model/sfera/sfera_xml_element.dart'; class VirtualBalisePosition extends SferaXmlElement { - static const String elementType = "VirtualBalisePosition"; + static const String elementType = 'VirtualBalisePosition'; VirtualBalisePosition({super.type = elementType, super.attributes, super.children, super.value}); - String get latitude => attributes["latitude"]!; + String get latitude => attributes['latitude']!; - String get longitude => attributes["longitude"]!; + String get longitude => attributes['longitude']!; - String? get altitude => attributes["altitude"]!; + String? get altitude => attributes['altitude']!; @override bool validate() { - return validateHasAttribute("latitude") && validateHasAttribute("longitude") && super.validate(); + return validateHasAttribute('latitude') && validateHasAttribute('longitude') && super.validate(); } } diff --git a/das_client/lib/nav/das_navigation_drawer.dart b/das_client/lib/nav/das_navigation_drawer.dart index 6d110012..689be15c 100644 --- a/das_client/lib/nav/das_navigation_drawer.dart +++ b/das_client/lib/nav/das_navigation_drawer.dart @@ -1,5 +1,5 @@ import 'package:auto_route/auto_route.dart'; -import 'package:das_client/i18n/src/build_context_x.dart'; +import 'package:das_client/i18n/i18n.dart'; import 'package:das_client/nav/app_router.dart'; import 'package:das_client/widgets/app_version_text.dart'; import 'package:das_client/widgets/device_id_text.dart'; diff --git a/das_client/lib/pages/fahrt/fahrt_page.dart b/das_client/lib/pages/fahrt/fahrt_page.dart index 5cd9b1ec..c945c1da 100644 --- a/das_client/lib/pages/fahrt/fahrt_page.dart +++ b/das_client/lib/pages/fahrt/fahrt_page.dart @@ -2,7 +2,7 @@ import 'package:auto_route/auto_route.dart'; import 'package:das_client/auth/auth_cubit.dart'; import 'package:das_client/bloc/fahrbild_cubit.dart'; import 'package:das_client/di.dart'; -import 'package:das_client/i18n/src/build_context_x.dart'; +import 'package:das_client/i18n/i18n.dart'; import 'package:das_client/nav/app_router.dart'; import 'package:das_client/nav/das_navigation_drawer.dart'; import 'package:das_client/pages/fahrt/widgets/fahrbild.dart'; diff --git a/das_client/lib/pages/fahrt/widgets/fahrbild.dart b/das_client/lib/pages/fahrt/widgets/fahrbild.dart index 578c44d1..908f90e2 100644 --- a/das_client/lib/pages/fahrt/widgets/fahrbild.dart +++ b/das_client/lib/pages/fahrt/widgets/fahrbild.dart @@ -39,11 +39,11 @@ class Fahrbild extends StatelessWidget { padding: const EdgeInsets.all(8.0), child: Row( children: [ - Text(timingPoint.attributes["TP_PlannedLatestArrivalTime"] ?? ""), + Text(timingPoint.attributes['TP_PlannedLatestArrivalTime'] ?? ''), const SizedBox( width: sbbDefaultSpacing, ), - Text(tp?.names.first.name ?? "unkown"), + Text(tp?.names.first.name ?? 'unkown'), ], ), ); diff --git a/das_client/lib/pages/fahrt/widgets/train_selection.dart b/das_client/lib/pages/fahrt/widgets/train_selection.dart index d916f9f3..7342f5ce 100644 --- a/das_client/lib/pages/fahrt/widgets/train_selection.dart +++ b/das_client/lib/pages/fahrt/widgets/train_selection.dart @@ -19,8 +19,8 @@ class _TrainSelectionState extends State { @override void initState() { super.initState(); - _trainNumberController = TextEditingController(text: "7839"); - _companyController = TextEditingController(text: "1085"); + _trainNumberController = TextEditingController(text: '7839'); + _companyController = TextEditingController(text: '1085'); context.fahrbildCubit.updateTrainNumber(_trainNumberController.text); context.fahrbildCubit.updateCompany(_companyController.text); @@ -75,7 +75,7 @@ class _TrainSelectionState extends State { Widget _errorWidget(BuildContext context, FahrbildState state) { if (state is SelectingFahrbildState && state.errorCode != null) { - return Text("${state.errorCode}", style: SBBTextStyles.mediumBold); + return Text('${state.errorCode}', style: SBBTextStyles.mediumBold); } return Container(); } diff --git a/das_client/lib/pages/links/links_page.dart b/das_client/lib/pages/links/links_page.dart index 32d06a0e..16cffdcf 100644 --- a/das_client/lib/pages/links/links_page.dart +++ b/das_client/lib/pages/links/links_page.dart @@ -1,5 +1,5 @@ import 'package:auto_route/auto_route.dart'; -import 'package:das_client/i18n/src/build_context_x.dart'; +import 'package:das_client/i18n/i18n.dart'; import 'package:das_client/nav/das_navigation_drawer.dart'; import 'package:design_system_flutter/design_system_flutter.dart'; import 'package:flutter/material.dart'; diff --git a/das_client/lib/pages/profile/profile_page.dart b/das_client/lib/pages/profile/profile_page.dart index 399d0d79..1776eb70 100644 --- a/das_client/lib/pages/profile/profile_page.dart +++ b/das_client/lib/pages/profile/profile_page.dart @@ -1,5 +1,5 @@ import 'package:auto_route/auto_route.dart'; -import 'package:das_client/i18n/src/build_context_x.dart'; +import 'package:das_client/i18n/i18n.dart'; import 'package:das_client/nav/das_navigation_drawer.dart'; import 'package:design_system_flutter/design_system_flutter.dart'; import 'package:flutter/material.dart'; diff --git a/das_client/lib/pages/settings/settings_page.dart b/das_client/lib/pages/settings/settings_page.dart index d7a807c9..366098f5 100644 --- a/das_client/lib/pages/settings/settings_page.dart +++ b/das_client/lib/pages/settings/settings_page.dart @@ -1,5 +1,5 @@ import 'package:auto_route/auto_route.dart'; -import 'package:das_client/i18n/src/build_context_x.dart'; +import 'package:das_client/i18n/i18n.dart'; import 'package:das_client/nav/das_navigation_drawer.dart'; import 'package:design_system_flutter/design_system_flutter.dart'; import 'package:flutter/material.dart'; diff --git a/das_client/lib/repo/sfera_repository.dart b/das_client/lib/repo/sfera_repository.dart index af71e5f8..cdcfa16f 100644 --- a/das_client/lib/repo/sfera_repository.dart +++ b/das_client/lib/repo/sfera_repository.dart @@ -39,7 +39,7 @@ class SferaRepository { journeyProfile.toEntity(id: existingProfile?.id ?? _db.journeyProfile.autoIncrement(), startDate: today); Fimber.i( - "Writing journey profile to db company=${journeyProfileEntity.company} operationalTrainNumber=${journeyProfileEntity.operationalTrainNumber} startDate=${journeyProfileEntity.startDate}"); + 'Writing journey profile to db company=${journeyProfileEntity.company} operationalTrainNumber=${journeyProfileEntity.operationalTrainNumber} startDate=${journeyProfileEntity.startDate}'); await _db.writeAsync((isar) { isar.journeyProfile.put(journeyProfileEntity); }); @@ -53,13 +53,13 @@ class SferaRepository { if (existingProfile == null) { final segmentProfileEntity = segmentProfile.toEntity(isarId: _db.segmentProfile.autoIncrement()); Fimber.i( - "Writing segment profile to db spId=${segmentProfileEntity.spId} majorVersion=${segmentProfileEntity.majorVersion} minorVersion=${segmentProfileEntity.minorVersion}"); + 'Writing segment profile to db spId=${segmentProfileEntity.spId} majorVersion=${segmentProfileEntity.majorVersion} minorVersion=${segmentProfileEntity.minorVersion}'); _db.write((isar) { isar.segmentProfile.put(segmentProfileEntity); }); } else { Fimber.i( - "Segment profile already exists in db spId=${segmentProfile.id} majorVersion=${segmentProfile.versionMajor} minorVersion=${segmentProfile.versionMinor}"); + 'Segment profile already exists in db spId=${segmentProfile.id} majorVersion=${segmentProfile.versionMajor} minorVersion=${segmentProfile.versionMinor}'); } } diff --git a/das_client/lib/service/backend_service.dart b/das_client/lib/service/backend_service.dart index 2ded59b9..c4a5b542 100644 --- a/das_client/lib/service/backend_service.dart +++ b/das_client/lib/service/backend_service.dart @@ -2,7 +2,7 @@ import 'dart:convert'; import 'dart:core'; import 'package:das_client/auth/authenticator.dart'; -import 'package:das_client/logging/src/log_entry.dart'; +import 'package:das_client/logging/logging_component.dart'; import 'package:fimber/fimber.dart'; import 'package:http/http.dart' as http; @@ -15,7 +15,7 @@ class BackendService { _baseUrl = baseUrl; Future sendLogs(List logs) async { - Fimber.i("Trying to send logs to backend..."); + Fimber.i('Trying to send logs to backend...'); final url = Uri.parse('$_baseUrl/api/v1/logging/logs'); var authToken = await _authenticator.token(); @@ -29,10 +29,10 @@ class BackendService { var statusCode = response.statusCode; if (statusCode >= 200 && statusCode < 300) { - Fimber.i("Successfully sent logs to backend"); + Fimber.i('Successfully sent logs to backend'); return true; } else { - Fimber.w("Failed to send logs to backend. StatusCode=$statusCode"); + Fimber.w('Failed to send logs to backend. StatusCode=$statusCode'); return false; } } diff --git a/das_client/lib/service/mqtt/mqtt_client_oauth_connector.dart b/das_client/lib/service/mqtt/mqtt_client_oauth_connector.dart index b78889ed..6358c71c 100644 --- a/das_client/lib/service/mqtt/mqtt_client_oauth_connector.dart +++ b/das_client/lib/service/mqtt/mqtt_client_oauth_connector.dart @@ -14,31 +14,31 @@ class MqttClientOauthConnector implements MqttClientConnector { @override Future connect(MqttClient client, String company, String train) async { - Fimber.i("Connecting to mqtt using oauth token"); + Fimber.i('Connecting to mqtt using oauth token'); - var sferaAuthToken = await _sferaAuthService.retrieveSferaAuthToken(company, train, "active"); + var sferaAuthToken = await _sferaAuthService.retrieveSferaAuthToken(company, train, 'active'); - Fimber.i("Received sfera token=${sferaAuthToken?.substring(0, 20)}"); + Fimber.i('Received sfera token=${sferaAuthToken?.substring(0, 20)}'); var token = await _authenticator.token(); var jsonWebToken = token.accessToken.toJwt(); - var userId = jsonWebToken.payload["preferred_username"]; - Fimber.i("Using userId=$userId"); + var userId = jsonWebToken.payload['preferred_username']; + Fimber.i('Using userId=$userId'); if (sferaAuthToken != null && userId != null) { try { - var mqttClientConnectionStatus = await client.connect(userId, "OAUTH~azureAd~$sferaAuthToken"); - Fimber.i("mqttClientConnectionStatus=$mqttClientConnectionStatus"); + var mqttClientConnectionStatus = await client.connect(userId, 'OAUTH~azureAd~$sferaAuthToken'); + Fimber.i('mqttClientConnectionStatus=$mqttClientConnectionStatus'); if (mqttClientConnectionStatus?.state == MqttConnectionState.connected) { - Fimber.i("Successfully connected to MQTT broker"); + Fimber.i('Successfully connected to MQTT broker'); return true; } } catch (e) { - Fimber.e("Exception during connect", ex: e); + Fimber.e('Exception during connect', ex: e); } } - Fimber.w("Failed to connect to MQTT broker"); + Fimber.w('Failed to connect to MQTT broker'); return false; } } diff --git a/das_client/lib/service/mqtt/mqtt_client_tms_oauth_connector.dart b/das_client/lib/service/mqtt/mqtt_client_tms_oauth_connector.dart index ea76db7d..43de1505 100644 --- a/das_client/lib/service/mqtt/mqtt_client_tms_oauth_connector.dart +++ b/das_client/lib/service/mqtt/mqtt_client_tms_oauth_connector.dart @@ -10,26 +10,26 @@ class MqttClientTMSOauthConnector implements MqttClientConnector { @override Future connect(MqttClient client, String company, String train) async { - Fimber.i("Connecting to TMS mqtt using oauth token"); + Fimber.i('Connecting to TMS mqtt using oauth token'); - var sferaAuthToken = await _sferaAuthService.retrieveSferaAuthToken(company, train, "active"); - Fimber.i("Received TMS sfera token=${sferaAuthToken?.substring(0, 20)}"); + var sferaAuthToken = await _sferaAuthService.retrieveSferaAuthToken(company, train, 'active'); + Fimber.i('Received TMS sfera token=${sferaAuthToken?.substring(0, 20)}'); if (sferaAuthToken != null) { try { - var mqttClientConnectionStatus = await client.connect("JWT", "OPENID~AzureAD_IMTS~~$sferaAuthToken"); - Fimber.i("mqttClientConnectionStatus=$mqttClientConnectionStatus"); + var mqttClientConnectionStatus = await client.connect('JWT', 'OPENID~AzureAD_IMTS~~$sferaAuthToken'); + Fimber.i('mqttClientConnectionStatus=$mqttClientConnectionStatus'); if (mqttClientConnectionStatus?.state == MqttConnectionState.connected) { - Fimber.i("Successfully connected to MQTT broker"); + Fimber.i('Successfully connected to MQTT broker'); return true; } } catch (e) { - Fimber.e("Exception during connect", ex: e); + Fimber.e('Exception during connect', ex: e); } } - Fimber.w("Failed to connect to MQTT broker"); + Fimber.w('Failed to connect to MQTT broker'); return false; } } diff --git a/das_client/lib/service/mqtt/mqtt_service.dart b/das_client/lib/service/mqtt/mqtt_service.dart index 0059e9a2..61a4cf45 100644 --- a/das_client/lib/service/mqtt/mqtt_service.dart +++ b/das_client/lib/service/mqtt/mqtt_service.dart @@ -36,7 +36,7 @@ class MqttService { } void disconnect() { - Fimber.i("Disconnecting from MQTT broker"); + Fimber.i('Disconnecting from MQTT broker'); _client.disconnect(); } @@ -45,8 +45,8 @@ class MqttService { _client.disconnect(); } if (await _mqttClientConnector.connect(_client, company, train)) { - _client.subscribe("${prefix}90940/2/event/$company/$train", MqttQos.exactlyOnce); - _client.subscribe("${prefix}90940/2/G2B/$company/$train/$_deviceId", MqttQos.exactlyOnce); + _client.subscribe('${prefix}90940/2/event/$company/$train', MqttQos.exactlyOnce); + _client.subscribe('${prefix}90940/2/G2B/$company/$train/$_deviceId', MqttQos.exactlyOnce); Fimber.i("Subscribed to topic with prefix='$prefix'..."); _startUpdateListener(); return true; @@ -57,16 +57,16 @@ class MqttService { bool publishMessage(String company, String train, String message) { if (_client.connectionStatus?.state == MqttConnectionState.connected) { - final topic = "${prefix}90940/2/B2G/$company/$train/$_deviceId"; + final topic = '${prefix}90940/2/B2G/$company/$train/$_deviceId'; final builder = MqttClientPayloadBuilder(); builder.addString(message); _client.publishMessage(topic, MqttQos.exactlyOnce, builder.payload!); - Fimber.v("Published MQTT message: topic=$topic message=$message"); + Fimber.v('Published MQTT message: topic=$topic message=$message'); return true; } else { - Fimber.w("Failed to publish MQTT message because it is not connected"); + Fimber.w('Failed to publish MQTT message because it is not connected'); return false; } } @@ -77,19 +77,19 @@ class MqttService { if (messageList != null) { for (final message in messageList) { Fimber.v( - "Received mqtt message with type=${message.runtimeType.toString()} payload=${message.payload.toString()}"); + 'Received mqtt message with type=${message.runtimeType.toString()} payload=${message.payload.toString()}'); if (message.payload is MqttPublishMessage) { final recMess = message.payload as MqttPublishMessage; final decodedMessage = utf8.decode(recMess.payload.message); - Fimber.v("Decoded mqtt message: $decodedMessage"); + Fimber.v('Decoded mqtt message: $decodedMessage'); _messageSubject.add(decodedMessage); } else { - Fimber.w("Type ${message.payload.runtimeType.toString()} parsing not implemented"); + Fimber.w('Type ${message.payload.runtimeType.toString()} parsing not implemented'); } } } else { - Fimber.w("received mqtt update with messageList=null"); + Fimber.w('received mqtt update with messageList=null'); } }); } diff --git a/das_client/lib/service/sfera/handler/journey_profile_reply_handler.dart b/das_client/lib/service/sfera/handler/journey_profile_reply_handler.dart index f5e5a96f..99b9f4e6 100644 --- a/das_client/lib/service/sfera/handler/journey_profile_reply_handler.dart +++ b/das_client/lib/service/sfera/handler/journey_profile_reply_handler.dart @@ -13,7 +13,7 @@ class JourneyProfileReplyHandler implements SferaMessageHandler { return false; } - Fimber.i("Updating journey profiles..."); + Fimber.i('Updating journey profiles...'); for (var journeyProfile in message.payload!.journeyProfiles) { await _sferaRepository.saveJourneyProfile(journeyProfile); } diff --git a/das_client/lib/service/sfera/handler/segment_profile_reply_handler.dart b/das_client/lib/service/sfera/handler/segment_profile_reply_handler.dart index cb415915..ea334af2 100644 --- a/das_client/lib/service/sfera/handler/segment_profile_reply_handler.dart +++ b/das_client/lib/service/sfera/handler/segment_profile_reply_handler.dart @@ -13,7 +13,7 @@ class SegmentProfileReplyHandler implements SferaMessageHandler { return false; } - Fimber.i("Updating segment profiles..."); + Fimber.i('Updating segment profiles...'); for (var segmentProfile in message.payload!.segmentProfiles) { await _sferaRepository.saveSegmentProfile(segmentProfile); } diff --git a/das_client/lib/service/sfera/sfera_service.dart b/das_client/lib/service/sfera/sfera_service.dart index 96190968..259210e4 100644 --- a/das_client/lib/service/sfera/sfera_service.dart +++ b/das_client/lib/service/sfera/sfera_service.dart @@ -57,7 +57,7 @@ class SferaService { _mqttStreamSubscription = _mqttService.messageStream.listen((message) async { var sferaG2bReplyMessage = SferaReplyParser.parse(message); if (!sferaG2bReplyMessage.validate()) { - Fimber.w("Validation failed for MQTT response"); + Fimber.w('Validation failed for MQTT response'); } var handled = false; @@ -66,13 +66,13 @@ class SferaService { } if (!handled) { - Fimber.w("Could not handle sfera message $message"); + Fimber.w('Could not handle sfera message $message'); } }); } Future connect(OtnId otnId) async { - Fimber.i("Starting new connection for $otnId"); + Fimber.i('Starting new connection for $otnId'); this.otnId = otnId; _messageHandlers.clear(); lastErrorCode = null; @@ -92,7 +92,7 @@ class SferaService { void onTaskCompleted(SferaTask task, dynamic data) async { _messageHandlers.remove(task); - Fimber.i("Task $task completed"); + Fimber.i('Task $task completed'); if (task is HandshakeTask) { _stateSubject.add(SferaServiceState.loadingJourney); var requestJourneyTask = @@ -123,7 +123,7 @@ class SferaService { if (segmentProfileEntity != null) { segments.add(segmentProfileEntity.toDomain()); } else { - Fimber.w("Could not find segment profile for ${element.spId}"); + Fimber.w('Could not find segment profile for ${element.spId}'); } } _segmentProfilesSubject.add(segments); @@ -138,7 +138,7 @@ class SferaService { void onTaskFailed(SferaTask task, ErrorCode errorCode) { _messageHandlers.remove(task); lastErrorCode = errorCode; - Fimber.e("Task $task failed with error code $errorCode"); + Fimber.e('Task $task failed with error code $errorCode'); if (task is HandshakeTask) { disconnect(); } @@ -151,12 +151,12 @@ class SferaService { static Future messageHeader({TrainIdentification? trainIdentification}) async { return MessageHeader.create(const Uuid().v4(), Format.sferaTimestamp(DateTime.now()), - await DeviceIdInfo.getDeviceId(), "TMS", "1085", "0085", + await DeviceIdInfo.getDeviceId(), 'TMS', '1085', '0085', trainIdentification: trainIdentification); } static String sferaTrain(String trainNumber, DateTime date) { - return "${trainNumber}_${Format.sferaDate(date)}"; + return '${trainNumber}_${Format.sferaDate(date)}'; } void dispose() { diff --git a/das_client/lib/service/sfera/task/handshake_task.dart b/das_client/lib/service/sfera/task/handshake_task.dart index 98a0d662..14b8ea25 100644 --- a/das_client/lib/service/sfera/task/handshake_task.dart +++ b/das_client/lib/service/sfera/task/handshake_task.dart @@ -35,7 +35,7 @@ class HandshakeTask extends SferaTask { Future _sendHandshakeRequest() async { var sferaTrain = SferaService.sferaTrain(otnId.operationalTrainNumber, otnId.startDate); - Fimber.i("Sending handshake request for company=${otnId.company} train=$sferaTrain"); + Fimber.i('Sending handshake request for company=${otnId.company} train=$sferaTrain'); var handshakeRequest = HandshakeRequest.create([ DasOperatingModesSupported.create( DasDrivingMode.readOnly, DasArchitecture.boardAdviceCalculation, DasConnectivity.connected), @@ -55,17 +55,17 @@ class HandshakeTask extends SferaTask { Future handleMessage(SferaG2bReplyMessage message) async { if (message.handshakeAcknowledgement != null) { stopTimeout(); - Fimber.i("Received handshake acknowledgment"); + Fimber.i('Received handshake acknowledgment'); _taskCompletedCallback(this, null); return true; } else if (message.handshakeReject != null) { stopTimeout(); - Fimber.w("Received handshake reject with reason=${message.handshakeReject?.handshakeRejectReason?.toString()}"); + Fimber.w('Received handshake reject with reason=${message.handshakeReject?.handshakeRejectReason?.toString()}'); _taskFailedCallback(this, ErrorCode.sferaHandshakeRejected); _mqttService.disconnect(); return true; } else { - Fimber.w("Ignoring response because is does not contain handshake"); + Fimber.w('Ignoring response because is does not contain handshake'); return false; } } diff --git a/das_client/lib/service/sfera/task/request_journey_profile_task.dart b/das_client/lib/service/sfera/task/request_journey_profile_task.dart index 64a9fefc..0ce369c2 100644 --- a/das_client/lib/service/sfera/task/request_journey_profile_task.dart +++ b/das_client/lib/service/sfera/task/request_journey_profile_task.dart @@ -43,7 +43,7 @@ class RequestJourneyProfileTask extends SferaTask { var sferaB2gRequestMessage = SferaB2gRequestMessage.create( await SferaService.messageHeader(trainIdentification: trainIdentification), b2gRequest: B2gRequest.createJPRequest(jpRequest)); - Fimber.i("Sending journey profile request..."); + Fimber.i('Sending journey profile request...'); _mqttService.publishMessage(otnId.company, SferaService.sferaTrain(otnId.operationalTrainNumber, otnId.startDate), sferaB2gRequestMessage.buildDocument().toString()); } @@ -53,7 +53,7 @@ class RequestJourneyProfileTask extends SferaTask { if (replyMessage.payload != null && replyMessage.payload!.journeyProfiles.isNotEmpty) { stopTimeout(); Fimber.i( - "Received G2bReplyPayload response with ${replyMessage.payload!.journeyProfiles.length} JourneyProfiles and ${replyMessage.payload!.segmentProfiles.length} SegmentProfiles...", + 'Received G2bReplyPayload response with ${replyMessage.payload!.journeyProfiles.length} JourneyProfiles and ${replyMessage.payload!.segmentProfiles.length} SegmentProfiles...', ); for (var element in replyMessage.payload!.segmentProfiles) { diff --git a/das_client/lib/service/sfera/task/request_segment_profiles_task.dart b/das_client/lib/service/sfera/task/request_segment_profiles_task.dart index 0296f907..d046f36e 100644 --- a/das_client/lib/service/sfera/task/request_segment_profiles_task.dart +++ b/das_client/lib/service/sfera/task/request_segment_profiles_task.dart @@ -42,7 +42,7 @@ class RequestSegmentProfilesTask extends SferaTask> { var missingSp = await findMissingSegmentProfiles(); if (missingSp.isEmpty) { - Fimber.i("No missing SegmentProfiles found..."); + Fimber.i('No missing SegmentProfiles found...'); _taskCompletedCallback(this, []); return; } @@ -56,7 +56,7 @@ class RequestSegmentProfilesTask extends SferaTask> { var sferaB2gRequestMessage = SferaB2gRequestMessage.create( await SferaService.messageHeader(trainIdentification: trainIdentification), b2gRequest: B2gRequest.createSPRequest(spRequests)); - Fimber.i("Sending segment profiles request..."); + Fimber.i('Sending segment profiles request...'); startTimeout(_taskFailedCallback); _mqttService.publishMessage(otnId.company, SferaService.sferaTrain(otnId.operationalTrainNumber, otnId.startDate), @@ -82,7 +82,7 @@ class RequestSegmentProfilesTask extends SferaTask> { if (replyMessage.payload != null && replyMessage.payload!.segmentProfiles.isNotEmpty) { stopTimeout(); Fimber.i( - "Received G2bReplyPayload response with ${replyMessage.payload!.segmentProfiles.length} SegmentProfiles...", + 'Received G2bReplyPayload response with ${replyMessage.payload!.segmentProfiles.length} SegmentProfiles...', ); for (var element in replyMessage.payload!.segmentProfiles) { diff --git a/das_client/lib/service/sfera/task/sfera_task.dart b/das_client/lib/service/sfera/task/sfera_task.dart index 7fec8c17..7716c70c 100644 --- a/das_client/lib/service/sfera/task/sfera_task.dart +++ b/das_client/lib/service/sfera/task/sfera_task.dart @@ -20,7 +20,7 @@ abstract class SferaTask implements SferaMessageHandler { ) { timeoutTimer?.cancel(); timeoutTimer = Timer(_timeout, () { - Fimber.e("Timeout reached for task $this"); + Fimber.e('Timeout reached for task $this'); onFailed(this, ErrorCode.sferaRequestTimeout); }); } diff --git a/das_client/lib/service/sfera_auth_service.dart b/das_client/lib/service/sfera_auth_service.dart index 0434ed62..fffdb152 100644 --- a/das_client/lib/service/sfera_auth_service.dart +++ b/das_client/lib/service/sfera_auth_service.dart @@ -14,7 +14,7 @@ class SferaAuthService { Future retrieveSferaAuthToken(String ru, String train, String role) async { - Fimber.i("Trying to fetch sfera auth token for ru=$ru train=$train role=$role..."); + Fimber.i('Trying to fetch sfera auth token for ru=$ru train=$train role=$role...'); final url = Uri.parse('$_tokenExchangeUrl?ru=$ru&train=$train&role=$role'); var authToken = await _authenticator.token(); @@ -24,10 +24,10 @@ class SferaAuthService { }); var statusCode = response.statusCode; if (statusCode >= 200 && statusCode < 300) { - Fimber.i("Successfully retrieved sfera auth token"); + Fimber.i('Successfully retrieved sfera auth token'); return response.body; } else { - Fimber.w("Failed to retrieved sfera auth token. StatusCode=$statusCode"); + Fimber.w('Failed to retrieved sfera auth token. StatusCode=$statusCode'); return null; } } diff --git a/das_client/lib/util/format.dart b/das_client/lib/util/format.dart index f532a2aa..221f37ee 100644 --- a/das_client/lib/util/format.dart +++ b/das_client/lib/util/format.dart @@ -5,7 +5,7 @@ class Format { static String sferaDate(DateTime date) { final localDate = date.toLocal(); - final dateFormat = DateFormat("yyyy-MM-dd"); + final dateFormat = DateFormat('yyyy-MM-dd'); return dateFormat.format(localDate); } diff --git a/das_client/pubspec.lock b/das_client/pubspec.lock index c8206a42..55493976 100644 --- a/das_client/pubspec.lock +++ b/das_client/pubspec.lock @@ -5,18 +5,31 @@ packages: dependency: transitive description: name: _fe_analyzer_shared - sha256: "0b2f2bd91ba804e53a61d757b986f89f1f9eaed5b11e4b2f5a2468d86d6c9fc7" + sha256: f256b0c0ba6c7577c15e2e4e114755640a875e885099367bf6e012b19314c834 url: "https://pub.dev" source: hosted - version: "67.0.0" + version: "72.0.0" + _macros: + dependency: transitive + description: dart + source: sdk + version: "0.3.2" analyzer: dependency: transitive description: name: analyzer - sha256: "37577842a27e4338429a1cbc32679d508836510b056f1eedf0c8d20e39c1383d" + sha256: b652861553cd3990d8ed361f7979dc6d7053a9ac8843fa73820ab68ce5410139 + url: "https://pub.dev" + source: hosted + version: "6.7.0" + analyzer_plugin: + dependency: transitive + description: + name: analyzer_plugin + sha256: "9661b30b13a685efaee9f02e5d01ed9f2b423bd889d28a304d02d704aee69161" url: "https://pub.dev" source: hosted - version: "6.4.1" + version: "0.11.3" android_id: dependency: "direct main" description: @@ -169,6 +182,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.0.3" + ci: + dependency: transitive + description: + name: ci + sha256: "145d095ce05cddac4d797a158bc4cf3b6016d1fe63d8c3d2fbd7212590adca13" + url: "https://pub.dev" + source: hosted + version: "0.1.0" cli_util: dependency: transitive description: @@ -225,6 +246,38 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.0" + custom_lint: + dependency: "direct dev" + description: + name: custom_lint + sha256: "3486c470bb93313a9417f926c7dd694a2e349220992d7b9d14534dc49c15bba9" + url: "https://pub.dev" + source: hosted + version: "0.7.0" + custom_lint_builder: + dependency: transitive + description: + name: custom_lint_builder + sha256: "42cdc41994eeeddab0d7a722c7093ec52bd0761921eeb2cbdbf33d192a234759" + url: "https://pub.dev" + source: hosted + version: "0.7.0" + custom_lint_core: + dependency: transitive + description: + name: custom_lint_core + sha256: "02450c3e45e2a6e8b26c4d16687596ab3c4644dd5792e3313aa9ceba5a49b7f5" + url: "https://pub.dev" + source: hosted + version: "0.7.0" + custom_lint_visitor: + dependency: transitive + description: + name: custom_lint_visitor + sha256: "8aeb3b6ae2bb765e7716b93d1d10e8356d04e0ff6d7592de6ee04e0dd7d6587d" + url: "https://pub.dev" + source: hosted + version: "1.0.0+6.7.0" dart_style: dependency: transitive description: @@ -233,6 +286,13 @@ packages: url: "https://pub.dev" source: hosted version: "2.3.6" + das_custom_lints: + dependency: "direct dev" + description: + path: das_custom_lints + relative: true + source: path + version: "0.0.1" design_system_flutter: dependency: "direct main" description: @@ -419,6 +479,14 @@ packages: description: flutter source: sdk version: "0.0.0" + freezed_annotation: + dependency: transitive + description: + name: freezed_annotation + sha256: c2e2d632dd9b8a2b7751117abcfc2b4888ecfe181bd9fca7170d9ef02e595fe2 + url: "https://pub.dev" + source: hosted + version: "2.4.4" frontend_server_client: dependency: transitive description: @@ -456,6 +524,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.3.1" + hotreloader: + dependency: transitive + description: + name: hotreloader + sha256: ed56fdc1f3a8ac924e717257621d09e9ec20e308ab6352a73a50a1d7a4d9158e + url: "https://pub.dev" + source: hosted + version: "4.2.0" html: dependency: transitive description: @@ -589,6 +665,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.2.0" + macros: + dependency: transitive + description: + name: macros + sha256: "0acaed5d6b7eab89f63350bccd82119e6c602df0f391260d0e32b5e23db79536" + url: "https://pub.dev" + source: hosted + version: "0.1.2-main.4" matcher: dependency: transitive description: @@ -986,10 +1070,10 @@ packages: dependency: "direct main" description: name: uuid - sha256: "814e9e88f21a176ae1359149021870e87f7cddaf633ab678a5d2b0bff7fd1ba8" + sha256: a5be9ef6618a7ac1e964353ef476418026db906c4facdedaa299b7a2e71690ff url: "https://pub.dev" source: hosted - version: "4.4.0" + version: "4.5.1" vector_math: dependency: transitive description: diff --git a/das_client/pubspec.yaml b/das_client/pubspec.yaml index e1f2bf5f..b5315470 100644 --- a/das_client/pubspec.yaml +++ b/das_client/pubspec.yaml @@ -101,6 +101,10 @@ dev_dependencies: # package. See that file for information about deactivating specific lint # rules and activating additional ones. flutter_lints: ^5.0.0 + custom_lint: + das_custom_lints: + path: ./das_custom_lints + flutter_launcher_icons: ^0.14.0 # For information on the generic Dart part of this file, see the diff --git a/das_client/test/logging/logging_service_test.dart b/das_client/test/logging/logging_service_test.dart index a5631635..417ae413 100644 --- a/das_client/test/logging/logging_service_test.dart +++ b/das_client/test/logging/logging_service_test.dart @@ -28,7 +28,7 @@ void main() { setUp(() async { PathProviderPlatform.instance = MockPathProviderPlatform(); - logDirectory = Directory("${(await getApplicationSupportDirectory()).path}/logs"); + logDirectory = Directory('${(await getApplicationSupportDirectory()).path}/logs'); logDirectory.createSync(recursive: true); logDirectory.listSync().forEach((element) { element.deleteSync(); @@ -43,7 +43,7 @@ void main() { var files = logDirectory.listSync(); expect(files, hasLength(0)); - var logEntry = LogEntry("Test message", LogLevel.info, {}); + var logEntry = LogEntry('Test message', LogLevel.info, {}); loggingService.save(logEntry); await Future.delayed(const Duration(milliseconds: 30)); @@ -57,13 +57,13 @@ void main() { var files = logDirectory.listSync(); expect(files, hasLength(0)); - var logEntry = LogEntry("Test message", LogLevel.fatal, {}); + var logEntry = LogEntry('Test message', LogLevel.fatal, {}); loggingService.save(logEntry); await Future.delayed(const Duration(milliseconds: 30)); files = logDirectory.listSync(); expect(files, hasLength(1)); - expect((files[0] as File).readAsStringSync(), "${jsonEncode(logEntry)},"); + expect((files[0] as File).readAsStringSync(), '${jsonEncode(logEntry)},'); }); test('Test writes multiple logs to same file', () async { @@ -72,10 +72,10 @@ void main() { var files = logDirectory.listSync(); expect(files, hasLength(0)); - loggingService.save(LogEntry("Test message", LogLevel.info, {})); - loggingService.save(LogEntry("Test message 2", LogLevel.error, {})); - loggingService.save(LogEntry("Test message 3", LogLevel.warning, {})); - loggingService.save(LogEntry("Test message 4", LogLevel.debug, {})); + loggingService.save(LogEntry('Test message', LogLevel.info, {})); + loggingService.save(LogEntry('Test message 2', LogLevel.error, {})); + loggingService.save(LogEntry('Test message 3', LogLevel.warning, {})); + loggingService.save(LogEntry('Test message 4', LogLevel.debug, {})); await Future.delayed(const Duration(milliseconds: 30)); files = logDirectory.listSync(); @@ -83,7 +83,7 @@ void main() { }); test('Test log entry json encode & decode', () async { - final logEntry = LogEntry("Test message", LogLevel.info, {'version': "0.1", 'systemName': "unitTests"}); + final logEntry = LogEntry('Test message', LogLevel.info, {'version': '0.1', 'systemName': 'unitTests'}); final logEntryDecoded = LogEntry.fromJson(jsonDecode(jsonEncode(logEntry))); expect(logEntryDecoded.message, logEntry.message); @@ -99,7 +99,7 @@ void main() { var files = logDirectory.listSync(); expect(files, hasLength(0)); - final logEntry = LogEntry("Test message", LogLevel.info, {'version': "0.1", 'systemName': "unitTests"}); + final logEntry = LogEntry('Test message', LogLevel.info, {'version': '0.1', 'systemName': 'unitTests'}); loggingService.save(logEntry); await Future.delayed(const Duration(milliseconds: 20)); @@ -125,7 +125,7 @@ void main() { var files = logDirectory.listSync(); expect(files, hasLength(0)); - final logEntry = LogEntry("Test message", LogLevel.info, {'version': "0.1", 'systemName': "unitTests"}); + final logEntry = LogEntry('Test message', LogLevel.info, {'version': '0.1', 'systemName': 'unitTests'}); loggingService.save(logEntry); await Future.delayed(const Duration(milliseconds: 20)); @@ -151,7 +151,7 @@ void main() { var files = logDirectory.listSync(); expect(files, hasLength(0)); - final logEntry = LogEntry("Test message", LogLevel.info, {'version': "0.1", 'systemName': "unitTests"}); + final logEntry = LogEntry('Test message', LogLevel.info, {'version': '0.1', 'systemName': 'unitTests'}); loggingService.save(logEntry); await Future.delayed(const Duration(milliseconds: 20)); diff --git a/das_client/test/model/sfera/sfera_document_test.dart b/das_client/test/model/sfera/sfera_document_test.dart index 3cacaa79..c67851cc 100644 --- a/das_client/test/model/sfera/sfera_document_test.dart +++ b/das_client/test/model/sfera/sfera_document_test.dart @@ -23,7 +23,7 @@ void main() { var parsedMessage = SferaReplyParser.parse(file.readAsStringSync()); - expect(() => parsedMessage.children.add(SferaXmlElement(type: "dummy")), throwsA(isA())); + expect(() => parsedMessage.children.add(SferaXmlElement(type: 'dummy')), throwsA(isA())); }); test('Test attributes are unmodifiable', () async { @@ -31,7 +31,7 @@ void main() { var parsedMessage = SferaReplyParser.parse(file.readAsStringSync()); - expect(() => parsedMessage.attributes["dummy"] = "dummy", throwsA(isA())); + expect(() => parsedMessage.attributes['dummy'] = 'dummy', throwsA(isA())); }); test('Test SferaReplyParser with SFERA_G2B_Reply_JP_request_9232.xml', () async { @@ -42,8 +42,8 @@ void main() { expect(sferaG2bReplyMessage.type, SferaG2bReplyMessage.elementType); expect(sferaG2bReplyMessage.validate(), true); - expect(sferaG2bReplyMessage.messageHeader.sender, "0088"); - expect(sferaG2bReplyMessage.messageHeader.recipient, "1088"); + expect(sferaG2bReplyMessage.messageHeader.sender, '0088'); + expect(sferaG2bReplyMessage.messageHeader.recipient, '1088'); expect(sferaG2bReplyMessage.payload, isNotNull); var payload = sferaG2bReplyMessage.payload!; @@ -54,22 +54,22 @@ void main() { expect(payload.segmentProfiles, hasLength(23)); expect(payload.segmentProfiles.first.points, isNotNull); expect(payload.segmentProfiles.first.zone, isNotNull); - expect(payload.segmentProfiles.first.zone!.imId, "0088"); + expect(payload.segmentProfiles.first.zone!.imId, '0088'); expect(payload.segmentProfiles.first.points!.timingPoints, hasLength(3)); - expect(payload.segmentProfiles.first.points!.timingPoints.first.id, "1837"); - expect(payload.segmentProfiles.first.points!.timingPoints.first.location, "0"); + expect(payload.segmentProfiles.first.points!.timingPoints.first.id, '1837'); + expect(payload.segmentProfiles.first.points!.timingPoints.first.location, '0'); expect( - payload.segmentProfiles.first.points!.timingPoints.first.names.first.name, "MEER-GRENS"); + payload.segmentProfiles.first.points!.timingPoints.first.names.first.name, 'MEER-GRENS'); expect(payload.segmentProfiles.first.points!.signals, hasLength(9)); - expect(payload.segmentProfiles.first.points!.signals.first.id.physicalId, "102346"); - expect(payload.segmentProfiles.first.points!.signals.first.id.location, "843"); + expect(payload.segmentProfiles.first.points!.signals.first.id.physicalId, '102346'); + expect(payload.segmentProfiles.first.points!.signals.first.id.location, '843'); expect(payload.segmentProfiles.first.points!.balise, hasLength(3)); - expect(payload.segmentProfiles.first.points!.balise.first.location, "0"); - expect(payload.segmentProfiles.first.points!.balise.first.position.latitude, "51.48591"); - expect(payload.segmentProfiles.first.points!.balise.first.position.longitude, "4.73459"); + expect(payload.segmentProfiles.first.points!.balise.first.location, '0'); + expect(payload.segmentProfiles.first.points!.balise.first.position.latitude, '51.48591'); + expect(payload.segmentProfiles.first.points!.balise.first.position.longitude, '4.73459'); }); test('Test Sfera HandshakeRequest generation', () async { @@ -80,13 +80,13 @@ void main() { DasDrivingMode.goa1, DasArchitecture.boardAdviceCalculation, DasConnectivity.standalone) ], relatedTrainRequestType: RelatedTrainRequestType.ownTrainAndOrRelatedTrains, statusReportsEnabled: true); - var messageHeader = MessageHeader.create("a24e63c3-ab2e-4102-9a10-ba058dec5efe", "2019-09-26T20:07:36Z", "DAS", "TMS", "1084", "0084"); + var messageHeader = MessageHeader.create('a24e63c3-ab2e-4102-9a10-ba058dec5efe', '2019-09-26T20:07:36Z', 'DAS', 'TMS', '1084', '0084'); var sferaB2gRequestMessage = SferaB2gRequestMessage.create(messageHeader, handshakeRequest: handshakeRequest); expect(sferaB2gRequestMessage.validate(), true); var xmlDocument = sferaB2gRequestMessage.buildDocument(); - var sferaB2gRequestMessageString = xmlDocument.toXmlString(pretty: true, newLine: "\r\n", indent: "\t"); + var sferaB2gRequestMessageString = xmlDocument.toXmlString(pretty: true, newLine: '\r\n', indent: '\t'); final file = File('test_resources/SFERA_B2G_RequestMessage_handshake.xml'); final xmlFileString = file.readAsStringSync(); @@ -101,8 +101,8 @@ void main() { expect(sferaG2bReplyMessage.type, SferaG2bReplyMessage.elementType); expect(sferaG2bReplyMessage.validate(), true); - expect(sferaG2bReplyMessage.messageHeader.sender, "0084"); - expect(sferaG2bReplyMessage.messageHeader.recipient, "1084"); + expect(sferaG2bReplyMessage.messageHeader.sender, '0084'); + expect(sferaG2bReplyMessage.messageHeader.recipient, '1084'); expect(sferaG2bReplyMessage.handshakeAcknowledgement, isNotNull); var handshakeAcknowledgement = sferaG2bReplyMessage.handshakeAcknowledgement!; @@ -119,8 +119,8 @@ void main() { expect(sferaG2bReplyMessage.type, SferaG2bReplyMessage.elementType); expect(sferaG2bReplyMessage.validate(), true); - expect(sferaG2bReplyMessage.messageHeader.sender, "0084"); - expect(sferaG2bReplyMessage.messageHeader.recipient, "1084"); + expect(sferaG2bReplyMessage.messageHeader.sender, '0084'); + expect(sferaG2bReplyMessage.messageHeader.recipient, '1084'); expect(sferaG2bReplyMessage.handshakeAcknowledgement, isNull); expect(sferaG2bReplyMessage.handshakeReject, isNotNull); diff --git a/das_client/test/service/sfera/sfera_handshake_task_test.dart b/das_client/test/service/sfera/sfera_handshake_task_test.dart index ecf0443d..98006850 100644 --- a/das_client/test/service/sfera/sfera_handshake_task_test.dart +++ b/das_client/test/service/sfera/sfera_handshake_task_test.dart @@ -23,7 +23,7 @@ void main() { setUp(() { mqttService = MockMqttService(); - otnId = OtnId.create("1085", "719", DateTime.now()); + otnId = OtnId.create('1085', '719', DateTime.now()); }); test('Test handshake successful', () async { diff --git a/das_client/test/service/sfera/sfera_request_journey_profile_task_test.dart b/das_client/test/service/sfera/sfera_request_journey_profile_task_test.dart index 98d5e926..b17909b2 100644 --- a/das_client/test/service/sfera/sfera_request_journey_profile_task_test.dart +++ b/das_client/test/service/sfera/sfera_request_journey_profile_task_test.dart @@ -27,7 +27,7 @@ void main() { setUp(() { mqttService = MockMqttService(); sferaRepository = MockSferaRepository(); - otnId = OtnId.create("1085", "719", DateTime.now()); + otnId = OtnId.create('1085', '719', DateTime.now()); }); test('Test JP request successful', () async {