Skip to content

Commit 3a75712

Browse files
committed
Merge branch 'main' into assets-style
2 parents 072f94c + fcb51db commit 3a75712

File tree

16 files changed

+82
-255
lines changed

16 files changed

+82
-255
lines changed

.github/workflows/flutter-ci.yml renamed to .github/workflows/dart-ci.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Flutter CI
1+
name: Dart CI
22

33
on:
44
pull_request: { }
@@ -35,4 +35,4 @@ jobs:
3535
- name: Check for any formatting and statically analyze the code.
3636
run: |
3737
make format
38-
make analyze
38+
make analyze

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,15 @@
77
<a href="https://pub.dartlang.org/packages/flutter_gen">
88
<img src="https://img.shields.io/pub/v/flutter_gen.svg">
99
</a>
10-
<a href="https://github.com/FlutterGen/flutter_gen/actions?query=workflow%3A%22Flutter+CI%22">
11-
<img src="https://github.com/FlutterGen/flutter_gen/workflows/Flutter%20CI/badge.svg?branch=master" />
10+
<a href="https://github.com/FlutterGen/flutter_gen/actions?query=workflow%3A%22Dart+CI%22">
11+
<img src="https://github.com/FlutterGen/flutter_gen/workflows/Dart%20CI/badge.svg" />
1212
</a>
1313
<a href="https://codecov.io/gh/FlutterGen/flutter_gen">
1414
<img src="https://codecov.io/gh/FlutterGen/flutter_gen/branch/main/graph/badge.svg" />
1515
</a>
16+
<a href="https://pub.dev/packages/effective_dart">
17+
<img src="https://img.shields.io/badge/style-effective_dart-40c4ff.svg" />
18+
</a>
1619
</p>
1720

1821
The Flutter code generator for your assets, fonts, colors, … — Get rid of all String-based APIs.

analysis_options.yaml

Lines changed: 2 additions & 194 deletions
Original file line numberDiff line numberDiff line change
@@ -1,197 +1,5 @@
1-
# See: https://github.com/dart-lang/pedantic/tree/master/lib
2-
include: package:pedantic/analysis_options.yaml
3-
4-
# See: https://github.com/flutter/flutter/blob/master/analysis_options.yaml
5-
analyzer:
6-
# enable-experiment:
7-
# - non-nullable
8-
strong-mode:
9-
implicit-casts: false
10-
implicit-dynamic: false
11-
errors:
12-
# treat missing required parameters as a warning (not a hint)
13-
missing_required_param: warning
14-
# treat missing returns as a warning (not a hint)
15-
missing_return: warning
16-
# allow having TODOs in the code
17-
todo: ignore
18-
# allow self-reference to deprecated members (we do this because otherwise we have
19-
# to annotate every member in every test, assert, etc, when we deprecate something)
20-
deprecated_member_use_from_same_package: ignore
21-
# Ignore analyzer hints for updating pubspecs when using Future or
22-
# Stream and not importing dart:async
23-
# Please see https://github.com/flutter/flutter/pull/24528 for details.
24-
sdk_version_async_exported_from_core: ignore
25-
exclude:
26-
- "bin/cache/**"
27-
# the following two are relative to the stocks example and the flutter package respectively
28-
# see https://github.com/dart-lang/sdk/issues/28463
29-
- "lib/i18n/messages_*.dart"
30-
- "lib/src/http/**"
31-
- "lib/data/model/*.g.dart"
1+
include: package:effective_dart/analysis_options.1.2.0.yaml
322

