Skip to content

Commit

Permalink
Update Flutter (#97)
Browse files Browse the repository at this point in the history
* Update dependencies

* Enable Dart 3

* Disable Material 3

* Update flutter for CI

* Use default cache key for flutter cache, remove pub cache
  • Loading branch information
Barabas5532 authored Nov 19, 2023
1 parent a612cca commit b180b27
Show file tree
Hide file tree
Showing 15 changed files with 341 additions and 262 deletions.
31 changes: 2 additions & 29 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ env:
CMAKE_C_COMPILER_LAUNCHER: ccache
CMAKE_CXX_COMPILER_LAUNCHER: ccache
CCACHE_DIR: /ccache
FLUTTER_VERSION: '3.3.10'
FLUTTER_VERSION: '3.16.0'
FLUTTER_CHANNEL: 'stable'

jobs:
Expand Down Expand Up @@ -192,15 +192,6 @@ jobs:
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: ${{ env.FLUTTER_CHANNEL }}
cache: true
cache-key: ${{ github.job }}

- name: Flutter pub cache
uses: actions/cache@v2
with:
path: ${{ env.PUB_CACHE }}
key: flutter-pub-${{ github.job }}-${{ hashFiles('**/pubspec.lock') }}
restore-keys: |
flutter-pub-${{ github.job }}-

- run: flutter pub get

Expand All @@ -227,20 +218,11 @@ jobs:
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: ${{ env.FLUTTER_CHANNEL }}
cache: true
cache-key: ${{ github.job }}

- name: Flutter pub cache
uses: actions/cache@v2
with:
path: ${{ env.PUB_CACHE }}
key: flutter-pub-${{ github.job }}-${{ hashFiles('**/pubspec.lock') }}
restore-keys: |
flutter-pub-${{ github.job }}-

- run: flutter pub get

- name: Format
run: flutter format -o none --set-exit-if-changed lib test
run: dart format -o none --set-exit-if-changed lib test

flutter-test:
runs-on: ubuntu-latest
Expand All @@ -259,15 +241,6 @@ jobs:
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: ${{ env.FLUTTER_CHANNEL }}
cache: true
cache-key: ${{ github.job }}

- name: Flutter pub cache
uses: actions/cache@v2
with:
path: ${{ env.PUB_CACHE }}
key: flutter-pub-${{ github.job }}-${{ hashFiles('**/pubspec.lock') }}
restore-keys: |
flutter-pub-${{ github.job }}-

- run: flutter pub get

Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/strictdoc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
branches: [ master ]

env:
FLUTTER_VERSION: '3.0.3'
FLUTTER_VERSION: '3.16.0'
FLUTTER_CHANNEL: 'stable'

jobs:
Expand Down Expand Up @@ -64,7 +64,6 @@ jobs:
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: ${{ env.FLUTTER_CHANNEL }}
cache: true
cache-key: ${{ github.job }}

- name: Flutter pub cache
uses: actions/cache@v2
Expand Down
17 changes: 16 additions & 1 deletion frontend/all_lint_rules.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# https://dart.dev/tools/linter-rules/all
linter:
rules:
- always_declare_return_types
Expand All @@ -7,6 +8,7 @@ linter:
- always_specify_types
- always_use_package_imports
- annotate_overrides
- annotate_redeclares
- avoid_annotating_with_dynamic
- avoid_bool_literals_in_conditional_expressions
- avoid_catches_without_on_clauses
Expand Down Expand Up @@ -44,6 +46,7 @@ linter:
- avoid_types_as_parameter_names
- avoid_types_on_closure_parameters
- avoid_unnecessary_containers
- avoid_unstable_final_fields
- avoid_unused_constructor_parameters
- avoid_void_async
- avoid_web_libraries_in_flutter
Expand All @@ -61,8 +64,10 @@ linter:
- constant_identifier_names
- control_flow_in_finally
- curly_braces_in_flow_control_structures
- dangling_library_doc_comments
- depend_on_referenced_packages
- deprecated_consistency
- deprecated_member_use_from_same_package
- diagnostic_describe_all_properties
- directives_ordering
- discarded_futures
Expand All @@ -76,23 +81,31 @@ linter:
- flutter_style_todos
- hash_and_equals
- implementation_imports
- implicit_call_tearoffs
- implicit_reopen
- invalid_case_patterns
- iterable_contains_unrelated_type
- join_return_with_assignment
- leading_newlines_in_multiline_strings
- library_annotations
- library_names
- library_prefixes
- library_private_types_in_public_api
- lines_longer_than_80_chars
- list_remove_unrelated_type
- literal_only_boolean_expressions
- matching_super_parameters
- missing_whitespace_between_adjacent_strings
- no_adjacent_strings_in_list
- no_default_cases
- no_duplicate_case_values
- no_leading_underscores_for_library_prefixes
- no_leading_underscores_for_local_identifiers
- no_literal_bool_comparisons
- no_logic_in_create_state
- no_runtimeType_toString
- no_self_assignments
- no_wildcard_variable_uses
- non_constant_identifier_names
- noop_primitive_operations
- null_check_on_nullable_type_parameter
Expand All @@ -117,7 +130,6 @@ linter:
- prefer_constructors_over_static_methods
- prefer_contains
- prefer_double_quotes
- prefer_equal_for_default_values
- prefer_expression_function_bodies
- prefer_final_fields
- prefer_final_in_for_each
Expand Down Expand Up @@ -162,15 +174,18 @@ linter:
- tighten_type_of_initializing_formals
- type_annotate_public_apis
- type_init_formals
- type_literal_in_constant_pattern
- unawaited_futures
- unnecessary_await_in_return
- unnecessary_brace_in_string_interps
- unnecessary_breaks
- unnecessary_const
- unnecessary_constructor_name
- unnecessary_final
- unnecessary_getters_setters
- unnecessary_lambdas
- unnecessary_late
- unnecessary_library_directive
- unnecessary_new
- unnecessary_null_aware_assignments
- unnecessary_null_aware_operator_on_extension_on_nullable
Expand Down
7 changes: 4 additions & 3 deletions frontend/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ include: all_lint_rules.yaml
analyzer:
exclude:
- "**/*.g.dart"
strong-mode:
implicit-casts: false
implicit-dynamic: false
language:
strict-casts: true
strict-inference: true
strict-raw-types: true
errors:
# Otherwise cause the import of all_lint_rules to warn because of some rules conflicts.
# We explicitly enabled even conflicting rules and are fixing the conflict
Expand Down
2 changes: 1 addition & 1 deletion frontend/lib/amplifier.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Amplifier extends StatelessWidget {
});

