Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/pr-check-annotation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: 3.35.5
flutter-version: 3.38.6
channel: stable
cache: true
- name: Check out repository code
Expand All @@ -36,4 +36,4 @@ jobs:
run: cd packages/reactive_forms_annotations && flutter analyze --no-fatal-infos

- name: reactive_forms_annotations => code formatting
run: cd packages/reactive_forms_annotations && dart format --set-exit-if-changed lib
run: cd packages/reactive_forms_annotations && dart format --set-exit-if-changed lib
4 changes: 2 additions & 2 deletions .github/workflows/pr-check-example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: 3.35.5
flutter-version: 3.38.6
channel: stable
cache: true
- name: Check out repository code
Expand All @@ -42,4 +42,4 @@ jobs:
# run: cd packages/reactive_forms_generator/example && flutter pub get && dart format --set-exit-if-changed lib

- name: reactive_forms_generator => example => test
run: cd packages/reactive_forms_generator/example && flutter test
run: cd packages/reactive_forms_generator/example && flutter test
4 changes: 2 additions & 2 deletions .github/workflows/pr-check-generator-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: 3.35.5
flutter-version: 3.38.6
channel: stable
cache: true
- name: Check out repository code
Expand All @@ -33,4 +33,4 @@ jobs:
run: melos bs

- name: reactive_forms_generator => Code generation tests
run: cd packages/generator_tests && dart test && cd ../
run: cd packages/generator_tests && dart test && cd ../
4 changes: 2 additions & 2 deletions .github/workflows/pr-check-generator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: 3.35.5
flutter-version: 3.38.6
channel: stable
cache: true
- name: Check out repository code
Expand All @@ -36,4 +36,4 @@ jobs:
run: flutter analyze --no-fatal-infos

- name: code formatting
run: dart format --set-exit-if-changed lib
run: dart format --set-exit-if-changed lib
23 changes: 9 additions & 14 deletions packages/generator_tests/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,28 +23,23 @@ environment:
resolution: workspace

dependencies:
build: ^4.0.1
source_gen: ^4.0.1
path: ^1.8.2
build_runner: ^2.10.1
code_builder: ^4.11.0
dart_style: ^3.1.2
build: ^4.0.4
source_gen: ^4.1.2
path: ^1.9.1
build_runner: ^2.10.5
code_builder: ^4.11.1
dart_style: ^3.1.3
recase: ^4.1.0
reactive_forms_annotations:
path: ../reactive_forms_annotations
freezed_annotation: ^3.1.0

dev_dependencies:
json_serializable:
build_test: ^3.4.1
freezed: ^3.2.0
test: ^1.25.15
build_test: ^3.5.5
freezed: ^3.2.3
test: ^1.27.0
logging: ^1.3.0
reactive_forms_generator:
path: ../reactive_forms_generator
flutter_lints: ^6.0.0

dependency_overrides:
analyzer: 8.2.0
_fe_analyzer_shared: 89.0.0
test_core: 0.6.8
4 changes: 2 additions & 2 deletions packages/reactive_forms_annotations/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ environment:
resolution: workspace

dependencies:
reactive_forms: ^17.0.0
reactive_forms: ^18.2.2
collection: ^1.18.0
logging: ^1.3.0
flutter:
sdk: flutter

dev_dependencies:
flutter_lints: ^6.0.0
flutter_lints: ^6.0.0
14 changes: 7 additions & 7 deletions packages/reactive_forms_generator/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,21 @@ dependencies:
sdk: flutter
reactive_forms_annotations:
path: ../../reactive_forms_annotations
reactive_forms: ^17.0.1
reactive_forms: ^18.2.2
intl: ">=0.19.0 <1.0.0"
freezed_annotation: ^3.1.0
dartz: ^0.10.1
json_annotation: ^4.9.0
# reactive_text_field: ^1.0.0
equatable: ^2.0.7
reactive_forms_lbc: ^4.0.5
equatable: ^2.0.8
reactive_forms_lbc: ^5.0.3

dev_dependencies:
reactive_forms_generator:
path: ../../reactive_forms_generator
flutter_test:
sdk: flutter
build_runner: ^2.7.0
freezed: ^3.2.0
json_serializable: ^6.9.5
flutter_lints: ^6.0.0
build_runner: ^2.10.5
freezed: ^3.2.3
json_serializable: ^6.11.2
flutter_lints: ^6.0.0
3 changes: 1 addition & 2 deletions packages/reactive_forms_generator/lib/src/extensions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,7 @@ extension ParameterElementExt on FormalParameterElement {
final typeParameter = typeArguments.first;

return (typeParameter.element is ClassElement ||
typeParameter.element is EnumElement ||
typeParameter.element is TypeDefiningElement) &&
typeParameter.element is EnumElement) &&
!typeParameter.element!.hasRfGroupAnnotation;
}

Expand Down
8 changes: 1 addition & 7 deletions packages/reactive_forms_generator/lib/src/output/x.dart
Original file line number Diff line number Diff line change
Expand Up @@ -274,13 +274,7 @@ class ElementDisplayStringBuilder2 extends ElementDisplayStringBuilder {
_write(element.displayName);
_writeTypeParameters(element.typeParameters);
_write(' = ');

var aliasedElement = element.aliasedElement;
if (aliasedElement != null) {
aliasedElement.appendTo(this);
} else {
_writeType(element.aliasedType);
}
_writeType(element.aliasedType);
}

