Skip to content

Commit 8c1277c

Browse files
author
M-Ahal
committed
Ran dart fix --apply
1 parent 9913bef commit 8c1277c

23 files changed

Lines changed: 309 additions & 97 deletions

analysis_options.yaml

Lines changed: 220 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,220 @@
1+
# include: package:flutter_lints/flutter.yaml
2+
include: package:very_good_analysis/analysis_options.yaml
3+
4+
analyzer:
5+
errors:
6+
avoid_dynamic_calls: error
7+
missing_required_param: error
8+
missing_return: error
9+
# allow having TODOs in the code
10+
todo: info
11+
missing_enum_constant_in_switch: error
12+
implicit_dynamic_type: info
13+
implicit_dynamic_map_literal: info
14+
implicit_dynamic_list_literal: info
15+
implicit_dynamic_method: warning
16+
implicit_dynamic_function: warning
17+
invalid_use_of_protected_member: error
18+
unused_local_variable: warning
19+
deprecated_member_use: warning
20+
unused_element: warning
21+
unused_field: warning
22+
dead_code: error
23+
must_call_super: error
24+
25+
# linter errors
26+
unnecessary_statements: error
27+
recursive_getters: error
28+
unnecessary_new: error
29+
unnecessary_getters_setters: error
30+
use_function_type_syntax_for_parameters: error
31+
no_duplicate_case_values: error
32+
no_adjacent_strings_in_list: error
33+
non_constant_identifier_names: error
34+
constant_identifier_names: error
35+
avoid_returning_this: error
36+
prefer_const_constructors_in_immutables: error
37+
prefer_const_literals_to_create_immutables: error
38+
avoid_equals_and_hash_code_on_mutable_classes: error
39+
camel_case_types: error
40+
camel_case_extensions: error
41+
library_names: error
42+
file_names: error
43+
library_prefixes: error
44+
45+
# linter warnings
46+
avoid_print: warning
47+
unnecessary_lambdas: warning
48+
use_key_in_widget_constructors: warning
49+
prefer_final_fields: warning
50+
prefer_final_locals: warning
51+
prefer_final_in_for_each: warning
52+
prefer_const_constructors: warning
53+
unnecessary_const: warning
54+
unnecessary_brace_in_string_interps: warning
55+
56+
# Ignore analyzer hints for updating pubspecs when using Future or
57+
# Stream and not importing dart:async
58+
# Please see https://github.com/flutter/flutter/pull/24528 for details.
59+
sdk_version_async_exported_from_core: ignore
60+
exclude:
61+
- "bin/cache/**"
62+
- "**/*.chopper.dart"
63+
- "**/generated/**"
64+
- "**/*.g.dart"
65+
language:
66+
strict-casts: true
67+
strict-raw-types: true
68+
69+
linter:
70+
rules:
71+
# these rules are documented on and in the same order as
72+
# the Dart Lint rules page to make maintenance easier
73+
# https://github.com/dart-lang/linter/blob/master/example/all.yaml
74+
- always_declare_return_types
75+
# always_put_control_body_on_new_line
76+
# always_put_required_named_parameters_first
77+
- always_require_non_null_named_parameters
78+
- avoid_dynamic_calls
79+
# - always_specify_types
80+
- annotate_overrides
81+
- avoid_print
82+
# - avoid_annotating_with_dynamic # conflicts with always_specify_types
83+
- avoid_returning_this
84+
- avoid_init_to_null
85+
- avoid_bool_literals_in_conditional_expressions
86+
# - avoid_catches_without_on_clauses # we do this commonly
87+
# - avoid_catching_errors # we do this commonly
88+
# - avoid_classes_with_only_static_members
89+
# - avoid_double_and_int_checks # only useful when targeting JS runtime
90+
- avoid_empty_else
91+
- avoid_field_initializers_in_const_classes
92+
- avoid_function_literals_in_foreach_calls
93+
# - avoid_js_rounded_ints # only useful when targeting JS runtime
94+
- avoid_null_checks_in_equality_operators
95+
# - avoid_positional_boolean_parameters
96+
# - avoid_private_typedef_functions # we prefer having typedef (discussion in https://github.com/flutter/flutter/pull/16356)
97+
- avoid_relative_lib_imports
98+
- avoid_renaming_method_parameters
99+
- avoid_return_types_on_setters
100+
# - avoid_returning_null # there are plenty of valid reasons to return null
101+
# - avoid_returning_null_for_future # not yet tested
102+
- avoid_returning_null_for_void
103+
# - avoid_returning_this # there are plenty of valid reasons to return this
104+
# - avoid_setters_without_getters # not yet tested
105+
# - avoid_shadowing_type_parameters # not yet tested
106+
# - avoid_single_cascade_in_expression_statements # not yet tested
107+
- avoid_slow_async_io
108+
- avoid_types_as_parameter_names
109+
# - avoid_types_on_closure_parameters # conflicts with always_specify_types
110+
- avoid_unused_constructor_parameters
111+
- avoid_void_async
112+
- await_only_futures
113+
- camel_case_types
114+
- cancel_subscriptions
115+
# - cascade_invocations # not yet tested
116+
# - close_sinks # not reliable enough
117+
# - comment_references # blocked on https://github.com/flutter/flutter/issues/20765
118+
# - constant_identifier_names # needs an opt-out https://github.com/dart-lang/linter/issues/204
119+
- control_flow_in_finally
120+
# - curly_braces_in_flow_control_structures # not yet tested
121+
# - diagnostic_describe_all_properties # not yet tested
122+
- directives_ordering
123+
- empty_catches
124+
- empty_constructor_bodies
125+
- empty_statements
126+
# - file_names # not yet tested
127+
- hash_and_equals
128+
- implementation_imports
129+
# - invariant_booleans # too many false positives: https://github.com/dart-lang/linter/issues/811
130+
- iterable_contains_unrelated_type
131+
# - join_return_with_assignment # not yet tested
132+
- library_names
133+
- library_prefixes
134+
# - lines_longer_than_80_chars # not yet tested
135+
- list_remove_unrelated_type
136+
# - literal_only_boolean_expressions # too many false positives: https://github.com/dart-lang/sdk/issues/34181
137+
- no_adjacent_strings_in_list
138+
- no_duplicate_case_values
139+
- non_constant_identifier_names
140+
# - null_closures # not yet tested
141+
# - omit_local_variable_types # opposite of always_specify_types
142+
# - one_member_abstracts # too many false positives
143+
# - only_throw_errors # https://github.com/flutter/flutter/issues/5792
144+
- overridden_fields
145+
- package_api_docs
146+
- package_names
147+
- package_prefixed_library_names
148+
# - parameter_assignments # we do this commonly
149+
- prefer_adjacent_string_concatenation
150+
- prefer_asserts_in_initializer_lists
151+
# - prefer_asserts_with_message # not yet tested
152+
- prefer_collection_literals
153+
- prefer_conditional_assignment
154+
- prefer_const_constructors
155+
- prefer_const_constructors_in_immutables
156+
- prefer_const_declarations
157+
- prefer_const_literals_to_create_immutables
158+
# - prefer_constructors_over_static_methods # not yet tested
159+
- prefer_contains
160+
# - prefer_double_quotes # opposite of prefer_single_quotes
161+
- prefer_equal_for_default_values
162+
# - prefer_expression_function_bodies # conflicts with https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#consider-using--for-short-functions-and-methods
163+
- prefer_final_fields
164+
# - prefer_final_in_for_each # not yet tested
165+
- prefer_final_locals
166+
# - prefer_for_elements_to_map_fromIterable # not yet tested
167+
- prefer_foreach
168+
# - prefer_function_declarations_over_variables # not yet tested
169+
- prefer_generic_function_type_aliases
170+
# - prefer_if_elements_to_conditional_expressions # not yet tested
171+
- prefer_if_null_operators
172+
- prefer_initializing_formals
173+
- prefer_inlined_adds
174+
# - prefer_int_literals # not yet tested
175+
# - prefer_interpolation_to_compose_strings # not yet tested
176+
- prefer_is_empty
177+
- prefer_is_not_empty
178+
- prefer_iterable_whereType
179+
# - prefer_mixin # https://github.com/dart-lang/language/issues/32
180+
# - prefer_null_aware_operators # disable until NNBD, see https://github.com/flutter/flutter/pull/32711#issuecomment-492930932
181+
- prefer_single_quotes
182+
- prefer_spread_collections
183+
- prefer_typing_uninitialized_variables
184+
- prefer_void_to_null
185+
# - provide_deprecation_message # not yet tested
186+
# - public_member_api_docs # enabled on a case-by-case basis; see e.g. packages/analysis_options.yaml
187+
- recursive_getters
188+
- slash_for_doc_comments
189+
# - sort_child_properties_last # not yet tested
190+
# - sort_constructors_first
191+
- sort_pub_dependencies
192+
- sort_unnamed_constructors_first
193+
- test_types_in_equals
194+
- throw_in_finally
195+
# - type_annotate_public_apis # subset of always_specify_types
196+
- type_init_formals
197+
- unawaited_futures
198+
# - unnecessary_await_in_return # not yet tested
199+
- unnecessary_brace_in_string_interps
200+
- unnecessary_const
201+
- unnecessary_getters_setters
202+
# - unnecessary_lambdas # has false positives: https://github.com/dart-lang/linter/issues/498
203+
- unnecessary_new
204+
- unnecessary_null_aware_assignments
205+
- unnecessary_null_in_if_null_operators
206+
- unnecessary_overrides
207+
- unnecessary_parenthesis
208+
- unnecessary_statements
209+
- unnecessary_this
210+
- unrelated_type_equality_checks
211+
# - unsafe_html # not yet tested
212+
- use_full_hex_values_for_flutter_colors
213+
# - use_function_type_syntax_for_parameters # not yet tested
214+
- use_rethrow_when_possible
215+
- use_key_in_widget_constructors
216+
# - use_setters_to_change_properties # not yet tested
217+
# - use_string_buffers # has false positives: https://github.com/dart-lang/sdk/issues/34182
218+
# - use_to_and_as_if_applicable # has false positives, so we prefer to catch this by code-review
219+
- valid_regexps
220+
# - void_checks # not yet tested