final bool full;
final Function() onTap;
final void Function() onTap;

final String name;

Expand Down
5 changes: 3 additions & 2 deletions frontend/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ class MyApp extends StatelessWidget {
textTheme: Typography().white.apply(
fontFamily: 'Noto Sans',
),
useMaterial3: false,
),
home: const MyHomePage(title: 'ShrapnelDSP'),
debugShowCheckedModeBanner: false,
Expand Down Expand Up @@ -250,9 +251,9 @@ class MyHomePage extends StatelessWidget {
Container(width: 10),
],
),
body: Center(
body: const Center(
child: Column(
children: const [
children: [
MidiLearnStatus(),
Spacer(),
Pedalboard(),
Expand Down
2 changes: 1 addition & 1 deletion frontend/lib/midi_mapping/view/midi_learn.dart
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class MidiLearnStatus extends StatelessWidget {
ElevatedButton(
onPressed: midiLearnService.cancelLearning,
child: const Text('Cancel'),
)
),
],
),
),
Expand Down
6 changes: 3 additions & 3 deletions frontend/lib/midi_mapping/view/midi_mapping.dart
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ class CreateMappingDialogState extends State<CreateMappingDialog> {
value: id,
child: Text(parameters[id]!),
),
)
),
],
value: parameter,
onChanged: (value) => setState(() => parameter = value),
Expand Down Expand Up @@ -328,7 +328,7 @@ class ModeDropdown extends StatelessWidget {
value: mode,
child: Text(mode.uiName),
),
)
),
],
onChanged: onChanged,
value: value,
Expand Down Expand Up @@ -357,7 +357,7 @@ class ParametersDropdown extends StatelessWidget {
value: id,
child: Text(parameters[id]!),
),
)
),
],
onChanged: onChanged,
value: value,
Expand Down
2 changes: 1 addition & 1 deletion frontend/lib/pedalboard.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class _PedalboardState extends State<Pedalboard> {
Wah(
onTap: () => _activateGear(GearId.wah),
full: _activeGear == GearId.wah,
)
),
],
),
],
Expand Down
2 changes: 1 addition & 1 deletion frontend/lib/stompbox.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Stompbox extends StatelessWidget {
final String name;

final bool full;
final Function() onCardTap;
final void Function() onCardTap;

final MaterialColor primarySwatch;

Expand Down
32 changes: 16 additions & 16 deletions frontend/lib/wifi_provisioning.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import 'dart:async';
import 'dart:convert';

import 'package:esp_softap_provisioning/esp_softap_provisioning.dart';

// ignore: implementation_imports
import 'package:esp_softap_provisioning/src/connection_models.dart';
import 'package:flutter/material.dart';
Expand All @@ -41,6 +42,7 @@ class _Strings {
'your WiFi access point.';
static const successMessage = 'The ShrapnelDSP device has connected to your '
'network successfully.';

// TODO how to add the SSID to this message?
// https://stackoverflow.com/questions/52278035/flutter-internationalization-dynamic-strings
// https://github.com/dart-lang/sdk/issues/1694
Expand Down Expand Up @@ -378,7 +380,7 @@ class _WifiScanningScreenState extends State<_WifiScanningScreen> {
);
},
child: const Text('Advanced configuration'),
)
),
],
),
);
Expand Down Expand Up @@ -524,34 +526,28 @@ class WifiProvisioningScreen extends StatelessWidget {
switch (provisioning.state) {
case WifiProvisioningState.initial:
child = buildInitial(context);
break;
case WifiProvisioningState.connecting:
child = buildConnecting(context);
break;
case WifiProvisioningState.sessionFailure:
child = buildSessionFailure(context);
break;
case WifiProvisioningState.scanning:
child = _WifiScanningScreen();
break;
case WifiProvisioningState.testing:
child = buildTesting(context);
break;
case WifiProvisioningState.failure:
child = buildFailure(context);
break;
case WifiProvisioningState.success:
child = buildSuccess(context);
break;
default:
child = Text(provisioning.state.toString());
break;
}

return WillPopScope(
onWillPop: () {
provisioning.reset();
return Future.value(true);
return PopScope(
onPopInvoked: (didPop) {
if (didPop) {
provisioning.reset();
}
},
child: child,
);
Expand Down Expand Up @@ -590,6 +586,7 @@ class WifiProvisioningService extends ChangeNotifier {
}

List<Map<String, dynamic>>? get _accessPoints => _accessPointsPrivate;

List<Map<String, dynamic>>? get accessPoints => _accessPoints;

set _state(WifiProvisioningState newState) {
Expand All @@ -599,15 +596,18 @@ class WifiProvisioningService extends ChangeNotifier {
}

WifiProvisioningState get _state => _statePrivate;

WifiProvisioningState get state => _state;

ConnectionStatus? _statusPrivate;

set _status(ConnectionStatus? newStatus) {
_statusPrivate = newStatus;
notifyListeners();
}

ConnectionStatus? get _status => _statusPrivate;

ConnectionStatus? get status => _status;

int? selectedAccessPoint;
Expand All @@ -618,7 +618,7 @@ class WifiProvisioningService extends ChangeNotifier {
if (state != WifiProvisioningState.initial &&
state != WifiProvisioningState.sessionFailure &&
state != WifiProvisioningState.failure) {
throw StateError('start called in unexpected state ${_state.toString()}');
throw StateError('start called in unexpected state $_state');
}

reset();
Expand Down Expand Up @@ -663,7 +663,7 @@ class WifiProvisioningService extends ChangeNotifier {
// TODO cancel if reset is called
Future<void> join(String? ssid, String passphrase) async {
if (state != WifiProvisioningState.scanning) {
throw StateError('join called in unexpected state ${_state.toString()}');
throw StateError('join called in unexpected state $_state');
}

if (ssid == null) {
Expand Down Expand Up @@ -706,8 +706,8 @@ class WifiProvisioningService extends ChangeNotifier {
if (!_status.isSuccess()) {
_log.severe(
'could not connect to provisioned access point '
'${_status?.state.toString()} '
'${_status?.failedReason?.toString()}',
'${_status?.state} '
'${_status?.failedReason}',
);
_state = WifiProvisioningState.failure;
return;
Expand Down
2 changes: 1 addition & 1 deletion frontend/lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

flutter test
flutter analyze
flutter format -o none --set-exit-if-changed lib test
dart format -o none --set-exit-if-changed lib test
Loading

0 comments on commit b180b27

Please sign in to comment.