333
linter:
344
rules:
35-
# these rules are documented on and in the same order as
36-
# the Dart Lint rules page to make maintenance easier
37-
# https://github.com/dart-lang/linter/blob/master/example/all.yaml
38-
- always_declare_return_types
39-
- always_put_control_body_on_new_line
40-
# - always_put_required_named_parameters_first # we prefer having parameters in the same order as fields https://github.com/flutter/flutter/issues/10219
41-
- always_require_non_null_named_parameters
42-
# - always_specify_types
43-
- annotate_overrides
44-
# - avoid_annotating_with_dynamic # conflicts with always_specify_types
45-
# - avoid_as # required for implicit-casts: true
46-
- avoid_bool_literals_in_conditional_expressions
47-
# - avoid_catches_without_on_clauses # we do this commonly
48-
# - avoid_catching_errors # we do this commonly
49-
- avoid_classes_with_only_static_members
50-
# - avoid_double_and_int_checks # only useful when targeting JS runtime
51-
- avoid_empty_else
52-
- avoid_equals_and_hash_code_on_mutable_classes
53-
- avoid_field_initializers_in_const_classes
54-
- avoid_function_literals_in_foreach_calls
55-
# - avoid_implementing_value_types # not yet tested
56-
- avoid_init_to_null
57-
# - avoid_js_rounded_ints # only useful when targeting JS runtime
58-
- avoid_null_checks_in_equality_operators
59-
# - avoid_positional_boolean_parameters # not yet tested
60-
# - avoid_print # not yet tested
61-
# - avoid_private_typedef_functions # we prefer having typedef (discussion in https://github.com/flutter/flutter/pull/16356)
62-
# - avoid_redundant_argument_values # not yet tested
63-
- avoid_relative_lib_imports
64-
- avoid_renaming_method_parameters
65-
- avoid_return_types_on_setters
66-
# - avoid_returning_null # there are plenty of valid reasons to return null
67-
# - avoid_returning_null_for_future # not yet tested
68-
- avoid_returning_null_for_void
69-
# - avoid_returning_this # there are plenty of valid reasons to return this
70-
# - avoid_setters_without_getters # not yet tested
71-
# - avoid_shadowing_type_parameters # not yet tested
72-
- avoid_single_cascade_in_expression_statements
73-
- avoid_slow_async_io
74-
- avoid_types_as_parameter_names
75-
# - avoid_types_on_closure_parameters # conflicts with always_specify_types
76-
# - avoid_unnecessary_containers # not yet tested
77-
- avoid_unused_constructor_parameters
78-
- avoid_void_async
79-
# - avoid_web_libraries_in_flutter # not yet tested
80-
- await_only_futures
81-
- camel_case_extensions
82-
- camel_case_types
83-
- cancel_subscriptions
84-
# - cascade_invocations # not yet tested
85-
# - close_sinks # not reliable enough
86-
# - comment_references # blocked on https://github.com/flutter/flutter/issues/20765
87-
# - constant_identifier_names # needs an opt-out https://github.com/dart-lang/linter/issues/204
88-
- control_flow_in_finally
89-
# - curly_braces_in_flow_control_structures # not yet tested
90-
# - diagnostic_describe_all_properties # not yet tested
91-
- directives_ordering
92-
- empty_catches
93-
- empty_constructor_bodies
94-
- empty_statements
95-
# - file_names # not yet tested
96-
- flutter_style_todos
97-
- hash_and_equals
98-
- implementation_imports
99-
# - invariant_booleans # too many false positives: https://github.com/dart-lang/linter/issues/811
100-
- iterable_contains_unrelated_type
101-
# - join_return_with_assignment # not yet tested
102-
- library_names
103-
- library_prefixes
104-
# - lines_longer_than_80_chars # not yet tested
105-
- list_remove_unrelated_type
106-
# - literal_only_boolean_expressions # too many false positives: https://github.com/dart-lang/sdk/issues/34181
107-
# - missing_whitespace_between_adjacent_strings # not yet tested
108-
- no_adjacent_strings_in_list
109-
- no_duplicate_case_values
110-
# - no_logic_in_create_state # not yet tested
111-
# - no_runtimeType_toString # not yet tested
112-
- non_constant_identifier_names
113-
# - null_closures # not yet tested
114-
# - omit_local_variable_types # opposite of always_specify_types
115-
# - one_member_abstracts # too many false positives
116-
# - only_throw_errors # https://github.com/flutter/flutter/issues/5792
117-
- overridden_fields
118-
- package_api_docs
119-
- package_names
120-
- package_prefixed_library_names
121-
# - parameter_assignments # we do this commonly
122-
- prefer_adjacent_string_concatenation
123-
- prefer_asserts_in_initializer_lists
124-
# - prefer_asserts_with_message # not yet tested
125-
- prefer_collection_literals
126-
- prefer_conditional_assignment
127-
- prefer_const_constructors
128-
- prefer_const_constructors_in_immutables
129-
- prefer_const_declarations
130-
- prefer_const_literals_to_create_immutables
131-
# - prefer_constructors_over_static_methods # not yet tested
132-
- prefer_contains
133-
# - prefer_double_quotes # opposite of prefer_single_quotes
134-
- prefer_equal_for_default_values
135-
# - prefer_expression_function_bodies # conflicts with https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#consider-using--for-short-functions-and-methods
136-
- prefer_final_fields
137-
- prefer_final_in_for_each
138-
- prefer_final_locals
139-
- prefer_for_elements_to_map_fromIterable
140-
- prefer_foreach
141-
# - prefer_function_declarations_over_variables # not yet tested
142-
- prefer_generic_function_type_aliases
143-
- prefer_if_elements_to_conditional_expressions
144-
- prefer_if_null_operators
145-
- prefer_initializing_formals
146-
- prefer_inlined_adds
147-
# - prefer_int_literals # not yet tested
148-
# - prefer_interpolation_to_compose_strings # not yet tested
149-
- prefer_is_empty
150-
- prefer_is_not_empty
151-
- prefer_is_not_operator
152-
- prefer_iterable_whereType
153-
# - prefer_mixin # https://github.com/dart-lang/language/issues/32
154-
# - prefer_null_aware_operators # disable until NNBD, see https://github.com/flutter/flutter/pull/32711#issuecomment-492930932
155-
# - prefer_relative_imports # not yet tested
156-
- prefer_single_quotes
157-
- prefer_spread_collections
158-
- prefer_typing_uninitialized_variables
159-
- prefer_void_to_null
160-
# - provide_deprecation_message # not yet tested
161-
# - public_member_api_docs # enabled on a case-by-case basis; see e.g. packages/analysis_options.yaml
162-
- recursive_getters
163-
- slash_for_doc_comments
164-
# - sort_child_properties_last # not yet tested
165-
- sort_constructors_first
166-
- sort_pub_dependencies
167-
- sort_unnamed_constructors_first
168-
- test_types_in_equals
169-
- throw_in_finally
170-
# - type_annotate_public_apis # subset of always_specify_types
171-
- type_init_formals
172-
# - unawaited_futures # too many false positives
173-
# - unnecessary_await_in_return # not yet tested
174-
- unnecessary_brace_in_string_interps
175-
- unnecessary_const
176-
# - unnecessary_final # conflicts with prefer_final_locals
177-
- unnecessary_getters_setters
178-
# - unnecessary_lambdas # has false positives: https://github.com/dart-lang/linter/issues/498
179-
- unnecessary_new
180-
- unnecessary_null_aware_assignments
181-
- unnecessary_null_in_if_null_operators
182-
- unnecessary_overrides
183-
- unnecessary_parenthesis
184-
- unnecessary_statements
185-
- unnecessary_string_interpolations
186-
- unnecessary_this
187-
- unrelated_type_equality_checks
188-
# - unsafe_html # not yet tested
189-
- use_full_hex_values_for_flutter_colors
190-
# - use_function_type_syntax_for_parameters # not yet tested
191-
# - use_key_in_widget_constructors # not yet tested
192-
- use_rethrow_when_possible
193-
# - use_setters_to_change_properties # not yet tested
194-
# - use_string_buffers # has false positives: https://github.com/dart-lang/sdk/issues/34182
195-
# - use_to_and_as_if_applicable # has false positives, so we prefer to catch this by code-review
196-
- valid_regexps
197-
- void_checks
5+
public_member_api_docs: false

