Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Output model - beta1 #163

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
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
28 changes: 14 additions & 14 deletions packages/generator_tests/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ packages:
dependency: transitive
description:
name: _fe_analyzer_shared
sha256: eb376e9acf6938204f90eb3b1f00b578640d3188b4c8a8ec054f9f479af8d051
sha256: "0b2f2bd91ba804e53a61d757b986f89f1f9eaed5b11e4b2f5a2468d86d6c9fc7"
url: "https://pub.dev"
source: hosted
version: "64.0.0"
version: "67.0.0"
analyzer:
dependency: transitive
description:
name: analyzer
sha256: "69f54f967773f6c26c7dcb13e93d7ccee8b17a641689da39e878d5cf13b06893"
sha256: "37577842a27e4338429a1cbc32679d508836510b056f1eedf0c8d20e39c1383d"
url: "https://pub.dev"
source: hosted
version: "6.2.0"
version: "6.4.1"
args:
dependency: transitive
description:
Expand Down Expand Up @@ -85,10 +85,10 @@ packages:
dependency: transitive
description:
name: build_runner_core
sha256: "6d6ee4276b1c5f34f21fdf39425202712d2be82019983d52f351c94aafbc2c41"
sha256: "30859c90e9ddaccc484f56303931f477b1f1ba2bab74aa32ed5d6ce15870f8cf"
url: "https://pub.dev"
source: hosted
version: "7.2.10"
version: "7.2.8"
build_test:
dependency: "direct dev"
description:
Expand Down Expand Up @@ -338,10 +338,10 @@ packages:
dependency: "direct dev"
description:
name: logging
sha256: "623a88c9594aa774443aa3eb2d41807a48486b5613e67599fb4c41c0ad47c340"
sha256: "04094f2eb032cbb06c6f6e8d3607edcfcb0455e2bb6cbc010cb01171dcb64e6d"
url: "https://pub.dev"
source: hosted
version: "1.2.0"
version: "1.1.1"
matcher:
dependency: transitive
description:
Expand All @@ -354,18 +354,18 @@ packages:
dependency: transitive
description:
name: material_color_utilities
sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a"
sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec
url: "https://pub.dev"
source: hosted
version: "0.8.0"
version: "0.11.1"
meta:
dependency: transitive
description:
name: meta
sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136"
sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7
url: "https://pub.dev"
source: hosted
version: "1.12.0"
version: "1.15.0"
mime:
dependency: transitive
description:
Expand Down Expand Up @@ -436,14 +436,14 @@ packages:
path: "../reactive_forms_annotations"
relative: true
source: path
version: "5.0.0"
version: "6.0.0-beta.5"
reactive_forms_generator:
dependency: "direct dev"
description:
path: "../reactive_forms_generator"
relative: true
source: path
version: "5.0.2"
version: "6.0.0-beta.8"
recase:
dependency: "direct main"
description:
Expand Down
46 changes: 40 additions & 6 deletions packages/generator_tests/test/doc/annotateless_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ void main() {

part '$fileName.gform.dart';

@Rf()
@Rf(output: false)
class Annotateless {
final String email;

Expand All @@ -41,7 +41,7 @@ void main() {
const generatedFile = r'''// coverage:ignore-file
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: type=lint
// ignore_for_file:
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark

part of 'annotateless.dart';

Expand Down Expand Up @@ -188,6 +188,34 @@ class _AnnotatelessFormBuilderState extends State<AnnotatelessFormBuilder> {

widget.initState?.call(context, _formModel);

_logAnnotatelessForm.onRecord.listen((LogRecord e) {
// use `dumpErrorToConsole` for severe messages to ensure that severe
// exceptions are formatted consistently with other Flutter examples and
// avoids printing duplicate exceptions
if (e.level >= Level.SEVERE) {
final Object? error = e.error;
FlutterError.dumpErrorToConsole(
FlutterErrorDetails(
exception: error is Exception ? error : Exception(error),
stack: e.stackTrace,
library: e.loggerName,
context: ErrorDescription(e.message),
),
);
} else {
log(
e.message,
time: e.time,
sequenceNumber: e.sequenceNumber,
level: e.level.value,
name: e.loggerName,
zone: e.zone,
error: e.error,
stackTrace: e.stackTrace,
);
}
});

super.initState();
}

Expand Down Expand Up @@ -225,7 +253,9 @@ class _AnnotatelessFormBuilderState extends State<AnnotatelessFormBuilder> {
}
}

class AnnotatelessForm implements FormModel<Annotateless> {
final _logAnnotatelessForm = Logger('AnnotatelessForm');

class AnnotatelessForm implements FormModel<Annotateless, Annotateless> {
AnnotatelessForm(
this.form,
this.path,
Expand Down Expand Up @@ -378,9 +408,11 @@ class AnnotatelessForm implements FormModel<Annotateless> {
final isValid = !currentForm.hasErrors && currentForm.errors.isEmpty;

if (!isValid) {
debugPrintStack(
label:
'[${path ?? 'AnnotatelessForm'}]\n┗━ Avoid calling `model` on invalid form. Possible exceptions for non-nullable fields which should be guarded by `required` validator.');
_logAnnotatelessForm.warning(
'Avoid calling `model` on invalid form.Possible exceptions for non-nullable fields which should be guarded by `required` validator.',
null,
StackTrace.current,
);
}
return Annotateless(email: _emailValue, password: _passwordValue);
}
Expand Down Expand Up @@ -426,6 +458,8 @@ class AnnotatelessForm implements FormModel<Annotateless> {
if (currentForm.valid) {
onValid(model);
} else {
_logAnnotatelessForm.info('Errors');
_logAnnotatelessForm.info('┗━━ ${form.errors}');
onNotValid?.call();
}
}
Expand Down
46 changes: 40 additions & 6 deletions packages/generator_tests/test/doc/array_nullable_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ void main() {

enum UserMode { user, admin }

@Rf()
@Rf(output: false)
class ArrayNullable {
final List<String> emailList;

Expand Down Expand Up @@ -56,7 +56,7 @@ void main() {
const generatedFile = r'''// coverage:ignore-file
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: type=lint
// ignore_for_file:
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark

part of 'array_nullable.dart';

Expand Down Expand Up @@ -203,6 +203,34 @@ class _ArrayNullableFormBuilderState extends State<ArrayNullableFormBuilder> {

widget.initState?.call(context, _formModel);

_logArrayNullableForm.onRecord.listen((LogRecord e) {
// use `dumpErrorToConsole` for severe messages to ensure that severe
// exceptions are formatted consistently with other Flutter examples and
// avoids printing duplicate exceptions
if (e.level >= Level.SEVERE) {
final Object? error = e.error;
FlutterError.dumpErrorToConsole(
FlutterErrorDetails(
exception: error is Exception ? error : Exception(error),
stack: e.stackTrace,
library: e.loggerName,
context: ErrorDescription(e.message),
),
);
} else {
log(
e.message,
time: e.time,
sequenceNumber: e.sequenceNumber,
level: e.level.value,
name: e.loggerName,
zone: e.zone,
error: e.error,
stackTrace: e.stackTrace,
);
}
});

super.initState();
}

Expand Down Expand Up @@ -240,7 +268,9 @@ class _ArrayNullableFormBuilderState extends State<ArrayNullableFormBuilder> {
}
}

class ArrayNullableForm implements FormModel<ArrayNullable> {
final _logArrayNullableForm = Logger('ArrayNullableForm');

class ArrayNullableForm implements FormModel<ArrayNullable, ArrayNullable> {
ArrayNullableForm(
this.form,
this.path,
Expand Down Expand Up @@ -843,9 +873,11 @@ class ArrayNullableForm implements FormModel<ArrayNullable> {
final isValid = !currentForm.hasErrors && currentForm.errors.isEmpty;

if (!isValid) {
debugPrintStack(
label:
'[${path ?? 'ArrayNullableForm'}]\n┗━ Avoid calling `model` on invalid form. Possible exceptions for non-nullable fields which should be guarded by `required` validator.');
_logArrayNullableForm.warning(
'Avoid calling `model` on invalid form.Possible exceptions for non-nullable fields which should be guarded by `required` validator.',
null,
StackTrace.current,
);
}
return ArrayNullable(
emailList: _emailListValue,
Expand Down Expand Up @@ -896,6 +928,8 @@ class ArrayNullableForm implements FormModel<ArrayNullable> {
if (currentForm.valid) {
onValid(model);
} else {
_logArrayNullableForm.info('Errors');
_logArrayNullableForm.info('┗━━ ${form.errors}');
onNotValid?.call();
}
}
Expand Down
Loading
Loading