From 9d5d9516f218983623f21580a86320f5bad7d435 Mon Sep 17 00:00:00 2001 From: Vasiliy Ditsyak Date: Thu, 8 Aug 2024 16:39:53 +0200 Subject: [PATCH] improve logging --- packages/generator_tests/pubspec.lock | 4 ++-- .../reactive_forms_annotations/CHANGELOG.md | 4 ++++ .../lib/reactive_forms_annotations.dart | 1 + .../reactive_forms_annotations/pubspec.yaml | 2 +- .../reactive_forms_generator/CHANGELOG.md | 8 +++++++ .../lib/docs/animated_url_list/url.gform.dart | 9 +++++--- .../animated_url_list/url_output.gform.dart | 9 +++++--- .../docs/annotateless/annotateless.gform.dart | 7 ++++-- .../annotateless_output.gform.dart | 7 ++++-- .../array_nullable/array_nullable.gform.dart | 7 ++++-- .../delivery_list/delivery_list.gform.dart | 22 +++++++++++++------ .../lib/docs/freezed/freezed_class.gform.dart | 7 ++++-- .../freezed/freezed_class_output.gform.dart | 7 ++++-- .../example/lib/docs/freezed2/test.gform.dart | 7 ++++-- .../lib/docs/generic/generic.gform.dart | 7 ++++-- .../generic_status_list.gform.dart | 7 ++++-- .../example/lib/docs/group/group.gform.dart | 13 ++++++----- .../example/lib/docs/login/login.gform.dart | 7 ++++-- .../lib/docs/login/login_output.gform.dart | 7 ++++-- .../login_extended/login_extended.gform.dart | 7 ++++-- .../login_extended_output.gform.dart | 7 ++++-- .../login_extended_nullable.gform.dart | 9 ++++++-- .../login_extended_nullable_output.gform.dart | 9 ++++++-- .../lib/docs/mailing_list/mailing_list.dart | 2 ++ .../docs/mailing_list/mailing_list.gform.dart | 7 ++++-- .../model_extends/model_extends.gform.dart | 7 ++++-- .../model_implements.gform.dart | 7 ++++-- .../example/lib/docs/nested/nested.gform.dart | 21 +++++++++++++----- .../lib/docs/profile/profile.gform.dart | 13 ++++++----- .../renamed_basic/renamed_basic.gform.dart | 7 ++++-- .../renamed_basic_output.gform.dart | 7 ++++-- .../docs/user_profile/user_profile.gform.dart | 9 +++++--- .../user_profile_output.gform.dart | 9 +++++--- .../example/lib/main.dart | 2 +- .../lib/src/form_generator.dart | 2 +- .../reactive_forms/reactive_form_builder.dart | 8 ++++++- .../reactive_forms_generator/pubspec.yaml | 2 +- 37 files changed, 197 insertions(+), 80 deletions(-) diff --git a/packages/generator_tests/pubspec.lock b/packages/generator_tests/pubspec.lock index d260913..b36fe0b 100644 --- a/packages/generator_tests/pubspec.lock +++ b/packages/generator_tests/pubspec.lock @@ -436,14 +436,14 @@ packages: path: "../reactive_forms_annotations" relative: true source: path - version: "6.0.0-beta.1" + version: "6.0.0-beta.3" reactive_forms_generator: dependency: "direct dev" description: path: "../reactive_forms_generator" relative: true source: path - version: "6.0.0-beta.3" + version: "6.0.0-beta.5" recase: dependency: "direct main" description: diff --git a/packages/reactive_forms_annotations/CHANGELOG.md b/packages/reactive_forms_annotations/CHANGELOG.md index 2788aa7..e61ba75 100644 --- a/packages/reactive_forms_annotations/CHANGELOG.md +++ b/packages/reactive_forms_annotations/CHANGELOG.md @@ -1,3 +1,7 @@ +## [6.0.0-beta.3] + +* improved logging + ## [6.0.0-beta.2] * improved logging diff --git a/packages/reactive_forms_annotations/lib/reactive_forms_annotations.dart b/packages/reactive_forms_annotations/lib/reactive_forms_annotations.dart index 8f00ef0..0b3d693 100644 --- a/packages/reactive_forms_annotations/lib/reactive_forms_annotations.dart +++ b/packages/reactive_forms_annotations/lib/reactive_forms_annotations.dart @@ -1,6 +1,7 @@ library reactive_forms_annotations; export 'dart:developer' hide Flow; +export 'dart:async'; export 'package:flutter/widgets.dart'; export 'package:logging/logging.dart'; export 'package:reactive_forms/reactive_forms.dart'; diff --git a/packages/reactive_forms_annotations/pubspec.yaml b/packages/reactive_forms_annotations/pubspec.yaml index 8220985..fd86970 100644 --- a/packages/reactive_forms_annotations/pubspec.yaml +++ b/packages/reactive_forms_annotations/pubspec.yaml @@ -16,7 +16,7 @@ repository: https://github.com/artflutter/reactive_forms_generator # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 6.0.0-beta.2 +version: 6.0.0-beta.3 environment: sdk: ">=3.0.0 <4.0.0" diff --git a/packages/reactive_forms_generator/CHANGELOG.md b/packages/reactive_forms_generator/CHANGELOG.md index 3249a2c..267c8f8 100644 --- a/packages/reactive_forms_generator/CHANGELOG.md +++ b/packages/reactive_forms_generator/CHANGELOG.md @@ -1,3 +1,11 @@ +## [6.0.0-beta.6] + +* improved logging + +## [6.0.0-beta.5] + +* improved logging + ## [6.0.0-beta.4] * improved logging diff --git a/packages/reactive_forms_generator/example/lib/docs/animated_url_list/url.gform.dart b/packages/reactive_forms_generator/example/lib/docs/animated_url_list/url.gform.dart index 737257a..70cb52c 100644 --- a/packages/reactive_forms_generator/example/lib/docs/animated_url_list/url.gform.dart +++ b/packages/reactive_forms_generator/example/lib/docs/animated_url_list/url.gform.dart @@ -132,6 +132,8 @@ class UrlFormBuilder extends StatefulWidget { class _UrlFormBuilderState extends State { late UrlForm _formModel; + StreamSubscription? _logSubscription; + @override void initState() { _formModel = UrlForm(UrlForm.formElements(widget.model), null); @@ -142,7 +144,7 @@ class _UrlFormBuilderState extends State { widget.initState?.call(context, _formModel); - _logUrlForm.onRecord.listen((LogRecord e) { + _logSubscription = _logUrlForm.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 @@ -185,6 +187,7 @@ class _UrlFormBuilderState extends State { @override void dispose() { _formModel.form.dispose(); + _logSubscription?.cancel(); super.dispose(); } @@ -207,7 +210,7 @@ class _UrlFormBuilderState extends State { } } -final _logUrlForm = Logger('UrlForm'); +final _logUrlForm = Logger.detached('UrlForm'); class UrlForm implements FormModel { UrlForm( @@ -506,7 +509,7 @@ class UrlForm implements FormModel { disabled: false); } -final _logUrlEntityForm = Logger('UrlEntityForm'); +final _logUrlEntityForm = Logger.detached('UrlEntityForm'); class UrlEntityForm implements FormModel { UrlEntityForm( diff --git a/packages/reactive_forms_generator/example/lib/docs/animated_url_list/url_output.gform.dart b/packages/reactive_forms_generator/example/lib/docs/animated_url_list/url_output.gform.dart index 9d51f0c..81e1703 100644 --- a/packages/reactive_forms_generator/example/lib/docs/animated_url_list/url_output.gform.dart +++ b/packages/reactive_forms_generator/example/lib/docs/animated_url_list/url_output.gform.dart @@ -132,6 +132,8 @@ class UrlOFormBuilder extends StatefulWidget { class _UrlOFormBuilderState extends State { late UrlOForm _formModel; + StreamSubscription? _logSubscription; + @override void initState() { _formModel = UrlOForm(UrlOForm.formElements(widget.model), null); @@ -142,7 +144,7 @@ class _UrlOFormBuilderState extends State { widget.initState?.call(context, _formModel); - _logUrlOForm.onRecord.listen((LogRecord e) { + _logSubscription = _logUrlOForm.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 @@ -185,6 +187,7 @@ class _UrlOFormBuilderState extends State { @override void dispose() { _formModel.form.dispose(); + _logSubscription?.cancel(); super.dispose(); } @@ -207,7 +210,7 @@ class _UrlOFormBuilderState extends State { } } -final _logUrlOForm = Logger('UrlOForm'); +final _logUrlOForm = Logger.detached('UrlOForm'); class UrlOForm implements FormModel { UrlOForm( @@ -507,7 +510,7 @@ class UrlOForm implements FormModel { disabled: false); } -final _logUrlEntityOForm = Logger('UrlEntityOForm'); +final _logUrlEntityOForm = Logger.detached('UrlEntityOForm'); class UrlEntityOForm implements FormModel { UrlEntityOForm( diff --git a/packages/reactive_forms_generator/example/lib/docs/annotateless/annotateless.gform.dart b/packages/reactive_forms_generator/example/lib/docs/annotateless/annotateless.gform.dart index 5980b51..0c04c67 100644 --- a/packages/reactive_forms_generator/example/lib/docs/annotateless/annotateless.gform.dart +++ b/packages/reactive_forms_generator/example/lib/docs/annotateless/annotateless.gform.dart @@ -137,6 +137,8 @@ class AnnotatelessFormBuilder extends StatefulWidget { class _AnnotatelessFormBuilderState extends State { late AnnotatelessForm _formModel; + StreamSubscription? _logSubscription; + @override void initState() { _formModel = @@ -148,7 +150,7 @@ class _AnnotatelessFormBuilderState extends State { widget.initState?.call(context, _formModel); - _logAnnotatelessForm.onRecord.listen((LogRecord e) { + _logSubscription = _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 @@ -191,6 +193,7 @@ class _AnnotatelessFormBuilderState extends State { @override void dispose() { _formModel.form.dispose(); + _logSubscription?.cancel(); super.dispose(); } @@ -213,7 +216,7 @@ class _AnnotatelessFormBuilderState extends State { } } -final _logAnnotatelessForm = Logger('AnnotatelessForm'); +final _logAnnotatelessForm = Logger.detached('AnnotatelessForm'); class AnnotatelessForm implements FormModel { AnnotatelessForm( diff --git a/packages/reactive_forms_generator/example/lib/docs/annotateless/annotateless_output.gform.dart b/packages/reactive_forms_generator/example/lib/docs/annotateless/annotateless_output.gform.dart index 1e869d6..dd98d2d 100644 --- a/packages/reactive_forms_generator/example/lib/docs/annotateless/annotateless_output.gform.dart +++ b/packages/reactive_forms_generator/example/lib/docs/annotateless/annotateless_output.gform.dart @@ -137,6 +137,8 @@ class AnnotatelessOFormBuilder extends StatefulWidget { class _AnnotatelessOFormBuilderState extends State { late AnnotatelessOForm _formModel; + StreamSubscription? _logSubscription; + @override void initState() { _formModel = @@ -148,7 +150,7 @@ class _AnnotatelessOFormBuilderState extends State { widget.initState?.call(context, _formModel); - _logAnnotatelessOForm.onRecord.listen((LogRecord e) { + _logSubscription = _logAnnotatelessOForm.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 @@ -191,6 +193,7 @@ class _AnnotatelessOFormBuilderState extends State { @override void dispose() { _formModel.form.dispose(); + _logSubscription?.cancel(); super.dispose(); } @@ -213,7 +216,7 @@ class _AnnotatelessOFormBuilderState extends State { } } -final _logAnnotatelessOForm = Logger('AnnotatelessOForm'); +final _logAnnotatelessOForm = Logger.detached('AnnotatelessOForm'); class AnnotatelessOForm implements FormModel { diff --git a/packages/reactive_forms_generator/example/lib/docs/array_nullable/array_nullable.gform.dart b/packages/reactive_forms_generator/example/lib/docs/array_nullable/array_nullable.gform.dart index 0c00239..ab7496d 100644 --- a/packages/reactive_forms_generator/example/lib/docs/array_nullable/array_nullable.gform.dart +++ b/packages/reactive_forms_generator/example/lib/docs/array_nullable/array_nullable.gform.dart @@ -137,6 +137,8 @@ class ArrayNullableFormBuilder extends StatefulWidget { class _ArrayNullableFormBuilderState extends State { late ArrayNullableForm _formModel; + StreamSubscription? _logSubscription; + @override void initState() { _formModel = @@ -148,7 +150,7 @@ class _ArrayNullableFormBuilderState extends State { widget.initState?.call(context, _formModel); - _logArrayNullableForm.onRecord.listen((LogRecord e) { + _logSubscription = _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 @@ -191,6 +193,7 @@ class _ArrayNullableFormBuilderState extends State { @override void dispose() { _formModel.form.dispose(); + _logSubscription?.cancel(); super.dispose(); } @@ -213,7 +216,7 @@ class _ArrayNullableFormBuilderState extends State { } } -final _logArrayNullableForm = Logger('ArrayNullableForm'); +final _logArrayNullableForm = Logger.detached('ArrayNullableForm'); class ArrayNullableForm implements FormModel { ArrayNullableForm( diff --git a/packages/reactive_forms_generator/example/lib/docs/delivery_list/delivery_list.gform.dart b/packages/reactive_forms_generator/example/lib/docs/delivery_list/delivery_list.gform.dart index ca2c132..bdc8505 100644 --- a/packages/reactive_forms_generator/example/lib/docs/delivery_list/delivery_list.gform.dart +++ b/packages/reactive_forms_generator/example/lib/docs/delivery_list/delivery_list.gform.dart @@ -137,6 +137,8 @@ class DeliveryListFormBuilder extends StatefulWidget { class _DeliveryListFormBuilderState extends State { late DeliveryListForm _formModel; + StreamSubscription? _logSubscription; + @override void initState() { _formModel = @@ -148,7 +150,7 @@ class _DeliveryListFormBuilderState extends State { widget.initState?.call(context, _formModel); - _logDeliveryListForm.onRecord.listen((LogRecord e) { + _logSubscription = _logDeliveryListForm.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 @@ -191,6 +193,7 @@ class _DeliveryListFormBuilderState extends State { @override void dispose() { _formModel.form.dispose(); + _logSubscription?.cancel(); super.dispose(); } @@ -213,7 +216,7 @@ class _DeliveryListFormBuilderState extends State { } } -final _logDeliveryListForm = Logger('DeliveryListForm'); +final _logDeliveryListForm = Logger.detached('DeliveryListForm'); class DeliveryListForm implements FormModel { DeliveryListForm( @@ -736,7 +739,7 @@ class DeliveryListForm implements FormModel { disabled: false); } -final _logDeliveryPointForm = Logger('DeliveryPointForm'); +final _logDeliveryPointForm = Logger.detached('DeliveryPointForm'); class DeliveryPointForm implements FormModel { DeliveryPointForm( @@ -1022,7 +1025,7 @@ class DeliveryPointForm implements FormModel { disabled: false); } -final _logAddressForm = Logger('AddressForm'); +final _logAddressForm = Logger.detached('AddressForm'); class AddressForm implements FormModel { AddressForm( @@ -1336,7 +1339,7 @@ class AddressForm implements FormModel { disabled: false); } -final _logClientForm = Logger('ClientForm'); +final _logClientForm = Logger.detached('ClientForm'); class ClientForm implements FormModel { ClientForm( @@ -1988,6 +1991,8 @@ class _StandaloneDeliveryPointFormBuilderState extends State { late StandaloneDeliveryPointForm _formModel; + StreamSubscription? _logSubscription; + @override void initState() { _formModel = StandaloneDeliveryPointForm( @@ -1999,7 +2004,8 @@ class _StandaloneDeliveryPointFormBuilderState widget.initState?.call(context, _formModel); - _logStandaloneDeliveryPointForm.onRecord.listen((LogRecord e) { + _logSubscription = + _logStandaloneDeliveryPointForm.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 @@ -2042,6 +2048,7 @@ class _StandaloneDeliveryPointFormBuilderState @override void dispose() { _formModel.form.dispose(); + _logSubscription?.cancel(); super.dispose(); } @@ -2064,7 +2071,8 @@ class _StandaloneDeliveryPointFormBuilderState } } -final _logStandaloneDeliveryPointForm = Logger('StandaloneDeliveryPointForm'); +final _logStandaloneDeliveryPointForm = + Logger.detached('StandaloneDeliveryPointForm'); class StandaloneDeliveryPointForm implements FormModel { diff --git a/packages/reactive_forms_generator/example/lib/docs/freezed/freezed_class.gform.dart b/packages/reactive_forms_generator/example/lib/docs/freezed/freezed_class.gform.dart index 0a0872d..c4f86c7 100644 --- a/packages/reactive_forms_generator/example/lib/docs/freezed/freezed_class.gform.dart +++ b/packages/reactive_forms_generator/example/lib/docs/freezed/freezed_class.gform.dart @@ -137,6 +137,8 @@ class FreezedClassFormBuilder extends StatefulWidget { class _FreezedClassFormBuilderState extends State { late FreezedClassForm _formModel; + StreamSubscription? _logSubscription; + @override void initState() { _formModel = @@ -148,7 +150,7 @@ class _FreezedClassFormBuilderState extends State { widget.initState?.call(context, _formModel); - _logFreezedClassForm.onRecord.listen((LogRecord e) { + _logSubscription = _logFreezedClassForm.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 @@ -191,6 +193,7 @@ class _FreezedClassFormBuilderState extends State { @override void dispose() { _formModel.form.dispose(); + _logSubscription?.cancel(); super.dispose(); } @@ -213,7 +216,7 @@ class _FreezedClassFormBuilderState extends State { } } -final _logFreezedClassForm = Logger('FreezedClassForm'); +final _logFreezedClassForm = Logger.detached('FreezedClassForm'); class FreezedClassForm implements FormModel { FreezedClassForm( diff --git a/packages/reactive_forms_generator/example/lib/docs/freezed/freezed_class_output.gform.dart b/packages/reactive_forms_generator/example/lib/docs/freezed/freezed_class_output.gform.dart index ba5e54c..50444fe 100644 --- a/packages/reactive_forms_generator/example/lib/docs/freezed/freezed_class_output.gform.dart +++ b/packages/reactive_forms_generator/example/lib/docs/freezed/freezed_class_output.gform.dart @@ -137,6 +137,8 @@ class FreezedClassOFormBuilder extends StatefulWidget { class _FreezedClassOFormBuilderState extends State { late FreezedClassOForm _formModel; + StreamSubscription? _logSubscription; + @override void initState() { _formModel = @@ -148,7 +150,7 @@ class _FreezedClassOFormBuilderState extends State { widget.initState?.call(context, _formModel); - _logFreezedClassOForm.onRecord.listen((LogRecord e) { + _logSubscription = _logFreezedClassOForm.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 @@ -191,6 +193,7 @@ class _FreezedClassOFormBuilderState extends State { @override void dispose() { _formModel.form.dispose(); + _logSubscription?.cancel(); super.dispose(); } @@ -213,7 +216,7 @@ class _FreezedClassOFormBuilderState extends State { } } -final _logFreezedClassOForm = Logger('FreezedClassOForm'); +final _logFreezedClassOForm = Logger.detached('FreezedClassOForm'); class FreezedClassOForm implements FormModel { diff --git a/packages/reactive_forms_generator/example/lib/docs/freezed2/test.gform.dart b/packages/reactive_forms_generator/example/lib/docs/freezed2/test.gform.dart index 38be7b8..d2cfb9d 100644 --- a/packages/reactive_forms_generator/example/lib/docs/freezed2/test.gform.dart +++ b/packages/reactive_forms_generator/example/lib/docs/freezed2/test.gform.dart @@ -132,6 +132,8 @@ class TestFormBuilder extends StatefulWidget { class _TestFormBuilderState extends State { late TestForm _formModel; + StreamSubscription? _logSubscription; + @override void initState() { _formModel = TestForm(TestForm.formElements(widget.model), null); @@ -142,7 +144,7 @@ class _TestFormBuilderState extends State { widget.initState?.call(context, _formModel); - _logTestForm.onRecord.listen((LogRecord e) { + _logSubscription = _logTestForm.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 @@ -185,6 +187,7 @@ class _TestFormBuilderState extends State { @override void dispose() { _formModel.form.dispose(); + _logSubscription?.cancel(); super.dispose(); } @@ -207,7 +210,7 @@ class _TestFormBuilderState extends State { } } -final _logTestForm = Logger('TestForm'); +final _logTestForm = Logger.detached('TestForm'); class TestForm implements FormModel { TestForm( diff --git a/packages/reactive_forms_generator/example/lib/docs/generic/generic.gform.dart b/packages/reactive_forms_generator/example/lib/docs/generic/generic.gform.dart index 86bb6e6..24dcddd 100644 --- a/packages/reactive_forms_generator/example/lib/docs/generic/generic.gform.dart +++ b/packages/reactive_forms_generator/example/lib/docs/generic/generic.gform.dart @@ -132,6 +132,8 @@ class TagsFormBuilder extends StatefulWidget { class _TagsFormBuilderState extends State> { late TagsForm _formModel; + StreamSubscription? _logSubscription; + @override void initState() { _formModel = TagsForm(TagsForm.formElements(widget.model), null); @@ -142,7 +144,7 @@ class _TagsFormBuilderState extends State> { widget.initState?.call(context, _formModel); - _logTagsForm.onRecord.listen((LogRecord e) { + _logSubscription = _logTagsForm.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 @@ -185,6 +187,7 @@ class _TagsFormBuilderState extends State> { @override void dispose() { _formModel.form.dispose(); + _logSubscription?.cancel(); super.dispose(); } @@ -207,7 +210,7 @@ class _TagsFormBuilderState extends State> { } } -final _logTagsForm = Logger('TagsForm'); +final _logTagsForm = Logger.detached('TagsForm'); class TagsForm implements FormModel, Tags> { TagsForm( diff --git a/packages/reactive_forms_generator/example/lib/docs/generic_status_list/generic_status_list.gform.dart b/packages/reactive_forms_generator/example/lib/docs/generic_status_list/generic_status_list.gform.dart index 32144d4..1dac080 100644 --- a/packages/reactive_forms_generator/example/lib/docs/generic_status_list/generic_status_list.gform.dart +++ b/packages/reactive_forms_generator/example/lib/docs/generic_status_list/generic_status_list.gform.dart @@ -139,6 +139,8 @@ class _StatusListFormBuilderState extends State> { late StatusListForm _formModel; + StreamSubscription? _logSubscription; + @override void initState() { _formModel = @@ -150,7 +152,7 @@ class _StatusListFormBuilderState widget.initState?.call(context, _formModel); - _logStatusListForm.onRecord.listen((LogRecord e) { + _logSubscription = _logStatusListForm.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 @@ -193,6 +195,7 @@ class _StatusListFormBuilderState @override void dispose() { _formModel.form.dispose(); + _logSubscription?.cancel(); super.dispose(); } @@ -215,7 +218,7 @@ class _StatusListFormBuilderState } } -final _logStatusListForm = Logger('StatusListForm'); +final _logStatusListForm = Logger.detached('StatusListForm'); class StatusListForm implements FormModel, StatusList> { diff --git a/packages/reactive_forms_generator/example/lib/docs/group/group.gform.dart b/packages/reactive_forms_generator/example/lib/docs/group/group.gform.dart index f5454c8..5c1b9ab 100644 --- a/packages/reactive_forms_generator/example/lib/docs/group/group.gform.dart +++ b/packages/reactive_forms_generator/example/lib/docs/group/group.gform.dart @@ -132,6 +132,8 @@ class GroupFormBuilder extends StatefulWidget { class _GroupFormBuilderState extends State { late GroupForm _formModel; + StreamSubscription? _logSubscription; + @override void initState() { _formModel = GroupForm(GroupForm.formElements(widget.model), null); @@ -142,7 +144,7 @@ class _GroupFormBuilderState extends State { widget.initState?.call(context, _formModel); - _logGroupForm.onRecord.listen((LogRecord e) { + _logSubscription = _logGroupForm.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 @@ -185,6 +187,7 @@ class _GroupFormBuilderState extends State { @override void dispose() { _formModel.form.dispose(); + _logSubscription?.cancel(); super.dispose(); } @@ -207,7 +210,7 @@ class _GroupFormBuilderState extends State { } } -final _logGroupForm = Logger('GroupForm'); +final _logGroupForm = Logger.detached('GroupForm'); class GroupForm implements FormModel { GroupForm( @@ -727,7 +730,7 @@ class GroupForm implements FormModel { disabled: false); } -final _logPersonalForm = Logger('PersonalForm'); +final _logPersonalForm = Logger.detached('PersonalForm'); class PersonalForm implements FormModel { PersonalForm( @@ -1041,7 +1044,7 @@ class PersonalForm implements FormModel { disabled: false); } -final _logPhoneForm = Logger('PhoneForm'); +final _logPhoneForm = Logger.detached('PhoneForm'); class PhoneForm implements FormModel { PhoneForm( @@ -1355,7 +1358,7 @@ class PhoneForm implements FormModel { disabled: false); } -final _logAddressForm = Logger('AddressForm'); +final _logAddressForm = Logger.detached('AddressForm'); class AddressForm implements FormModel { AddressForm( diff --git a/packages/reactive_forms_generator/example/lib/docs/login/login.gform.dart b/packages/reactive_forms_generator/example/lib/docs/login/login.gform.dart index 87d4fec..7b9c86a 100644 --- a/packages/reactive_forms_generator/example/lib/docs/login/login.gform.dart +++ b/packages/reactive_forms_generator/example/lib/docs/login/login.gform.dart @@ -132,6 +132,8 @@ class LoginFormBuilder extends StatefulWidget { class _LoginFormBuilderState extends State { late LoginForm _formModel; + StreamSubscription? _logSubscription; + @override void initState() { _formModel = LoginForm(LoginForm.formElements(widget.model), null); @@ -142,7 +144,7 @@ class _LoginFormBuilderState extends State { widget.initState?.call(context, _formModel); - _logLoginForm.onRecord.listen((LogRecord e) { + _logSubscription = _logLoginForm.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 @@ -185,6 +187,7 @@ class _LoginFormBuilderState extends State { @override void dispose() { _formModel.form.dispose(); + _logSubscription?.cancel(); super.dispose(); } @@ -207,7 +210,7 @@ class _LoginFormBuilderState extends State { } } -final _logLoginForm = Logger('LoginForm'); +final _logLoginForm = Logger.detached('LoginForm'); class LoginForm implements FormModel { LoginForm( diff --git a/packages/reactive_forms_generator/example/lib/docs/login/login_output.gform.dart b/packages/reactive_forms_generator/example/lib/docs/login/login_output.gform.dart index 6a9e5c3..9fe5588 100644 --- a/packages/reactive_forms_generator/example/lib/docs/login/login_output.gform.dart +++ b/packages/reactive_forms_generator/example/lib/docs/login/login_output.gform.dart @@ -132,6 +132,8 @@ class LoginOFormBuilder extends StatefulWidget { class _LoginOFormBuilderState extends State { late LoginOForm _formModel; + StreamSubscription? _logSubscription; + @override void initState() { _formModel = LoginOForm(LoginOForm.formElements(widget.model), null); @@ -142,7 +144,7 @@ class _LoginOFormBuilderState extends State { widget.initState?.call(context, _formModel); - _logLoginOForm.onRecord.listen((LogRecord e) { + _logSubscription = _logLoginOForm.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 @@ -185,6 +187,7 @@ class _LoginOFormBuilderState extends State { @override void dispose() { _formModel.form.dispose(); + _logSubscription?.cancel(); super.dispose(); } @@ -207,7 +210,7 @@ class _LoginOFormBuilderState extends State { } } -final _logLoginOForm = Logger('LoginOForm'); +final _logLoginOForm = Logger.detached('LoginOForm'); class LoginOForm implements FormModel { LoginOForm( diff --git a/packages/reactive_forms_generator/example/lib/docs/login_extended/login_extended.gform.dart b/packages/reactive_forms_generator/example/lib/docs/login_extended/login_extended.gform.dart index 092b85a..11efc95 100644 --- a/packages/reactive_forms_generator/example/lib/docs/login_extended/login_extended.gform.dart +++ b/packages/reactive_forms_generator/example/lib/docs/login_extended/login_extended.gform.dart @@ -137,6 +137,8 @@ class LoginExtendedFormBuilder extends StatefulWidget { class _LoginExtendedFormBuilderState extends State { late LoginExtendedForm _formModel; + StreamSubscription? _logSubscription; + @override void initState() { _formModel = @@ -148,7 +150,7 @@ class _LoginExtendedFormBuilderState extends State { widget.initState?.call(context, _formModel); - _logLoginExtendedForm.onRecord.listen((LogRecord e) { + _logSubscription = _logLoginExtendedForm.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 @@ -191,6 +193,7 @@ class _LoginExtendedFormBuilderState extends State { @override void dispose() { _formModel.form.dispose(); + _logSubscription?.cancel(); super.dispose(); } @@ -213,7 +216,7 @@ class _LoginExtendedFormBuilderState extends State { } } -final _logLoginExtendedForm = Logger('LoginExtendedForm'); +final _logLoginExtendedForm = Logger.detached('LoginExtendedForm'); class LoginExtendedForm implements FormModel { LoginExtendedForm( diff --git a/packages/reactive_forms_generator/example/lib/docs/login_extended/login_extended_output.gform.dart b/packages/reactive_forms_generator/example/lib/docs/login_extended/login_extended_output.gform.dart index 3c203f1..4536e2d 100644 --- a/packages/reactive_forms_generator/example/lib/docs/login_extended/login_extended_output.gform.dart +++ b/packages/reactive_forms_generator/example/lib/docs/login_extended/login_extended_output.gform.dart @@ -139,6 +139,8 @@ class LoginExtendedOFormBuilder extends StatefulWidget { class _LoginExtendedOFormBuilderState extends State { late LoginExtendedOForm _formModel; + StreamSubscription? _logSubscription; + @override void initState() { _formModel = @@ -150,7 +152,7 @@ class _LoginExtendedOFormBuilderState extends State { widget.initState?.call(context, _formModel); - _logLoginExtendedOForm.onRecord.listen((LogRecord e) { + _logSubscription = _logLoginExtendedOForm.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 @@ -193,6 +195,7 @@ class _LoginExtendedOFormBuilderState extends State { @override void dispose() { _formModel.form.dispose(); + _logSubscription?.cancel(); super.dispose(); } @@ -215,7 +218,7 @@ class _LoginExtendedOFormBuilderState extends State { } } -final _logLoginExtendedOForm = Logger('LoginExtendedOForm'); +final _logLoginExtendedOForm = Logger.detached('LoginExtendedOForm'); class LoginExtendedOForm implements FormModel { diff --git a/packages/reactive_forms_generator/example/lib/docs/login_extended_nullable/login_extended_nullable.gform.dart b/packages/reactive_forms_generator/example/lib/docs/login_extended_nullable/login_extended_nullable.gform.dart index 8e37f4d..bb5e565 100644 --- a/packages/reactive_forms_generator/example/lib/docs/login_extended_nullable/login_extended_nullable.gform.dart +++ b/packages/reactive_forms_generator/example/lib/docs/login_extended_nullable/login_extended_nullable.gform.dart @@ -139,6 +139,8 @@ class _LoginExtendedNullableFormBuilderState extends State { late LoginExtendedNullableForm _formModel; + StreamSubscription? _logSubscription; + @override void initState() { _formModel = LoginExtendedNullableForm( @@ -150,7 +152,8 @@ class _LoginExtendedNullableFormBuilderState widget.initState?.call(context, _formModel); - _logLoginExtendedNullableForm.onRecord.listen((LogRecord e) { + _logSubscription = + _logLoginExtendedNullableForm.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 @@ -193,6 +196,7 @@ class _LoginExtendedNullableFormBuilderState @override void dispose() { _formModel.form.dispose(); + _logSubscription?.cancel(); super.dispose(); } @@ -215,7 +219,8 @@ class _LoginExtendedNullableFormBuilderState } } -final _logLoginExtendedNullableForm = Logger('LoginExtendedNullableForm'); +final _logLoginExtendedNullableForm = + Logger.detached('LoginExtendedNullableForm'); class LoginExtendedNullableForm implements FormModel { diff --git a/packages/reactive_forms_generator/example/lib/docs/login_extended_nullable/login_extended_nullable_output.gform.dart b/packages/reactive_forms_generator/example/lib/docs/login_extended_nullable/login_extended_nullable_output.gform.dart index e5305b6..047e6a6 100644 --- a/packages/reactive_forms_generator/example/lib/docs/login_extended_nullable/login_extended_nullable_output.gform.dart +++ b/packages/reactive_forms_generator/example/lib/docs/login_extended_nullable/login_extended_nullable_output.gform.dart @@ -139,6 +139,8 @@ class _LoginExtendedNullableOFormBuilderState extends State { late LoginExtendedNullableOForm _formModel; + StreamSubscription? _logSubscription; + @override void initState() { _formModel = LoginExtendedNullableOForm( @@ -150,7 +152,8 @@ class _LoginExtendedNullableOFormBuilderState widget.initState?.call(context, _formModel); - _logLoginExtendedNullableOForm.onRecord.listen((LogRecord e) { + _logSubscription = + _logLoginExtendedNullableOForm.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 @@ -193,6 +196,7 @@ class _LoginExtendedNullableOFormBuilderState @override void dispose() { _formModel.form.dispose(); + _logSubscription?.cancel(); super.dispose(); } @@ -215,7 +219,8 @@ class _LoginExtendedNullableOFormBuilderState } } -final _logLoginExtendedNullableOForm = Logger('LoginExtendedNullableOForm'); +final _logLoginExtendedNullableOForm = + Logger.detached('LoginExtendedNullableOForm'); class LoginExtendedNullableOForm implements FormModel { diff --git a/packages/reactive_forms_generator/example/lib/docs/mailing_list/mailing_list.dart b/packages/reactive_forms_generator/example/lib/docs/mailing_list/mailing_list.dart index 574ab7e..60e9ea3 100644 --- a/packages/reactive_forms_generator/example/lib/docs/mailing_list/mailing_list.dart +++ b/packages/reactive_forms_generator/example/lib/docs/mailing_list/mailing_list.dart @@ -1,3 +1,5 @@ +import 'dart:async'; + import 'package:example/helpers.dart'; import 'package:reactive_forms_annotations/reactive_forms_annotations.dart'; diff --git a/packages/reactive_forms_generator/example/lib/docs/mailing_list/mailing_list.gform.dart b/packages/reactive_forms_generator/example/lib/docs/mailing_list/mailing_list.gform.dart index 911e4af..deee0be 100644 --- a/packages/reactive_forms_generator/example/lib/docs/mailing_list/mailing_list.gform.dart +++ b/packages/reactive_forms_generator/example/lib/docs/mailing_list/mailing_list.gform.dart @@ -135,6 +135,8 @@ class MailingListFormBuilder extends StatefulWidget { class _MailingListFormBuilderState extends State { late MailingListForm _formModel; + StreamSubscription? _logSubscription; + @override void initState() { _formModel = @@ -146,7 +148,7 @@ class _MailingListFormBuilderState extends State { widget.initState?.call(context, _formModel); - _logMailingListForm.onRecord.listen((LogRecord e) { + _logSubscription = _logMailingListForm.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 @@ -189,6 +191,7 @@ class _MailingListFormBuilderState extends State { @override void dispose() { _formModel.form.dispose(); + _logSubscription?.cancel(); super.dispose(); } @@ -211,7 +214,7 @@ class _MailingListFormBuilderState extends State { } } -final _logMailingListForm = Logger('MailingListForm'); +final _logMailingListForm = Logger.detached('MailingListForm'); class MailingListForm implements FormModel { MailingListForm( diff --git a/packages/reactive_forms_generator/example/lib/docs/model_extends/model_extends.gform.dart b/packages/reactive_forms_generator/example/lib/docs/model_extends/model_extends.gform.dart index 7a39488..4a13dbf 100644 --- a/packages/reactive_forms_generator/example/lib/docs/model_extends/model_extends.gform.dart +++ b/packages/reactive_forms_generator/example/lib/docs/model_extends/model_extends.gform.dart @@ -137,6 +137,8 @@ class ModelExtendsFormBuilder extends StatefulWidget { class _ModelExtendsFormBuilderState extends State { late ModelExtendsForm _formModel; + StreamSubscription? _logSubscription; + @override void initState() { _formModel = @@ -148,7 +150,7 @@ class _ModelExtendsFormBuilderState extends State { widget.initState?.call(context, _formModel); - _logModelExtendsForm.onRecord.listen((LogRecord e) { + _logSubscription = _logModelExtendsForm.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 @@ -191,6 +193,7 @@ class _ModelExtendsFormBuilderState extends State { @override void dispose() { _formModel.form.dispose(); + _logSubscription?.cancel(); super.dispose(); } @@ -213,7 +216,7 @@ class _ModelExtendsFormBuilderState extends State { } } -final _logModelExtendsForm = Logger('ModelExtendsForm'); +final _logModelExtendsForm = Logger.detached('ModelExtendsForm'); class ModelExtendsForm implements FormModel { ModelExtendsForm( diff --git a/packages/reactive_forms_generator/example/lib/docs/model_implements/model_implements.gform.dart b/packages/reactive_forms_generator/example/lib/docs/model_implements/model_implements.gform.dart index 184120a..48680a5 100644 --- a/packages/reactive_forms_generator/example/lib/docs/model_implements/model_implements.gform.dart +++ b/packages/reactive_forms_generator/example/lib/docs/model_implements/model_implements.gform.dart @@ -140,6 +140,8 @@ class _ModelImplementsFormBuilderState extends State { late ModelImplementsForm _formModel; + StreamSubscription? _logSubscription; + @override void initState() { _formModel = ModelImplementsForm( @@ -151,7 +153,7 @@ class _ModelImplementsFormBuilderState widget.initState?.call(context, _formModel); - _logModelImplementsForm.onRecord.listen((LogRecord e) { + _logSubscription = _logModelImplementsForm.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 @@ -194,6 +196,7 @@ class _ModelImplementsFormBuilderState @override void dispose() { _formModel.form.dispose(); + _logSubscription?.cancel(); super.dispose(); } @@ -216,7 +219,7 @@ class _ModelImplementsFormBuilderState } } -final _logModelImplementsForm = Logger('ModelImplementsForm'); +final _logModelImplementsForm = Logger.detached('ModelImplementsForm'); class ModelImplementsForm implements FormModel { diff --git a/packages/reactive_forms_generator/example/lib/docs/nested/nested.gform.dart b/packages/reactive_forms_generator/example/lib/docs/nested/nested.gform.dart index e0e505b..6679ba2 100644 --- a/packages/reactive_forms_generator/example/lib/docs/nested/nested.gform.dart +++ b/packages/reactive_forms_generator/example/lib/docs/nested/nested.gform.dart @@ -133,6 +133,8 @@ class SubGroupFormBuilder extends StatefulWidget { class _SubGroupFormBuilderState extends State { late SubGroupForm _formModel; + StreamSubscription? _logSubscription; + @override void initState() { _formModel = SubGroupForm(SubGroupForm.formElements(widget.model), null); @@ -143,7 +145,7 @@ class _SubGroupFormBuilderState extends State { widget.initState?.call(context, _formModel); - _logSubGroupForm.onRecord.listen((LogRecord e) { + _logSubscription = _logSubGroupForm.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 @@ -186,6 +188,7 @@ class _SubGroupFormBuilderState extends State { @override void dispose() { _formModel.form.dispose(); + _logSubscription?.cancel(); super.dispose(); } @@ -208,7 +211,7 @@ class _SubGroupFormBuilderState extends State { } } -final _logSubGroupForm = Logger('SubGroupForm'); +final _logSubGroupForm = Logger.detached('SubGroupForm'); class SubGroupForm implements FormModel { SubGroupForm( @@ -650,6 +653,8 @@ class GroupFormBuilder extends StatefulWidget { class _GroupFormBuilderState extends State { late GroupForm _formModel; + StreamSubscription? _logSubscription; + @override void initState() { _formModel = GroupForm(GroupForm.formElements(widget.model), null); @@ -660,7 +665,7 @@ class _GroupFormBuilderState extends State { widget.initState?.call(context, _formModel); - _logGroupForm.onRecord.listen((LogRecord e) { + _logSubscription = _logGroupForm.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 @@ -703,6 +708,7 @@ class _GroupFormBuilderState extends State { @override void dispose() { _formModel.form.dispose(); + _logSubscription?.cancel(); super.dispose(); } @@ -725,7 +731,7 @@ class _GroupFormBuilderState extends State { } } -final _logGroupForm = Logger('GroupForm'); +final _logGroupForm = Logger.detached('GroupForm'); class GroupForm implements FormModel { GroupForm( @@ -1355,6 +1361,8 @@ class NestedFormBuilder extends StatefulWidget { class _NestedFormBuilderState extends State { late NestedForm _formModel; + StreamSubscription? _logSubscription; + @override void initState() { _formModel = NestedForm(NestedForm.formElements(widget.model), null); @@ -1365,7 +1373,7 @@ class _NestedFormBuilderState extends State { widget.initState?.call(context, _formModel); - _logNestedForm.onRecord.listen((LogRecord e) { + _logSubscription = _logNestedForm.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 @@ -1408,6 +1416,7 @@ class _NestedFormBuilderState extends State { @override void dispose() { _formModel.form.dispose(); + _logSubscription?.cancel(); super.dispose(); } @@ -1430,7 +1439,7 @@ class _NestedFormBuilderState extends State { } } -final _logNestedForm = Logger('NestedForm'); +final _logNestedForm = Logger.detached('NestedForm'); class NestedForm implements FormModel { NestedForm( diff --git a/packages/reactive_forms_generator/example/lib/docs/profile/profile.gform.dart b/packages/reactive_forms_generator/example/lib/docs/profile/profile.gform.dart index 9348c28..c17accd 100644 --- a/packages/reactive_forms_generator/example/lib/docs/profile/profile.gform.dart +++ b/packages/reactive_forms_generator/example/lib/docs/profile/profile.gform.dart @@ -132,6 +132,8 @@ class ProfileFormBuilder extends StatefulWidget { class _ProfileFormBuilderState extends State { late ProfileForm _formModel; + StreamSubscription? _logSubscription; + @override void initState() { _formModel = ProfileForm(ProfileForm.formElements(widget.model), null); @@ -142,7 +144,7 @@ class _ProfileFormBuilderState extends State { widget.initState?.call(context, _formModel); - _logProfileForm.onRecord.listen((LogRecord e) { + _logSubscription = _logProfileForm.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 @@ -185,6 +187,7 @@ class _ProfileFormBuilderState extends State { @override void dispose() { _formModel.form.dispose(); + _logSubscription?.cancel(); super.dispose(); } @@ -207,7 +210,7 @@ class _ProfileFormBuilderState extends State { } } -final _logProfileForm = Logger('ProfileForm'); +final _logProfileForm = Logger.detached('ProfileForm'); class ProfileForm implements FormModel { ProfileForm( @@ -1100,7 +1103,7 @@ class ProfileForm implements FormModel { disabled: false); } -final _logIncidenceFilterForm = Logger('IncidenceFilterForm'); +final _logIncidenceFilterForm = Logger.detached('IncidenceFilterForm'); class IncidenceFilterForm implements FormModel { @@ -1682,7 +1685,7 @@ class IncidenceFilterForm disabled: false); } -final _logThresholdSettingForm = Logger('ThresholdSettingForm'); +final _logThresholdSettingForm = Logger.detached('ThresholdSettingForm'); class ThresholdSettingForm implements FormModel { @@ -1944,7 +1947,7 @@ class ThresholdSettingForm disabled: false); } -final _logTimerSettingForm = Logger('TimerSettingForm'); +final _logTimerSettingForm = Logger.detached('TimerSettingForm'); class TimerSettingForm implements FormModel { TimerSettingForm( diff --git a/packages/reactive_forms_generator/example/lib/docs/renamed_basic/renamed_basic.gform.dart b/packages/reactive_forms_generator/example/lib/docs/renamed_basic/renamed_basic.gform.dart index 9a6165a..30c263d 100644 --- a/packages/reactive_forms_generator/example/lib/docs/renamed_basic/renamed_basic.gform.dart +++ b/packages/reactive_forms_generator/example/lib/docs/renamed_basic/renamed_basic.gform.dart @@ -137,6 +137,8 @@ class SomeWiredNameFormBuilder extends StatefulWidget { class _SomeWiredNameFormBuilderState extends State { late SomeWiredNameForm _formModel; + StreamSubscription? _logSubscription; + @override void initState() { _formModel = @@ -148,7 +150,7 @@ class _SomeWiredNameFormBuilderState extends State { widget.initState?.call(context, _formModel); - _logSomeWiredNameForm.onRecord.listen((LogRecord e) { + _logSubscription = _logSomeWiredNameForm.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 @@ -191,6 +193,7 @@ class _SomeWiredNameFormBuilderState extends State { @override void dispose() { _formModel.form.dispose(); + _logSubscription?.cancel(); super.dispose(); } @@ -213,7 +216,7 @@ class _SomeWiredNameFormBuilderState extends State { } } -final _logSomeWiredNameForm = Logger('SomeWiredNameForm'); +final _logSomeWiredNameForm = Logger.detached('SomeWiredNameForm'); class SomeWiredNameForm implements FormModel { SomeWiredNameForm( diff --git a/packages/reactive_forms_generator/example/lib/docs/renamed_basic/renamed_basic_output.gform.dart b/packages/reactive_forms_generator/example/lib/docs/renamed_basic/renamed_basic_output.gform.dart index 8c9d57d..f72bd31 100644 --- a/packages/reactive_forms_generator/example/lib/docs/renamed_basic/renamed_basic_output.gform.dart +++ b/packages/reactive_forms_generator/example/lib/docs/renamed_basic/renamed_basic_output.gform.dart @@ -137,6 +137,8 @@ class SomeWiredNameFormBuilder extends StatefulWidget { class _SomeWiredNameFormBuilderState extends State { late SomeWiredNameForm _formModel; + StreamSubscription? _logSubscription; + @override void initState() { _formModel = @@ -148,7 +150,7 @@ class _SomeWiredNameFormBuilderState extends State { widget.initState?.call(context, _formModel); - _logSomeWiredNameForm.onRecord.listen((LogRecord e) { + _logSubscription = _logSomeWiredNameForm.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 @@ -191,6 +193,7 @@ class _SomeWiredNameFormBuilderState extends State { @override void dispose() { _formModel.form.dispose(); + _logSubscription?.cancel(); super.dispose(); } @@ -213,7 +216,7 @@ class _SomeWiredNameFormBuilderState extends State { } } -final _logSomeWiredNameForm = Logger('SomeWiredNameForm'); +final _logSomeWiredNameForm = Logger.detached('SomeWiredNameForm'); class SomeWiredNameForm implements FormModel { diff --git a/packages/reactive_forms_generator/example/lib/docs/user_profile/user_profile.gform.dart b/packages/reactive_forms_generator/example/lib/docs/user_profile/user_profile.gform.dart index 3dcbbc8..8004f8b 100644 --- a/packages/reactive_forms_generator/example/lib/docs/user_profile/user_profile.gform.dart +++ b/packages/reactive_forms_generator/example/lib/docs/user_profile/user_profile.gform.dart @@ -135,6 +135,8 @@ class UserProfileFormBuilder extends StatefulWidget { class _UserProfileFormBuilderState extends State { late UserProfileForm _formModel; + StreamSubscription? _logSubscription; + @override void initState() { _formModel = @@ -146,7 +148,7 @@ class _UserProfileFormBuilderState extends State { widget.initState?.call(context, _formModel); - _logUserProfileForm.onRecord.listen((LogRecord e) { + _logSubscription = _logUserProfileForm.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 @@ -189,6 +191,7 @@ class _UserProfileFormBuilderState extends State { @override void dispose() { _formModel.form.dispose(); + _logSubscription?.cancel(); super.dispose(); } @@ -211,7 +214,7 @@ class _UserProfileFormBuilderState extends State { } } -final _logUserProfileForm = Logger('UserProfileForm'); +final _logUserProfileForm = Logger.detached('UserProfileForm'); class UserProfileForm implements FormModel { UserProfileForm( @@ -726,7 +729,7 @@ class UserProfileForm implements FormModel { disabled: false); } -final _logAddressForm = Logger('AddressForm'); +final _logAddressForm = Logger.detached('AddressForm'); class AddressForm implements FormModel { AddressForm( diff --git a/packages/reactive_forms_generator/example/lib/docs/user_profile/user_profile_output.gform.dart b/packages/reactive_forms_generator/example/lib/docs/user_profile/user_profile_output.gform.dart index 8648260..b23fc63 100644 --- a/packages/reactive_forms_generator/example/lib/docs/user_profile/user_profile_output.gform.dart +++ b/packages/reactive_forms_generator/example/lib/docs/user_profile/user_profile_output.gform.dart @@ -137,6 +137,8 @@ class UserProfileOFormBuilder extends StatefulWidget { class _UserProfileOFormBuilderState extends State { late UserProfileOForm _formModel; + StreamSubscription? _logSubscription; + @override void initState() { _formModel = @@ -148,7 +150,7 @@ class _UserProfileOFormBuilderState extends State { widget.initState?.call(context, _formModel); - _logUserProfileOForm.onRecord.listen((LogRecord e) { + _logSubscription = _logUserProfileOForm.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 @@ -191,6 +193,7 @@ class _UserProfileOFormBuilderState extends State { @override void dispose() { _formModel.form.dispose(); + _logSubscription?.cancel(); super.dispose(); } @@ -213,7 +216,7 @@ class _UserProfileOFormBuilderState extends State { } } -final _logUserProfileOForm = Logger('UserProfileOForm'); +final _logUserProfileOForm = Logger.detached('UserProfileOForm'); class UserProfileOForm implements FormModel { UserProfileOForm( @@ -780,7 +783,7 @@ class UserProfileOForm implements FormModel { disabled: false); } -final _logAddressOForm = Logger('AddressOForm'); +final _logAddressOForm = Logger.detached('AddressOForm'); class AddressOForm implements FormModel { AddressOForm( diff --git a/packages/reactive_forms_generator/example/lib/main.dart b/packages/reactive_forms_generator/example/lib/main.dart index 67b73f0..34ca085 100644 --- a/packages/reactive_forms_generator/example/lib/main.dart +++ b/packages/reactive_forms_generator/example/lib/main.dart @@ -52,7 +52,7 @@ class MyApp extends StatelessWidget { Routes.modelImplements: (_) => const ModelImplementsWidget(), Routes.nested: (_) => const NestedFormWidget(), }, - home: const LoginFormWidget(), + home: const UrlListForm(), ); } } diff --git a/packages/reactive_forms_generator/lib/src/form_generator.dart b/packages/reactive_forms_generator/lib/src/form_generator.dart index 804e0b9..7ce8e70 100644 --- a/packages/reactive_forms_generator/lib/src/form_generator.dart +++ b/packages/reactive_forms_generator/lib/src/form_generator.dart @@ -591,7 +591,7 @@ class FormGenerator { }, ); - Code get logging => Code("final $log = Logger('$classNameFull');"); + Code get logging => Code("final $log = Logger.detached('$classNameFull');"); Constructor get _constructor => Constructor( (b) => b diff --git a/packages/reactive_forms_generator/lib/src/reactive_forms/reactive_form_builder.dart b/packages/reactive_forms_generator/lib/src/reactive_forms/reactive_form_builder.dart index 0a1158a..7685053 100644 --- a/packages/reactive_forms_generator/lib/src/reactive_forms/reactive_form_builder.dart +++ b/packages/reactive_forms_generator/lib/src/reactive_forms/reactive_form_builder.dart @@ -163,7 +163,7 @@ class ReactiveFormBuilder { widget.initState?.call(context, _formModel); - $_log.onRecord.listen((LogRecord e) { + _logSubscription = $_log.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 @@ -222,6 +222,7 @@ class ReactiveFormBuilder { ..returns = const Reference('void') ..body = const Code(''' _formModel.form.dispose(); + _logSubscription?.cancel(); super.dispose(); '''), ), @@ -273,6 +274,11 @@ class ReactiveFormBuilder { .reactiveInheritedStreamer.formGenerator.classNameFull, ), ), + Field( + (b) => b + ..name = '_logSubscription' + ..type = const Reference('StreamSubscription?'), + ), ], ) ..methods.addAll(_stateMethods), diff --git a/packages/reactive_forms_generator/pubspec.yaml b/packages/reactive_forms_generator/pubspec.yaml index ac71151..869cc27 100644 --- a/packages/reactive_forms_generator/pubspec.yaml +++ b/packages/reactive_forms_generator/pubspec.yaml @@ -15,7 +15,7 @@ repository: https://github.com/artflutter/reactive_forms_generator # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 6.0.0-beta.4 +version: 6.0.0-beta.6 environment: sdk: ">=3.0.0 <4.0.0"