example/enough_platform_widgets_example.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ class MyHomePage extends StatelessWidget {
2929
@override
3030
Widget build(BuildContext context) => PlatformScaffold(
3131
appBar: PlatformAppBar(
32-
title: Text('Hello World'),
32+
title: const Text('Hello World'),
3333
),
3434
body: Column(
3535
crossAxisAlignment: CrossAxisAlignment.start,
3636
children: [
3737
Expanded(
3838
child: ListView(
39-
children: [
39+
children: const [
4040
SelectablePlatformListTile(
4141
title: Text('List Tile 1'),
4242
),

lib/cupertino.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export 'src/cupertino/cupertino.dart';
2-
3-
export 'package:cupertino_stepper/cupertino_stepper.dart';
41
export 'package:cupertino_progress_bar/cupertino_progress_bar.dart';
2+
export 'package:cupertino_stepper/cupertino_stepper.dart';
3+
4+
export 'src/cupertino/cupertino.dart';

lib/enough_platform_widgets.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
library enough_platform_widgets;
22

3-
export 'src/cupertino/cupertino.dart';
4-
export 'src/platform/platform.dart';
5-
63
export 'package:cupertino_stepper/cupertino_stepper.dart';
74
export 'package:flutter_platform_widgets/flutter_platform_widgets.dart';
5+
6+
export 'src/cupertino/cupertino.dart';
7+
export 'src/platform/platform.dart';

lib/platform.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
export 'src/platform/platform.dart';
2-
31
export 'package:flutter_platform_widgets/flutter_platform_widgets.dart';
2+
3+
export 'src/platform/platform.dart';

lib/src/cupertino/cupertino.dart

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
export 'cupertino_page_scaffold_with_toolbar.dart';
2-
export 'cupertino_toolbar.dart';
3-
export 'cupertino_page.dart';
4-
export 'cupertino_checkbox_list_tile.dart';
5-
export 'cupertino_radio_list_tile.dart';
61
export 'cupertino_bar.dart';
2+
export 'cupertino_checkbox_list_tile.dart';
73
export 'cupertino_chip.dart';
84
export 'cupertino_dropdown_button.dart';
9-
export 'cupertino_snack_app.dart';
10-
export 'cupertino_multiple_segmented.dart';
115
export 'cupertino_inkwell.dart';
6+
export 'cupertino_multiple_segmented.dart';
7+
export 'cupertino_page.dart';
8+
export 'cupertino_page_scaffold_with_toolbar.dart';
9+
export 'cupertino_radio_list_tile.dart';
1210
export 'cupertino_search.dart';
11+
export 'cupertino_snack_app.dart';
12+
export 'cupertino_toolbar.dart';

lib/src/cupertino/cupertino_checkbox_list_tile.dart

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class CupertinoCheckboxListTile extends StatelessWidget {
4040
CupertinoIcons.circle,
4141
color: highlightColor,
4242
);
43-
final padding = contentPadding ?? EdgeInsets.all(8.0);
43+
final padding = contentPadding ?? const EdgeInsets.all(8.0);
4444
final t = title;
4545
final st = subtitle;
4646
var content = t != null && st != null
@@ -49,11 +49,7 @@ class CupertinoCheckboxListTile extends StatelessWidget {
4949
mainAxisSize: MainAxisSize.min,
5050
children: [t, st],
5151
)
52-
: t != null
53-
? t
54-
: st != null
55-
? st
56-
: Container();
52+
: t ?? (st ?? Container());
5753
if (selected) {
5854
content = CupertinoTheme(
5955
data: CupertinoThemeData(

lib/src/cupertino/cupertino_chip.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class CupertinoChip extends StatelessWidget {
3434
child: Container(
3535
decoration: BoxDecoration(
3636
border: Border.all(),
37-
borderRadius: BorderRadius.all(Radius.circular(8))),
37+
borderRadius: const BorderRadius.all(Radius.circular(8))),
3838
child: Padding(
3939
padding: const EdgeInsets.all(4.0),
4040
child: content,

lib/src/cupertino/cupertino_dropdown_button.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ class _CupertinoDropdownButtonState<T>
6363
final currentIndex =
6464
max(items.indexWhere((item) => item.value == currentValue), 0);
6565
final child = currentValue == null
66-
? widget.hint ?? Icon(CupertinoIcons.arrow_down)
66+
? widget.hint ?? const Icon(CupertinoIcons.arrow_down)
6767
: children[currentIndex];
6868
return CupertinoButton(
69-
padding: EdgeInsets.all(8.0),
69+
padding: const EdgeInsets.all(8.0),
7070
child: FittedBox(child: child),
7171
onPressed: () async {
7272
widget.onTap?.call();

lib/src/cupertino/cupertino_multiple_segmented.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class CupertinoMultipleSegmentedControl extends StatefulWidget {
7979
/// If no [groupValue] is provided, or the [groupValue] is null, no widget will
8080
/// appear as selected. The [groupValue] must be either null or one of the keys
8181
/// in the [children] map.
82-
CupertinoMultipleSegmentedControl({
82+
const CupertinoMultipleSegmentedControl({
8383
Key? key,
8484
required this.children,
8585
required this.isSelected,
@@ -361,7 +361,7 @@ class _SegmentedControlState extends State<CupertinoMultipleSegmentedControl>
361361
final List<Widget> _gestureChildren = <Widget>[];
362362
final List<Color> _backgroundColors = <Color>[];
363363
//int? selectedIndex;
364-
int? pressedIndex = _pressedKey;
364+
final int? pressedIndex = _pressedKey;
365365
for (var i = 0; i < widget.children.length; i++) {
366366
final selected = widget.isSelected[i];
367367

@@ -417,7 +417,7 @@ class _SegmentedControlState extends State<CupertinoMultipleSegmentedControl>
417417
}
418418

419419
class _SegmentedControlRenderWidget extends MultiChildRenderObjectWidget {
420-
_SegmentedControlRenderWidget({
420+
const _SegmentedControlRenderWidget({
421421
Key? key,
422422
List<Widget> children = const <Widget>[],
423423
required this.isSelected,

0 commit comments

Comments
 (0)