Skip to content

Commit 0c6d7b9

Browse files
authored
chore(repo): Upgrade Flutter to >=3.38.1 and enable new lints (#29)
1 parent 06f6a40 commit 0c6d7b9

File tree

63 files changed

+524
-761
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+524
-761
lines changed

.github/workflows/pr_title.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
- synchronize
88
branches:
99
- main
10-
- main-design-system
10+
- main-design-system # Remove this once the design system is merged into main
1111

1212
concurrency:
1313
group: ${{ github.workflow }}-${{ github.ref }}
@@ -21,13 +21,13 @@ jobs:
2121
with:
2222
scopes: |
2323
llc
24+
ui
2425
repo
2526
requireScope: true
2627
env:
2728
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2829

2930
semantic_changelog_update:
30-
if: ${{ false }} # TODO: Enable after the first release
3131
needs: conventional_pr_title # Trigger after the [conventional_pr_title] completes
3232
runs-on: ubuntu-latest
3333
steps:

all_lint_rules.yaml

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ linter:
33
- always_declare_return_types
44
- always_put_control_body_on_new_line
55
- always_put_required_named_parameters_first
6-
- always_require_non_null_named_parameters
76
- always_specify_types
87
- always_use_package_imports
98
- annotate_overrides
9+
- annotate_redeclares
1010
- avoid_annotating_with_dynamic
1111
- avoid_bool_literals_in_conditional_expressions
1212
- avoid_catches_without_on_clauses
@@ -20,6 +20,7 @@ linter:
2020
- avoid_field_initializers_in_const_classes
2121
- avoid_final_parameters
2222
- avoid_function_literals_in_foreach_calls
23+
- avoid_futureor_void
2324
- avoid_implementing_value_types
2425
- avoid_init_to_null
2526
- avoid_js_rounded_ints
@@ -32,8 +33,6 @@ linter:
3233
- avoid_relative_lib_imports
3334
- avoid_renaming_method_parameters
3435
- avoid_return_types_on_setters
35-
- avoid_returning_null
36-
- avoid_returning_null_for_future
3736
- avoid_returning_null_for_void
3837
- avoid_returning_this
3938
- avoid_setters_without_getters
@@ -61,12 +60,15 @@ linter:
6160
- constant_identifier_names
6261
- control_flow_in_finally
6362
- curly_braces_in_flow_control_structures
63+
- dangling_library_doc_comments
6464
- depend_on_referenced_packages
6565
- deprecated_consistency
66+
- deprecated_member_use_from_same_package
6667
- diagnostic_describe_all_properties
6768
- directives_ordering
6869
- discarded_futures
6970
- do_not_use_environment
71+
- document_ignores
7072
- empty_catches
7173
- empty_constructor_bodies
7274
- empty_statements
@@ -76,32 +78,41 @@ linter:
7678
- flutter_style_todos
7779
- hash_and_equals
7880
- implementation_imports
79-
- iterable_contains_unrelated_type
81+
- implicit_call_tearoffs
82+
- implicit_reopen
83+
- invalid_case_patterns
84+
- invalid_runtime_check_with_js_interop_types
8085
- join_return_with_assignment
8186
- leading_newlines_in_multiline_strings
87+
- library_annotations
8288
- library_names
8389
- library_prefixes
8490
- library_private_types_in_public_api
8591
- lines_longer_than_80_chars
86-
- list_remove_unrelated_type
8792
- literal_only_boolean_expressions
93+
- matching_super_parameters
94+
- missing_code_block_language_in_doc_comment
8895
- missing_whitespace_between_adjacent_strings
8996
- no_adjacent_strings_in_list
9097
- no_default_cases
9198
- no_duplicate_case_values
9299
- no_leading_underscores_for_library_prefixes
93100
- no_leading_underscores_for_local_identifiers
101+
- no_literal_bool_comparisons
94102
- no_logic_in_create_state
95103
- no_runtimeType_toString
104+
- no_self_assignments
105+
- no_wildcard_variable_uses
96106
- non_constant_identifier_names
97107
- noop_primitive_operations
98108
- null_check_on_nullable_type_parameter
99109
- null_closures
100110
- omit_local_variable_types
111+
- omit_obvious_local_variable_types
112+
- omit_obvious_property_types
101113
- one_member_abstracts
102114
- only_throw_errors
103115
- overridden_fields
104-
- package_api_docs
105116
- package_names
106117
- package_prefixed_library_names
107118
- parameter_assignments
@@ -117,7 +128,6 @@ linter:
117128
- prefer_constructors_over_static_methods
118129
- prefer_contains
119130
- prefer_double_quotes
120-
- prefer_equal_for_default_values
121131
- prefer_expression_function_bodies
122132
- prefer_final_fields
123133
- prefer_final_in_for_each
@@ -148,29 +158,42 @@ linter:
148158
- provide_deprecation_message
149159
- public_member_api_docs
150160
- recursive_getters
161+
- remove_deprecations_in_breaking_versions
151162
- require_trailing_commas
152163
- secure_pubspec_urls
164+
- simplify_variable_pattern
153165
- sized_box_for_whitespace
154166
- sized_box_shrink_expand
155167
- slash_for_doc_comments
156168
- sort_child_properties_last
157169
- sort_constructors_first
158170
- sort_pub_dependencies
159171
- sort_unnamed_constructors_first
172+
- specify_nonobvious_local_variable_types
173+
- specify_nonobvious_property_types
174+
- strict_top_level_inference
175+
- switch_on_type
160176
- test_types_in_equals
161177
- throw_in_finally
162178
- tighten_type_of_initializing_formals
163179
- type_annotate_public_apis
164180
- type_init_formals
181+
- type_literal_in_constant_pattern
165182
- unawaited_futures
183+
- unintended_html_in_doc_comment
184+
- unnecessary_async
166185
- unnecessary_await_in_return
167186
- unnecessary_brace_in_string_interps
187+
- unnecessary_breaks
168188
- unnecessary_const
169189
- unnecessary_constructor_name
170190
- unnecessary_final
171191
- unnecessary_getters_setters
192+
- unnecessary_ignore
172193
- unnecessary_lambdas
173194
- unnecessary_late
195+
- unnecessary_library_directive
196+
- unnecessary_library_name
174197
- unnecessary_new
175198
- unnecessary_null_aware_assignments
176199
- unnecessary_null_aware_operator_on_extension_on_nullable
@@ -185,9 +208,11 @@ linter:
185208
- unnecessary_string_interpolations
186209
- unnecessary_this
187210
- unnecessary_to_list_in_spreads
211+
- unnecessary_unawaited
212+
- unnecessary_underscores
188213
- unreachable_from_main
189214
- unrelated_type_equality_checks
190-
- unsafe_html
215+
- unsafe_variance
191216
- use_build_context_synchronously
192217
- use_colored_box
193218
- use_decorated_box
@@ -199,6 +224,7 @@ linter:
199224
- use_key_in_widget_constructors
200225
- use_late_for_private_fields_and_variables
201226
- use_named_constants
227+
- use_null_aware_elements
202228
- use_raw_strings
203229
- use_rethrow_when_possible
204230
- use_setters_to_change_properties
@@ -207,5 +233,6 @@ linter:
207233
- use_super_parameters
208234
- use_test_throws_matchers
209235
- use_to_and_as_if_applicable
236+
- use_truncating_division
210237
- valid_regexps
211-
- void_checks
238+
- void_checks

analysis_options.yaml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@ analyzer:
1010
# We explicitly enabled even conflicting rules and are fixing the conflict
1111
# in this file.
1212
included_file_warning: ignore
13-
14-
todo: ignore
1513
exclude:
1614
# exclude all the generated files
1715
- packages/*/lib/**/*.*.dart
1816

17+
formatter:
18+
page_width: 100
19+
trailing_commas: preserve
20+
1921
linter:
2022
rules:
2123
## Disabled rules because the repository doesn't respect them (yet)
@@ -93,6 +95,19 @@ linter:
9395
# There are situations where we use default in enums on purpose
9496
no_default_cases: false
9597

98+
# Sometimes static methods are more readable
99+
prefer_constructors_over_static_methods: false
100+
101+
# Conflicts with `omit_local_variable_types`
102+
specify_nonobvious_local_variable_types: false
103+
specify_nonobvious_property_types: false
104+
105+
# Makes the code more verbose without adding much value
106+
document_ignores: false
107+
108+
# False positives
109+
unsafe_variance: false
110+
96111
# Temporarily disabled to find more important issues
97112
public_member_api_docs: false
98113
avoid_print: false

apps/design_system_gallery/.gitignore

Lines changed: 0 additions & 45 deletions
This file was deleted.

apps/design_system_gallery/analysis_options.yaml

Lines changed: 0 additions & 28 deletions
This file was deleted.

apps/design_system_gallery/lib/components/button.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Widget buildCoolButtonUseCase(BuildContext context) {
1313
onTap: () {
1414
ScaffoldMessenger.of(
1515
context,
16-
).showSnackBar(SnackBar(content: Text('Button clicked')));
16+
).showSnackBar(const SnackBar(content: Text('Button clicked')));
1717
},
1818
type: context.knobs.object.dropdown(
1919
label: 'Type',

apps/design_system_gallery/lib/main.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import 'package:design_system_gallery/theme_config.dart';
21
import 'package:flutter/material.dart';
32
import 'package:provider/provider.dart';
43
import 'package:widgetbook/widgetbook.dart';
@@ -7,6 +6,7 @@ import 'package:widgetbook_annotation/widgetbook_annotation.dart' as widgetbook;
76
// This file does not exist yet,
87
// it will be generated in the next step
98
import 'main.directories.g.dart';
9+
import 'theme_config.dart';
1010

1111
void main() {
1212
runApp(const WidgetbookApp());

apps/design_system_gallery/lib/theme_config.dart

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import 'package:widgetbook_annotation/widgetbook_annotation.dart' as widgetbook;
66

77
@widgetbook.UseCase(name: 'Default', type: ThemeConfig)
88
Widget buildCoolButtonUseCase(BuildContext context) {
9-
return ThemeConfig();
9+
return const ThemeConfig();
1010
}
1111

1212
class ThemeConfig extends StatelessWidget {
@@ -18,7 +18,7 @@ class ThemeConfig extends StatelessWidget {
1818

1919
return Column(
2020
children: [
21-
Text('Theme config'),
21+
const Text('Theme config'),
2222
Row(
2323
spacing: 16,
2424
children: [
@@ -27,16 +27,13 @@ class ThemeConfig extends StatelessWidget {
2727
height: 25,
2828
color: themeConfiguration.themeData.primaryColor,
2929
),
30-
Text('Primary color'),
30+
const Text('Primary color'),
3131
StreamButton(
3232
label: 'Pick color',
3333
onTap: () => pickColor(
3434
context,
35-
themeConfiguration.themeData.primaryColor ??
36-
Theme.of(context).colorScheme.primary,
37-
(color) {
38-
themeConfiguration.setPrimaryColor(color);
39-
},
35+
themeConfiguration.themeData.primaryColor ?? Theme.of(context).colorScheme.primary,
36+
themeConfiguration.setPrimaryColor,
4037
),
4138
),
4239
],
@@ -45,15 +42,15 @@ class ThemeConfig extends StatelessWidget {
4542
);
4643
}
4744

48-
void pickColor(
45+
Future<void> pickColor(
4946
BuildContext context,
5047
Color pickerColor,
5148
ValueChanged<Color> onColorChanged,
5249
) {
53-
showDialog(
50+
return showDialog(
5451
context: context,
5552
builder: (context) => AlertDialog(
56-
title: Text('Pick a color'),
53+
title: const Text('Pick a color'),
5754
content: SingleChildScrollView(
5855
child: MaterialPicker(
5956
pickerColor: pickerColor,
@@ -66,11 +63,9 @@ class ThemeConfig extends StatelessWidget {
6663
}
6764

6865
class ThemeConfiguration extends ChangeNotifier {
69-
StreamTheme themeData;
70-
7166
ThemeConfiguration({required this.themeData});
72-
7367
ThemeConfiguration.empty() : themeData = StreamTheme();
68+
StreamTheme themeData;
7469

7570
void setPrimaryColor(Color color) {
7671
themeData = themeData.copyWith(primaryColor: color);

0 commit comments

Comments
 (0)