void writeTypeParameter(TypeParameterElement element) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class ReactiveForm {
),
Parameter(
(b) => b
..name = 'onPopInvoked'
..name = 'onPopInvokedWithResult'
..toThis = true
..named = true,
),
Expand Down Expand Up @@ -83,10 +83,10 @@ class ReactiveForm {
),
Field(
(b) => b
..name = 'onPopInvoked'
..name = 'onPopInvokedWithResult'
..modifier = FieldModifier.final$
..type = const Reference(
'void Function(FormGroup formGroup, bool didPop)?',
'void Function(FormGroup formGroup, bool didPop, dynamic? result)?',
),
),
])
Expand Down Expand Up @@ -145,7 +145,7 @@ class ReactiveForm {
stream: form.form.statusChanged,
child: ReactiveFormPopScope(
canPop: canPop,
onPopInvoked: onPopInvoked,
onPopInvokedWithResult: onPopInvokedWithResult,
child: child,
),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class ReactiveFormBuilder {
),
Parameter(
(b) => b
..name = 'onPopInvoked'
..name = 'onPopInvokedWithResult'
..named = true
..toThis = true,
),
Expand Down Expand Up @@ -117,9 +117,9 @@ class ReactiveFormBuilder {
),
Field(
(b) => b
..name = 'onPopInvoked'
..name = 'onPopInvokedWithResult'
..type = const Reference(
'void Function(FormGroup formGroup, bool didPop)?',
'void Function(FormGroup formGroup, bool didPop, dynamic? result)?',
)
..modifier = FieldModifier.final$,
),
Expand Down Expand Up @@ -245,12 +245,10 @@ class ReactiveFormBuilder {
return ${reactiveForm.className}(
key: ObjectKey(_formModel),
form: _formModel,
// canPop: widget.canPop,
// onPopInvoked: widget.onPopInvoked,
child: ReactiveFormBuilder(
form: () => _formModel.form,
canPop: widget.canPop,
onPopInvoked: widget.onPopInvoked,
onPopInvokedWithResult: widget.onPopInvokedWithResult,
builder: (context, formGroup, child) => widget.builder(context, _formModel, widget.child),
child: widget.child,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class ErrorsMethod extends ReactiveFormGeneratorMethod {
..name = field.errorsMethodName
..lambda = true
..type = MethodType.getter
..returns = Reference('Map<String, Object>${field.nullabilitySuffix}')
..returns = Reference('Map<String, dynamic>${field.nullabilitySuffix}')
..body = Code('${field.fieldControlName}.errors'),
);
}
65 changes: 32 additions & 33 deletions packages/reactive_forms_generator/lib/src/types.dart
Original file line number Diff line number Diff line change
Expand Up @@ -78,37 +78,41 @@ extension NodeListImplAnnotationImplExt on NodeListImpl<AnnotationImpl> {
}
}

extension on Annotatable {
Map<String, String> annotationParams1(TypeChecker? typeChecker) {
final result = <String, String>{};
final annotation = typeChecker?.firstAnnotationOf(this);
try {
if (annotation != null) {
for (final meta in metadata.annotations) {
final obj = meta.computeConstantValue()!;

final isExactlyType = typeChecker?.isExactlyType(obj.type!) ?? false;
if (isExactlyType) {
final argumentList =
(meta as ElementAnnotationImpl).annotationAst.arguments
as ArgumentListImpl;
for (var argument in argumentList.arguments) {
final argumentNamedExpression = argument as NamedExpressionImpl;
result.addEntries([
MapEntry(
argumentNamedExpression.name.label.toSource(),
argumentNamedExpression.expression.toSource(),
),
]);
}
Map<String, String> _annotationParamsFromElement(
Element element,
TypeChecker? typeChecker,
) {
final result = <String, String>{};
final annotation = typeChecker?.firstAnnotationOf(element);
try {
if (annotation != null) {
for (final meta in element.metadata.annotations) {
final obj = meta.computeConstantValue();
if (obj == null) {
continue;
}

final isExactlyType = typeChecker?.isExactlyType(obj.type!) ?? false;
if (isExactlyType) {
final argumentList =
(meta as ElementAnnotationImpl).annotationAst.arguments
as ArgumentListImpl;
for (var argument in argumentList.arguments) {
final argumentNamedExpression = argument as NamedExpressionImpl;
result.addEntries([
MapEntry(
argumentNamedExpression.name.label.toSource(),
argumentNamedExpression.expression.toSource(),
),
]);
}
}
}

return result;
} catch (e) {
return result;
}

return result;
} catch (e) {
return result;
}
}

Expand Down Expand Up @@ -167,12 +171,7 @@ extension ElementRfExt on Element {
}

Map<String, String> annotationParams(TypeChecker? typeChecker) {
final result = <String, String>{};
if (this is Annotatable) {
return (this as Annotatable).annotationParams1(typeChecker);
}

return result;
return _annotationParamsFromElement(this, typeChecker);
// final annotation = typeChecker?.firstAnnotationOf(this);
// try {
// if (annotation != null) {
Expand Down
25 changes: 10 additions & 15 deletions packages/reactive_forms_generator/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,18 @@ environment:
resolution: workspace

dependencies:
build: ^4.0.1
source_gen: ^4.0.1
_fe_analyzer_shared: ^89.0.0
analyzer: ^8.2.0
path: ^1.8.1
build_runner: ^2.7.0
code_builder: ^4.10.1
build: ^4.0.4
source_gen: ^4.1.2
_fe_analyzer_shared: ^91.0.0
analyzer: ^8.4.0
path: ^1.9.1
build_runner: ^2.10.5
code_builder: ^4.11.1
collection: ">=1.0.0 <2.0.0"
dart_style: ^3.0.0
dart_style: ^3.1.3
recase: ^4.1.0

dev_dependencies:
build_test: ^3.4.1
logging: ^1.2.0
build_test: ^3.5.5
logging: ^1.3.0
flutter_lints: ^6.0.0

#dependency_overrides:
# build_resolvers: ^2.1.0
# test_api: ^0.4.18
# source_helper: ^1.3.3
Loading