lib/flutter_generator.dart

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ import 'dart:io';
22

33
import 'package:build/build.dart';
44
import 'package:dart_style/dart_style.dart';
5-
import 'package:flutter_gen/src/generators/assets_generator.dart';
6-
import 'package:flutter_gen/src/generators/colors_generator.dart';
7-
import 'package:flutter_gen/src/generators/fonts_generator.dart';
8-
import 'package:flutter_gen/src/settings/config.dart';
9-
import 'package:flutter_gen/src/utils/file.dart';
105
import 'package:path/path.dart';
116

7+
import 'src/generators/assets_generator.dart';
8+
import 'src/generators/colors_generator.dart';
9+
import 'src/generators/fonts_generator.dart';
10+
import 'src/settings/config.dart';
11+
import 'src/utils/file.dart';
12+
1213
Builder build(BuilderOptions options) {
1314
Future(() async {
1415
await FlutterGenerator(File('pubspec.yaml')).build();
@@ -41,8 +42,8 @@ class FlutterGenerator {
4142
exit(-1);
4243
}
4344

44-
var output = Config.DEFAULT_OUTPUT;
45-
var lineLength = Config.DEFAULT_LINE_LENGTH;
45+
var output = Config.defaultOutput;
46+
var lineLength = Config.defaultLineLength;
4647

4748
if (config.hasFlutterGen) {
4849
output = config.flutterGen.output;

lib/src/generators/assets_generator.dart

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,17 @@ import 'dart:collection';
22
import 'dart:io';
33

44
import 'package:dart_style/dart_style.dart';
5-
import 'package:flutter_gen/src/generators/generator_helper.dart';
6-
import 'package:flutter_gen/src/generators/integrations/integration.dart';
7-
import 'package:flutter_gen/src/generators/integrations/svg_integration.dart';
8-
import 'package:flutter_gen/src/settings/asset_type.dart';
9-
import 'package:flutter_gen/src/settings/flutter.dart';
10-
import 'package:flutter_gen/src/settings/flutter_gen.dart';
11-
import 'package:flutter_gen/src/utils/string.dart';
125
import 'package:path/path.dart';
136
import 'package:dartx/dartx.dart';
147

8+
import '../settings/asset_type.dart';
9+
import '../settings/flutter.dart';
10+
import '../settings/flutter_gen.dart';
11+
import '../utils/string.dart';
12+
import 'generator_helper.dart';
13+
import 'integrations/integration.dart';
14+
import 'integrations/svg_integration.dart';
15+
1516
String generateAssets(
1617
File pubspecFile,
1718
DartFormatter formatter,

lib/src/generators/colors_generator.dart

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@ import 'dart:io';
22

33
import 'package:dart_style/dart_style.dart';
44
import 'package:dartx/dartx.dart';
5-
import 'package:flutter_gen/src/generators/generator_helper.dart';
6-
import 'package:flutter_gen/src/settings/color_path.dart';
7-
import 'package:flutter_gen/src/settings/flutter_gen.dart';
8-
import 'package:flutter_gen/src/utils/string.dart';
9-
import 'package:flutter_gen/src/utils/color.dart';
105
import 'package:path/path.dart';
116
import 'package:xml/xml.dart';
127

8+
import '../settings/color_path.dart';
9+
import '../settings/flutter_gen.dart';
10+
import '../utils/string.dart';
11+
import '../utils/color.dart';
12+
import 'generator_helper.dart';
13+
1314
String generateColors(
1415
File pubspecFile, DartFormatter formatter, FlutterGenColors colors) {
1516
assert(

lib/src/generators/fonts_generator.dart

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import 'package:dart_style/dart_style.dart';
2-
import 'package:flutter_gen/src/generators/generator_helper.dart';
3-
import 'package:flutter_gen/src/settings/flutter.dart';
4-
import 'package:flutter_gen/src/utils/string.dart';
5-
import 'package:flutter_gen/src/utils/cast.dart';
6-
import 'package:yaml/yaml.dart';
72
import 'package:dartx/dartx.dart';
3+
import 'package:yaml/yaml.dart';
4+
5+
import '../settings/flutter.dart';
6+
import '../utils/string.dart';
7+
import '../utils/cast.dart';
8+
import 'generator_helper.dart';
89

910
String generateFonts(DartFormatter formatter, FlutterFonts fonts) {
1011
assert(fonts != null && fonts.hasFonts,

lib/src/generators/integrations/svg_integration.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import 'package:flutter_gen/src/generators/integrations/integration.dart';
1+
import 'integration.dart';
22

33
class SvgIntegration extends Integration {
44
@override

lib/src/settings/config.dart

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,28 @@
11
import 'dart:io';
22

3-
import 'package:flutter_gen/src/settings/flutter.dart';
4-
import 'package:flutter_gen/src/settings/flutter_gen.dart';
5-
import 'package:flutter_gen/src/utils/cast.dart';
63
import 'package:path/path.dart';
74
import 'package:yaml/yaml.dart';
85

6+
import '../utils/cast.dart';
7+
import 'flutter.dart';
8+
import 'flutter_gen.dart';
9+
910
class Config {
1011
Config(this.pubspecFile);
1112

12-
// ignore: non_constant_identifier_names
13-
static final String DEFAULT_OUTPUT = 'lib${separator}gen$separator';
14-
static const int DEFAULT_LINE_LENGTH = 80;
13+
static final String defaultOutput = 'lib${separator}gen$separator';
14+
static const int defaultLineLength = 80;
1515

1616
final File pubspecFile;
1717
Flutter flutter;
1818
FlutterGen flutterGen;
1919

2020
Future<Config> load() async {
21-
print(
22-
'FlutterGen Loading ... ${join(basename(pubspecFile.parent.path), basename(pubspecFile.path))}');
21+
print('FlutterGen Loading ... '
22+
'${normalize(join(
23+
basename(pubspecFile.parent.path),
24+
basename(pubspecFile.path),
25+
))}');
2326
final pubspec =
2427
await pubspecFile.readAsString().catchError((dynamic error) {
2528
throw FileSystemException(

lib/src/settings/flutter.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import 'package:flutter_gen/src/utils/cast.dart';
21
import 'package:yaml/yaml.dart';
32

3+
import '../utils/cast.dart';
4+
45
class Flutter {
56
Flutter(YamlMap flutterMap) {
67
if (flutterMap != null) {

0 commit comments

Comments
 (0)