Skip to content
This repository was archived by the owner on Jan 31, 2025. It is now read-only.

Commit 049d365

Browse files
feat!: update to Dart3 and modernize code (#13)
1 parent 794b014 commit 049d365

File tree

19 files changed

+177
-1219
lines changed

19 files changed

+177
-1219
lines changed

.github/workflows/publish.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ name: Publish Release
33
on:
44
push:
55
tags:
6-
- 'unnested-v[0-9]+.[0-9]+.[0-9]+*'
6+
- "*"
77

88
jobs:
99
publish_github_release:
1010
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write # this is required for action-gh-release
1113
steps:
1214
- uses: actions/checkout@v3
1315
- uses: softprops/action-gh-release@v1

.github/workflows/release.yml

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

.github/workflows/test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Test Code
1+
name: Build & Test
22

33
on:
44
pull_request:
@@ -19,8 +19,8 @@ jobs:
1919
- uses: bluefireteam/melos-action@v2
2020

2121
- name: Check code format
22-
run: melos run check-format --no-select
22+
run: melos format --set-exit-if-changed
2323
- name: Run code analysis
24-
run: melos run analyze --no-select
24+
run: melos analyze --fatal-infos --fatal-warnings
2525
- name: Run tests
2626
run: melos run test

README.md

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
</p>
1010

1111
The easy way to unnest even the most complicated of widget trees,
12-
based on the power of macros in Dart 3.
12+
based on the power of the upcoming macros feature.
1313

1414
---
1515

1616
# IMPORTANT
1717
This library is just a placeholder for now with some prototype code.
18-
Dart 3 and macros have not been released yet.
18+
Macros in Dart have not been released yet.
1919

2020
Also, there are still a few in-code TODOs that need to be worked out.
2121

@@ -46,9 +46,6 @@ import 'package:flutter/material.dart';
4646
@unnested
4747
import 'package:my_app/my_custom_widget.dart';
4848
// other Widget imports with @unnested...
49-
50-
// The @unnested macros above will construct an Unnest class for you
51-
// that you can then import in your other UI files.
5249
```
5350

5451
### Step 3: Use Unnested
@@ -68,12 +65,12 @@ Widget build(BuildContext context) => Unnest()
6865

6966
#### Stateful Widgets
7067
```dart
71-
// This example uses Unstate, a modern state management solution
72-
// built around Dart 3! After you're done here, go check it out!
73-
@unstateWidget
74-
Widget _countDisplay(@C(countCapsule) int count) => Unnest()
68+
// This example uses ReArch, a modern state management solution.
69+
// After you are done here, go check it out!
70+
@rearchWidget
71+
Widget _countDisplay(WidgetHandle use) => Unnest()
7572
.padding(padding: const EdgeInsets.all(8))
76-
.text('$count'); // simply reference your state variables
73+
.text('${use(countCapsule)}'); // simply reference your state variables
7774
```
7875

7976
#### Including Custom Widgets
@@ -119,7 +116,7 @@ Widget build(BuildContext context) => Unnest()
119116
### Step 4: Going Beyond
120117
Here are some helpful hints to make working with Unnested easier.
121118

122-
- Unnested plays very nicely with `Unstate` for state management, as they are sister projects
119+
- Unnested plays very nicely with `ReArch` for state management, as they are sister projects
123120
- Create a `widgets` Flutter package and use a monorepo tool like [Melos](https://melos.invertase.dev)
124121
- Helps split up your code in a logical way too!
125122
- When using Unnested to create stateless widgets, using the `=>` syntax

analysis_options.yaml

Lines changed: 3 additions & 206 deletions
Original file line numberDiff line numberDiff line change
@@ -1,208 +1,5 @@
1-
# Modified from [email protected]
2-
# TODO update for Dart 3
3-
analyzer:
4-
language:
5-
strict-casts: true
6-
strict-inference: true
7-
strict-raw-types: true
1+
include: package:very_good_analysis/analysis_options.yaml
82

3+
analyzer:
94
errors:
10-
missing_required_param: error
11-
missing_return: error
12-
13-
exclude:
14-
- test/.test_coverage.dart
15-
- lib/generated_plugin_registrant.dart
16-
- '**/lib/macro_api/**'
17-
18-
linter:
19-
rules:
20-
- always_declare_return_types
21-
- always_put_required_named_parameters_first
22-
- always_use_package_imports
23-
- annotate_overrides
24-
- avoid_bool_literals_in_conditional_expressions
25-
- avoid_catching_errors
26-
- avoid_double_and_int_checks
27-
- avoid_dynamic_calls
28-
- avoid_empty_else
29-
- avoid_equals_and_hash_code_on_mutable_classes
30-
- avoid_escaping_inner_quotes
31-
- avoid_field_initializers_in_const_classes
32-
- avoid_final_parameters
33-
- avoid_function_literals_in_foreach_calls
34-
- avoid_init_to_null
35-
- avoid_js_rounded_ints
36-
- avoid_multiple_declarations_per_line
37-
- avoid_null_checks_in_equality_operators
38-
- avoid_positional_boolean_parameters
39-
- avoid_print
40-
- avoid_private_typedef_functions
41-
- avoid_redundant_argument_values
42-
- avoid_relative_lib_imports
43-
- avoid_renaming_method_parameters
44-
- avoid_return_types_on_setters
45-
- avoid_returning_null_for_void
46-
- avoid_returning_this
47-
- avoid_setters_without_getters
48-
- avoid_shadowing_type_parameters
49-
- avoid_single_cascade_in_expression_statements
50-
- avoid_slow_async_io
51-
- avoid_type_to_string
52-
- avoid_types_as_parameter_names
53-
- avoid_unnecessary_containers
54-
- avoid_unused_constructor_parameters
55-
- avoid_void_async
56-
- avoid_web_libraries_in_flutter
57-
- await_only_futures
58-
- camel_case_extensions
59-
- camel_case_types
60-
- cancel_subscriptions
61-
- cast_nullable_to_non_nullable
62-
- collection_methods_unrelated_type
63-
- combinators_ordering
64-
- comment_references
65-
- conditional_uri_does_not_exist
66-
- constant_identifier_names
67-
- control_flow_in_finally
68-
- curly_braces_in_flow_control_structures
69-
- dangling_library_doc_comments
70-
- depend_on_referenced_packages
71-
- deprecated_consistency
72-
- directives_ordering
73-
- empty_catches
74-
- empty_constructor_bodies
75-
- empty_statements
76-
- enable_null_safety
77-
- eol_at_end_of_file
78-
- exhaustive_cases
79-
- file_names
80-
- flutter_style_todos
81-
- hash_and_equals
82-
- implicit_call_tearoffs
83-
- implementation_imports
84-
- iterable_contains_unrelated_type
85-
- join_return_with_assignment
86-
- leading_newlines_in_multiline_strings
87-
- library_annotations
88-
- library_names
89-
- library_prefixes
90-
- library_private_types_in_public_api
91-
- lines_longer_than_80_chars
92-
- list_remove_unrelated_type
93-
- literal_only_boolean_expressions
94-
- missing_whitespace_between_adjacent_strings
95-
- no_adjacent_strings_in_list
96-
- no_default_cases
97-
- no_duplicate_case_values
98-
- no_leading_underscores_for_library_prefixes
99-
- no_leading_underscores_for_local_identifiers
100-
- no_logic_in_create_state
101-
- no_runtimeType_toString
102-
- non_constant_identifier_names
103-
- noop_primitive_operations
104-
- null_check_on_nullable_type_parameter
105-
- null_closures
106-
- omit_local_variable_types
107-
- one_member_abstracts
108-
- only_throw_errors
109-
- overridden_fields
110-
- package_api_docs
111-
- package_names
112-
- package_prefixed_library_names
113-
- parameter_assignments
114-
- prefer_adjacent_string_concatenation
115-
- prefer_asserts_in_initializer_lists
116-
- prefer_asserts_with_message
117-
- prefer_collection_literals
118-
- prefer_conditional_assignment
119-
- prefer_const_constructors
120-
- prefer_const_constructors_in_immutables
121-
- prefer_const_declarations
122-
- prefer_const_literals_to_create_immutables
123-
- prefer_constructors_over_static_methods
124-
- prefer_contains
125-
- prefer_equal_for_default_values
126-
- prefer_final_fields
127-
- prefer_final_in_for_each
128-
- prefer_final_locals
129-
- prefer_for_elements_to_map_fromIterable
130-
- prefer_function_declarations_over_variables
131-
- prefer_generic_function_type_aliases
132-
- prefer_if_elements_to_conditional_expressions
133-
- prefer_if_null_operators
134-
- prefer_initializing_formals
135-
- prefer_inlined_adds
136-
- prefer_int_literals
137-
- prefer_interpolation_to_compose_strings
138-
- prefer_is_empty
139-
- prefer_is_not_empty
140-
- prefer_is_not_operator
141-
- prefer_iterable_whereType
142-
- prefer_null_aware_method_calls
143-
- prefer_null_aware_operators
144-
- prefer_single_quotes
145-
- prefer_spread_collections
146-
- prefer_typing_uninitialized_variables
147-
- prefer_void_to_null
148-
- provide_deprecation_message
149-
- public_member_api_docs
150-
- recursive_getters
151-
- require_trailing_commas
152-
- secure_pubspec_urls
153-
- sized_box_for_whitespace
154-
- sized_box_shrink_expand
155-
- slash_for_doc_comments
156-
- sort_child_properties_last
157-
- sort_constructors_first
158-
- sort_pub_dependencies
159-
- sort_unnamed_constructors_first
160-
- test_types_in_equals
161-
- throw_in_finally
162-
- tighten_type_of_initializing_formals
163-
- type_annotate_public_apis
164-
- type_init_formals
165-
- unawaited_futures
166-
- unnecessary_await_in_return
167-
- unnecessary_brace_in_string_interps
168-
- unnecessary_const
169-
- unnecessary_constructor_name
170-
- unnecessary_getters_setters
171-
- unnecessary_lambdas
172-
- unnecessary_late
173-
- unnecessary_library_directive
174-
- unnecessary_new
175-
- unnecessary_null_aware_assignments
176-
- unnecessary_null_checks
177-
- unnecessary_null_in_if_null_operators
178-
- unnecessary_nullable_for_final_variable_declarations
179-
- unnecessary_overrides
180-
- unnecessary_parenthesis
181-
- unnecessary_raw_strings
182-
- unnecessary_statements
183-
- unnecessary_string_escapes
184-
- unnecessary_string_interpolations
185-
- unnecessary_this
186-
- unnecessary_to_list_in_spreads
187-
- unrelated_type_equality_checks
188-
- use_build_context_synchronously
189-
- use_colored_box
190-
- use_decorated_box
191-
- use_enums
192-
- use_full_hex_values_for_flutter_colors
193-
- use_function_type_syntax_for_parameters
194-
- use_if_null_to_convert_nulls_to_bools
195-
- use_is_even_rather_than_modulo
196-
- use_key_in_widget_constructors
197-
- use_late_for_private_fields_and_variables
198-
- use_named_constants
199-
- use_raw_strings
200-
- use_rethrow_when_possible
201-
- use_setters_to_change_properties
202-
- use_string_buffers
203-
- use_string_in_part_of_directives
204-
- use_super_parameters
205-
- use_test_throws_matchers
206-
- use_to_and_as_if_applicable
207-
- valid_regexps
208-
- void_checks
5+
close_sinks: warning

melos.yaml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,6 @@ packages:
55
- 'packages/**'
66

77
scripts:
8-
analyze:
9-
exec: dart analyze . --fatal-infos
10-
description: Analyze a specific package in this project.
11-
12-
check-format:
13-
exec: dart format --set-exit-if-changed .
14-
description: Check the format of a specific package in this project.
15-
16-
format:
17-
exec: dart format .
18-
description: Format a specific package in this project.
19-
208
test:
219
run: melos run test:dart --no-select && melos run test:flutter --no-select
2210
description: Run all Dart & Flutter tests in this project.

packages/unnested/example/lib/main.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import 'package:flutter/material.dart';
22
import 'package:unnested/unnested.dart';
33

4+
// NOTE: this is a trivial example
45
// ignore_for_file: public_member_api_docs
56

6-
class Unnest extends UnmodifiableRecursiveBuilder {}
7-
87
void main() {
98
runApp(
109
const MaterialApp(

packages/unnested/example/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: Example project using Unnested.
44
publish_to: none
55

66
environment:
7-
sdk: ">=2.19.2 <3.0.0"
7+
sdk: ">=3.6.0 <4.0.0"
88

99
dependencies:
1010
flutter:

packages/unnested/lib/macro_api/api.dart

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

0 commit comments

Comments
 (0)