From 40de5c4be8cdcc4c9f65abaaaf721a908c82b799 Mon Sep 17 00:00:00 2001 From: Martin Edlman Date: Mon, 18 Jan 2021 09:32:16 +0100 Subject: [PATCH 1/4] Rename 'clear' to 'reset' to match other form fields. Put 'reset' icon into text field as 'suffixIcon' to match other form fields (datetime, dropdown, ...) Move 'close' button from 'end' to 'start' to not cover 'My position' button when enabled in LocationFieldDialog. Signed-off-by: Martin Edlman --- example/pubspec.lock | 106 +++++---------------- lib/src/form_builder_location_field.dart | 95 +++++++++++-------- lib/src/location_field_dialog.dart | 2 +- pubspec.lock | 116 ++++++----------------- pubspec.yaml | 6 +- 5 files changed, 114 insertions(+), 211 deletions(-) diff --git a/example/pubspec.lock b/example/pubspec.lock index 0738b4a..7a127f9 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -71,13 +71,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.15.0-nullsafety.3" - community_material_icon: - dependency: transitive - description: - name: community_material_icon - url: "https://pub.dartlang.org" - source: hosted - version: "5.4.55" convert: dependency: transitive description: @@ -85,13 +78,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.1.1" - country_pickers: - dependency: transitive - description: - name: country_pickers - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.0" crypto: dependency: transitive description: @@ -119,7 +105,7 @@ packages: name: dropdown_search url: "https://pub.dartlang.org" source: hosted - version: "0.4.6" + version: "0.4.8" fake_async: dependency: transitive description: @@ -127,13 +113,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.2.0-nullsafety.1" - file_picker: - dependency: transitive - description: - name: file_picker - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.13" flutter: dependency: "direct main" description: flutter @@ -145,14 +124,14 @@ packages: name: flutter_chips_input url: "https://pub.dartlang.org" source: hosted - version: "1.9.4" + version: "1.9.5" flutter_colorpicker: dependency: transitive description: name: flutter_colorpicker url: "https://pub.dartlang.org" source: hosted - version: "0.3.4" + version: "0.3.5" flutter_datetime_picker: dependency: transitive description: @@ -166,14 +145,28 @@ packages: name: flutter_form_builder url: "https://pub.dartlang.org" source: hosted - version: "4.0.0-pre.7" + version: "4.2.0" flutter_keyboard_visibility: dependency: transitive description: name: flutter_keyboard_visibility url: "https://pub.dartlang.org" source: hosted - version: "3.3.0" + version: "4.0.2" + flutter_keyboard_visibility_platform_interface: + dependency: transitive + description: + name: flutter_keyboard_visibility_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" + flutter_keyboard_visibility_web: + dependency: transitive + description: + name: flutter_keyboard_visibility_web + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" flutter_localizations: dependency: transitive description: flutter @@ -185,7 +178,7 @@ packages: name: flutter_plugin_android_lifecycle url: "https://pub.dartlang.org" source: hosted - version: "1.0.6" + version: "1.0.11" flutter_test: dependency: "direct dev" description: flutter @@ -204,7 +197,7 @@ packages: name: flutter_typeahead url: "https://pub.dartlang.org" source: hosted - version: "1.8.8" + version: "1.9.3" flutter_web_plugins: dependency: transitive description: flutter @@ -223,14 +216,14 @@ packages: name: google_maps_flutter url: "https://pub.dartlang.org" source: hosted - version: "1.0.6" + version: "1.1.1" google_maps_flutter_platform_interface: dependency: transitive description: name: google_maps_flutter_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.0.5" + version: "1.1.0" http: dependency: transitive description: @@ -252,27 +245,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.1.19" - image_picker: - dependency: transitive - description: - name: image_picker - url: "https://pub.dartlang.org" - source: hosted - version: "0.6.7+14" - image_picker_for_web: - dependency: transitive - description: - name: image_picker_for_web - url: "https://pub.dartlang.org" - source: hosted - version: "0.1.0+2" - image_picker_platform_interface: - dependency: transitive - description: - name: image_picker_platform_interface - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.1" intl: dependency: transitive description: @@ -280,13 +252,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.16.1" - js: - dependency: transitive - description: - name: js - url: "https://pub.dartlang.org" - source: hosted - version: "0.6.2" json_annotation: dependency: transitive description: @@ -329,20 +294,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.9.2" - permission_handler: - dependency: transitive - description: - name: permission_handler - url: "https://pub.dartlang.org" - source: hosted - version: "5.0.1+1" - permission_handler_platform_interface: - dependency: transitive - description: - name: permission_handler_platform_interface - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.1" petitparser: dependency: transitive description: @@ -350,13 +301,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "3.1.0" - phone_number: - dependency: transitive - description: - name: phone_number - url: "https://pub.dartlang.org" - source: hosted - version: "0.8.1" plugin_platform_interface: dependency: transitive description: @@ -473,7 +417,7 @@ packages: name: vin_decoder url: "https://pub.dartlang.org" source: hosted - version: "0.1.2" + version: "0.1.3" xml: dependency: transitive description: @@ -482,5 +426,5 @@ packages: source: hosted version: "4.5.1" sdks: - dart: ">=2.10.0-110 <2.11.0" + dart: ">=2.10.0 <2.11.0" flutter: ">=1.22.0 <2.0.0" diff --git a/lib/src/form_builder_location_field.dart b/lib/src/form_builder_location_field.dart index ba6fa74..c6d349e 100644 --- a/lib/src/form_builder_location_field.dart +++ b/lib/src/form_builder_location_field.dart @@ -161,16 +161,14 @@ class FormBuilderLocationField extends FormBuilderField { final Color markerIconColor; final double height; final bool allowClear; - final Widget clearIcon; - - // final TextEditingController textEditingController; + final Widget resetIcon; + final TextEditingController controller; FormBuilderLocationField({ Key key, //From Super @required String name, FormFieldValidator validator, - CameraPosition initialValue, InputDecoration decoration = const InputDecoration(), ValueChanged onChanged, ValueTransformer valueTransformer, @@ -180,7 +178,7 @@ class FormBuilderLocationField extends FormBuilderField { VoidCallback onReset, FocusNode focusNode, this.allowClear = true, - this.clearIcon = const Icon(Icons.close), + this.resetIcon = const Icon(Icons.close), this.markerIcon = Icons.person_pin_circle_sharp, this.markerIconSize = 30, this.markerIconColor = Colors.black, @@ -214,9 +212,10 @@ class FormBuilderLocationField extends FormBuilderField { this.onMapCreated, this.initialCameraPosition, this.onCameraMove, + this.controller, }) : super( key: key, - initialValue: initialValue, + initialValue: initialCameraPosition, name: name, validator: validator, valueTransformer: valueTransformer, @@ -228,31 +227,27 @@ class FormBuilderLocationField extends FormBuilderField { decoration: decoration, builder: (FormFieldState field) { final state = field as _FormBuilderLocationFieldState; - - return Row( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Expanded( - child: TextField( - decoration: state.decoration(), - enabled: enabled, - // Setting readOnly to be true hides the keyboard - readOnly: true, - controller: state.effectiveController, - focusNode: state.effectiveFocusNode, - // style: style, - // autofocus: autofocus, - ), - ), - if (allowClear && enabled && state.value != null) - InkWell( - child: clearIcon, - onTap: () { - state.didChange(null); - FocusScope.of(state.context).requestFocus(FocusNode()); - }, - ), - ], + final InputDecoration effectiveDecoration = (decoration ?? + const InputDecoration()) + .applyDefaults(Theme.of(field.context).inputDecorationTheme); + + return TextField( + decoration: effectiveDecoration.copyWith( + errorText: field.errorText, + suffixIcon: state.shouldShowClearIcon(effectiveDecoration) + ? IconButton( + icon: resetIcon, + onPressed: state.clear, + ) + : null, + ), + enabled: enabled, + // Setting readOnly to be true hides the keyboard + readOnly: true, + controller: state._textFieldController, + focusNode: state.effectiveFocusNode, + // style: style, + // autofocus: autofocus, ); }, ); @@ -264,24 +259,23 @@ class FormBuilderLocationField extends FormBuilderField { class _FormBuilderLocationFieldState extends FormBuilderFieldState { - TextEditingController _controller; - - TextEditingController get effectiveController => - /*widget.textEditingController ??*/ _controller; + TextEditingController _textFieldController; String get valueString => value?.target?.toString() ?? ''; @override void initState() { super.initState(); - _controller = TextEditingController(); - effectiveController.text = valueString; - effectiveFocusNode.addListener(_handleFocus); + _textFieldController = widget.controller ?? TextEditingController(); + effectiveFocusNode?.addListener(_handleFocus); } @override void dispose() { - _controller.dispose(); + // Dispose the _textFieldController when initState created it + if (null == widget.controller) { + _textFieldController.dispose(); + } super.dispose(); } @@ -335,6 +329,27 @@ class _FormBuilderLocationFieldState @override void didChange(CameraPosition value) { super.didChange(value); - effectiveController.text = valueString ?? ''; + _textFieldController.text = + widget.valueTransformer?.call(value)?.toString() ?? valueString; + widget.onChanged?.call(value); } + + void clear() async { + _hideKeyboard(); + // Fix for ripple effect throwing exception + // and the field staying gray. + // https://github.com/flutter/flutter/issues/36324 + WidgetsBinding.instance.addPostFrameCallback((_) { + setState(() => _textFieldController.clear()); + }); + } + + void _hideKeyboard() { + Future.microtask(() => FocusScope.of(context).requestFocus(FocusNode())); + } + + bool shouldShowClearIcon([InputDecoration decoration]) => + widget.resetIcon != null && + (_textFieldController.text.isNotEmpty || effectiveFocusNode.hasFocus) && + decoration?.suffixIcon == null; } diff --git a/lib/src/location_field_dialog.dart b/lib/src/location_field_dialog.dart index 647e1e4..497f1a4 100644 --- a/lib/src/location_field_dialog.dart +++ b/lib/src/location_field_dialog.dart @@ -159,7 +159,7 @@ class _LocationFieldDialogState extends State { Padding( padding: const EdgeInsets.all(8.0), child: Row( - mainAxisAlignment: MainAxisAlignment.end, + mainAxisAlignment: MainAxisAlignment.start, children: [ FloatingActionButton( backgroundColor: theme.scaffoldBackgroundColor, diff --git a/pubspec.lock b/pubspec.lock index 03f5b1c..54111ea 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -7,14 +7,14 @@ packages: name: archive url: "https://pub.dartlang.org" source: hosted - version: "2.0.11" + version: "2.0.13" args: dependency: transitive description: name: args url: "https://pub.dartlang.org" source: hosted - version: "1.5.2" + version: "1.6.0" asn1lib: dependency: transitive description: @@ -35,7 +35,7 @@ packages: name: basic_utils url: "https://pub.dartlang.org" source: hosted - version: "2.6.0" + version: "2.6.3" boolean_selector: dependency: transitive description: @@ -71,13 +71,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.15.0-nullsafety.3" - community_material_icon: - dependency: transitive - description: - name: community_material_icon - url: "https://pub.dartlang.org" - source: hosted - version: "5.4.55" convert: dependency: transitive description: @@ -85,20 +78,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.1.1" - country_pickers: - dependency: transitive - description: - name: country_pickers - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.0" crypto: dependency: transitive description: name: crypto url: "https://pub.dartlang.org" source: hosted - version: "2.1.3" + version: "2.1.5" date_range_picker: dependency: transitive description: @@ -119,7 +105,7 @@ packages: name: dropdown_search url: "https://pub.dartlang.org" source: hosted - version: "0.4.6" + version: "0.4.8" fake_async: dependency: transitive description: @@ -127,13 +113,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.2.0-nullsafety.1" - file_picker: - dependency: transitive - description: - name: file_picker - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.13" flutter: dependency: "direct main" description: flutter @@ -145,14 +124,14 @@ packages: name: flutter_chips_input url: "https://pub.dartlang.org" source: hosted - version: "1.9.4" + version: "1.9.5" flutter_colorpicker: dependency: transitive description: name: flutter_colorpicker url: "https://pub.dartlang.org" source: hosted - version: "0.3.4" + version: "0.3.5" flutter_datetime_picker: dependency: transitive description: @@ -166,14 +145,28 @@ packages: name: flutter_form_builder url: "https://pub.dartlang.org" source: hosted - version: "4.0.0-pre.7" + version: "4.2.0" flutter_keyboard_visibility: dependency: transitive description: name: flutter_keyboard_visibility url: "https://pub.dartlang.org" source: hosted - version: "3.3.0" + version: "4.0.2" + flutter_keyboard_visibility_platform_interface: + dependency: transitive + description: + name: flutter_keyboard_visibility_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" + flutter_keyboard_visibility_web: + dependency: transitive + description: + name: flutter_keyboard_visibility_web + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" flutter_localizations: dependency: transitive description: flutter @@ -185,7 +178,7 @@ packages: name: flutter_plugin_android_lifecycle url: "https://pub.dartlang.org" source: hosted - version: "1.0.6" + version: "1.0.11" flutter_test: dependency: "direct dev" description: flutter @@ -204,7 +197,7 @@ packages: name: flutter_typeahead url: "https://pub.dartlang.org" source: hosted - version: "1.8.8" + version: "1.9.3" flutter_web_plugins: dependency: transitive description: flutter @@ -216,14 +209,14 @@ packages: name: google_maps_flutter url: "https://pub.dartlang.org" source: hosted - version: "1.0.6" + version: "1.1.1" google_maps_flutter_platform_interface: dependency: transitive description: name: google_maps_flutter_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.0.5" + version: "1.1.0" http: dependency: transitive description: @@ -245,27 +238,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.1.19" - image_picker: - dependency: transitive - description: - name: image_picker - url: "https://pub.dartlang.org" - source: hosted - version: "0.6.7+14" - image_picker_for_web: - dependency: transitive - description: - name: image_picker_for_web - url: "https://pub.dartlang.org" - source: hosted - version: "0.1.0+2" - image_picker_platform_interface: - dependency: transitive - description: - name: image_picker_platform_interface - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.1" intl: dependency: transitive description: @@ -273,13 +245,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.16.1" - js: - dependency: transitive - description: - name: js - url: "https://pub.dartlang.org" - source: hosted - version: "0.6.2" json_annotation: dependency: transitive description: @@ -321,21 +286,7 @@ packages: name: pedantic url: "https://pub.dartlang.org" source: hosted - version: "1.8.0+1" - permission_handler: - dependency: transitive - description: - name: permission_handler - url: "https://pub.dartlang.org" - source: hosted - version: "5.0.1+1" - permission_handler_platform_interface: - dependency: transitive - description: - name: permission_handler_platform_interface - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.1" + version: "1.9.2" petitparser: dependency: transitive description: @@ -343,13 +294,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "3.1.0" - phone_number: - dependency: transitive - description: - name: phone_number - url: "https://pub.dartlang.org" - source: hosted - version: "0.8.1" plugin_platform_interface: dependency: transitive description: @@ -466,7 +410,7 @@ packages: name: vin_decoder url: "https://pub.dartlang.org" source: hosted - version: "0.1.2" + version: "0.1.3" xml: dependency: transitive description: @@ -475,5 +419,5 @@ packages: source: hosted version: "4.5.1" sdks: - dart: ">=2.10.0-110 <2.11.0" + dart: ">=2.10.0 <2.11.0" flutter: ">=1.22.0 <2.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index e5e9f03..57c2705 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -4,13 +4,13 @@ version: 1.0.0-alpha.1 homepage: https://github.com/danvick/form_builder_map_field environment: - sdk: ">=2.6.0 <3.0.0" + sdk: ">=2.10.0 <3.0.0" dependencies: flutter: sdk: flutter - flutter_form_builder: ^4.0.0-pre.7 - google_maps_flutter: ^1.0.6 + flutter_form_builder: ^4.2.0 + google_maps_flutter: ^1.1.1 dev_dependencies: flutter_test: From 3daef2ebfbd651be1ae053f8c2107d9cf4d12409 Mon Sep 17 00:00:00 2001 From: Martin Edlman Date: Fri, 5 Feb 2021 10:41:21 +0100 Subject: [PATCH 2/4] Null safety code (part V) Signed-off-by: Martin Edlman --- example/pubspec.lock | 72 ++++++++++++++++++++++---------------------- example/pubspec.yaml | 5 ++- 2 files changed, 40 insertions(+), 37 deletions(-) diff --git a/example/pubspec.lock b/example/pubspec.lock index 7a127f9..da5a8ed 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -15,62 +15,55 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.6.0" - asn1lib: - dependency: transitive - description: - name: asn1lib - url: "https://pub.dartlang.org" - source: hosted - version: "0.6.5" async: dependency: transitive description: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.5.0-nullsafety.1" + version: "2.5.0-nullsafety.3" basic_utils: dependency: transitive description: name: basic_utils url: "https://pub.dartlang.org" source: hosted - version: "2.6.3" + version: "2.7.0" boolean_selector: dependency: transitive description: name: boolean_selector url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.1" + version: "2.1.0-nullsafety.3" characters: dependency: transitive description: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.3" + version: "1.1.0-nullsafety.5" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.1" + version: "1.2.0-nullsafety.3" clock: dependency: transitive description: name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.1" + version: "1.1.0-nullsafety.3" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.15.0-nullsafety.3" + version: "1.15.0-nullsafety.5" convert: dependency: transitive description: @@ -112,7 +105,7 @@ packages: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.1" + version: "1.2.0-nullsafety.3" flutter: dependency: "direct main" description: flutter @@ -138,7 +131,7 @@ packages: name: flutter_datetime_picker url: "https://pub.dartlang.org" source: hosted - version: "1.4.0" + version: "1.5.0" flutter_form_builder: dependency: "direct main" description: @@ -152,7 +145,7 @@ packages: name: flutter_keyboard_visibility url: "https://pub.dartlang.org" source: hosted - version: "4.0.2" + version: "4.0.3" flutter_keyboard_visibility_platform_interface: dependency: transitive description: @@ -216,14 +209,14 @@ packages: name: google_maps_flutter url: "https://pub.dartlang.org" source: hosted - version: "1.1.1" + version: "1.2.0" google_maps_flutter_platform_interface: dependency: transitive description: name: google_maps_flutter_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.2.0" http: dependency: transitive description: @@ -246,19 +239,26 @@ packages: source: hosted version: "2.1.19" intl: - dependency: transitive + dependency: "direct overridden" description: name: intl url: "https://pub.dartlang.org" source: hosted - version: "0.16.1" + version: "0.17.0-nullsafety.2" + js: + dependency: transitive + description: + name: js + url: "https://pub.dartlang.org" + source: hosted + version: "0.6.3-nullsafety.3" json_annotation: dependency: transitive description: name: json_annotation url: "https://pub.dartlang.org" source: hosted - version: "3.0.1" + version: "3.1.1" logging: dependency: transitive description: @@ -272,21 +272,21 @@ packages: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.10-nullsafety.1" + version: "0.12.10-nullsafety.3" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.3" + version: "1.3.0-nullsafety.6" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.0-nullsafety.1" + version: "1.8.0-nullsafety.3" pedantic: dependency: transitive description: @@ -314,7 +314,7 @@ packages: name: pointycastle url: "https://pub.dartlang.org" source: hosted - version: "1.0.2" + version: "2.0.1" random_string: dependency: transitive description: @@ -347,21 +347,21 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.0-nullsafety.2" + version: "1.8.0-nullsafety.4" stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.10.0-nullsafety.1" + version: "1.10.0-nullsafety.6" stream_channel: dependency: transitive description: name: stream_channel url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.1" + version: "2.1.0-nullsafety.3" stream_transform: dependency: transitive description: @@ -375,28 +375,28 @@ packages: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.1" + version: "1.1.0-nullsafety.3" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.1" + version: "1.2.0-nullsafety.3" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.19-nullsafety.2" + version: "0.2.19-nullsafety.6" typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.3" + version: "1.3.0-nullsafety.5" validators: dependency: transitive description: @@ -410,7 +410,7 @@ packages: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.3" + version: "2.1.0-nullsafety.5" vin_decoder: dependency: transitive description: @@ -426,5 +426,5 @@ packages: source: hosted version: "4.5.1" sdks: - dart: ">=2.10.0 <2.11.0" - flutter: ">=1.22.0 <2.0.0" + dart: ">=2.12.0-0.0 <3.0.0" + flutter: ">=1.22.0" diff --git a/example/pubspec.yaml b/example/pubspec.yaml index ccecedb..37136b9 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -10,7 +10,7 @@ dependencies: flutter: sdk: flutter - flutter_form_builder: ^4.0.0-pre.7 + flutter_form_builder: ^4.2.0 form_builder_map_field: path: ../ @@ -18,5 +18,8 @@ dev_dependencies: flutter_test: sdk: flutter +dependency_overrides: + intl: 0.17.0-nullsafety.2 + flutter: uses-material-design: true From 1d2fbcc0a713f7cb34854e8e95aae65d968869f3 Mon Sep 17 00:00:00 2001 From: Martin Edlman Date: Wed, 10 Feb 2021 20:24:13 +0100 Subject: [PATCH 3/4] Make the lib compatible with unsound null safety Signed-off-by: Martin Edlman --- example/pubspec.lock | 2 +- example/pubspec.yaml | 2 +- lib/form_builder_map_field.dart | 3 +- lib/src/form_builder_location_field.dart | 23 +++----- lib/src/location_field_dialog.dart | 2 + pubspec.lock | 74 ++++++++++++------------ pubspec.yaml | 7 ++- 7 files changed, 57 insertions(+), 56 deletions(-) diff --git a/example/pubspec.lock b/example/pubspec.lock index da5a8ed..635f0a2 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -293,7 +293,7 @@ packages: name: pedantic url: "https://pub.dartlang.org" source: hosted - version: "1.9.2" + version: "1.10.0" petitparser: dependency: transitive description: diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 37136b9..ec0d0c7 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -4,7 +4,7 @@ homepage: https://github.com/danvick/form_builder_map_field/tree/master/example version: 1.0.0+1 environment: - sdk: ">=2.1.0 <3.0.0" + sdk: ">=2.12.0-0 <3.0.0" dependencies: flutter: diff --git a/lib/form_builder_map_field.dart b/lib/form_builder_map_field.dart index cfe0b12..5b49c77 100644 --- a/lib/form_builder_map_field.dart +++ b/lib/form_builder_map_field.dart @@ -1,6 +1,7 @@ +// @dart=2.9 + library form_builder_map_field; export 'package:google_maps_flutter/google_maps_flutter.dart'; export './src/form_builder_location_field.dart'; -export 'package:google_maps_flutter/google_maps_flutter.dart'; diff --git a/lib/src/form_builder_location_field.dart b/lib/src/form_builder_location_field.dart index c6d349e..29fb437 100644 --- a/lib/src/form_builder_location_field.dart +++ b/lib/src/form_builder_location_field.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:flutter/foundation.dart'; import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; @@ -227,9 +229,8 @@ class FormBuilderLocationField extends FormBuilderField { decoration: decoration, builder: (FormFieldState field) { final state = field as _FormBuilderLocationFieldState; - final InputDecoration effectiveDecoration = (decoration ?? - const InputDecoration()) - .applyDefaults(Theme.of(field.context).inputDecorationTheme); + final InputDecoration effectiveDecoration = + (decoration ?? const InputDecoration()).applyDefaults(Theme.of(field.context).inputDecorationTheme); return TextField( decoration: effectiveDecoration.copyWith( @@ -253,12 +254,10 @@ class FormBuilderLocationField extends FormBuilderField { ); @override - _FormBuilderLocationFieldState createState() => - _FormBuilderLocationFieldState(); + _FormBuilderLocationFieldState createState() => _FormBuilderLocationFieldState(); } -class _FormBuilderLocationFieldState - extends FormBuilderFieldState { +class _FormBuilderLocationFieldState extends FormBuilderFieldState { TextEditingController _textFieldController; String get valueString => value?.target?.toString() ?? ''; @@ -281,8 +280,7 @@ class _FormBuilderLocationFieldState Future _handleFocus() async { if (effectiveFocusNode.hasFocus && widget.enabled) { - await Future.microtask( - () => FocusScope.of(context).requestFocus(FocusNode())); + await Future.microtask(() => FocusScope.of(context).requestFocus(FocusNode())); final newValue = await showDialog( context: context, builder: (context) => LocationFieldDialog( @@ -329,8 +327,7 @@ class _FormBuilderLocationFieldState @override void didChange(CameraPosition value) { super.didChange(value); - _textFieldController.text = - widget.valueTransformer?.call(value)?.toString() ?? valueString; + _textFieldController.text = widget.valueTransformer?.call(value)?.toString() ?? valueString; widget.onChanged?.call(value); } @@ -349,7 +346,5 @@ class _FormBuilderLocationFieldState } bool shouldShowClearIcon([InputDecoration decoration]) => - widget.resetIcon != null && - (_textFieldController.text.isNotEmpty || effectiveFocusNode.hasFocus) && - decoration?.suffixIcon == null; + widget.resetIcon != null && (_textFieldController.text.isNotEmpty || effectiveFocusNode.hasFocus) && decoration?.suffixIcon == null; } diff --git a/lib/src/location_field_dialog.dart b/lib/src/location_field_dialog.dart index 497f1a4..95a24e4 100644 --- a/lib/src/location_field_dialog.dart +++ b/lib/src/location_field_dialog.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'dart:async'; import 'package:flutter/foundation.dart'; diff --git a/pubspec.lock b/pubspec.lock index 54111ea..393ee18 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -15,62 +15,55 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.6.0" - asn1lib: - dependency: transitive - description: - name: asn1lib - url: "https://pub.dartlang.org" - source: hosted - version: "0.6.5" async: dependency: transitive description: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.5.0-nullsafety.1" + version: "2.5.0-nullsafety.3" basic_utils: dependency: transitive description: name: basic_utils url: "https://pub.dartlang.org" source: hosted - version: "2.6.3" + version: "2.7.0" boolean_selector: dependency: transitive description: name: boolean_selector url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.1" + version: "2.1.0-nullsafety.3" characters: dependency: transitive description: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.3" + version: "1.1.0-nullsafety.5" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.1" + version: "1.2.0-nullsafety.3" clock: dependency: transitive description: name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.1" + version: "1.1.0-nullsafety.3" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.15.0-nullsafety.3" + version: "1.15.0-nullsafety.5" convert: dependency: transitive description: @@ -112,7 +105,7 @@ packages: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.1" + version: "1.2.0-nullsafety.3" flutter: dependency: "direct main" description: flutter @@ -138,7 +131,7 @@ packages: name: flutter_datetime_picker url: "https://pub.dartlang.org" source: hosted - version: "1.4.0" + version: "1.5.0" flutter_form_builder: dependency: "direct main" description: @@ -152,7 +145,7 @@ packages: name: flutter_keyboard_visibility url: "https://pub.dartlang.org" source: hosted - version: "4.0.2" + version: "4.0.3" flutter_keyboard_visibility_platform_interface: dependency: transitive description: @@ -209,14 +202,14 @@ packages: name: google_maps_flutter url: "https://pub.dartlang.org" source: hosted - version: "1.1.1" + version: "1.2.0" google_maps_flutter_platform_interface: dependency: transitive description: name: google_maps_flutter_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.2.0" http: dependency: transitive description: @@ -239,19 +232,26 @@ packages: source: hosted version: "2.1.19" intl: - dependency: transitive + dependency: "direct overridden" description: name: intl url: "https://pub.dartlang.org" source: hosted - version: "0.16.1" + version: "0.17.0-nullsafety.2" + js: + dependency: transitive + description: + name: js + url: "https://pub.dartlang.org" + source: hosted + version: "0.6.3-nullsafety.3" json_annotation: dependency: transitive description: name: json_annotation url: "https://pub.dartlang.org" source: hosted - version: "3.0.1" + version: "3.1.1" logging: dependency: transitive description: @@ -265,28 +265,28 @@ packages: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.10-nullsafety.1" + version: "0.12.10-nullsafety.3" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.3" + version: "1.3.0-nullsafety.6" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.0-nullsafety.1" + version: "1.8.0-nullsafety.3" pedantic: dependency: transitive description: name: pedantic url: "https://pub.dartlang.org" source: hosted - version: "1.9.2" + version: "1.10.0" petitparser: dependency: transitive description: @@ -307,7 +307,7 @@ packages: name: pointycastle url: "https://pub.dartlang.org" source: hosted - version: "1.0.2" + version: "2.0.1" random_string: dependency: transitive description: @@ -340,21 +340,21 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.0-nullsafety.2" + version: "1.8.0-nullsafety.4" stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.10.0-nullsafety.1" + version: "1.10.0-nullsafety.6" stream_channel: dependency: transitive description: name: stream_channel url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.1" + version: "2.1.0-nullsafety.3" stream_transform: dependency: transitive description: @@ -368,28 +368,28 @@ packages: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.1" + version: "1.1.0-nullsafety.3" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.1" + version: "1.2.0-nullsafety.3" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.19-nullsafety.2" + version: "0.2.19-nullsafety.6" typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.3" + version: "1.3.0-nullsafety.5" validators: dependency: transitive description: @@ -403,7 +403,7 @@ packages: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.3" + version: "2.1.0-nullsafety.5" vin_decoder: dependency: transitive description: @@ -419,5 +419,5 @@ packages: source: hosted version: "4.5.1" sdks: - dart: ">=2.10.0 <2.11.0" - flutter: ">=1.22.0 <2.0.0" + dart: ">=2.12.0-0.0 <3.0.0" + flutter: ">=1.22.0" diff --git a/pubspec.yaml b/pubspec.yaml index 57c2705..471da98 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -4,16 +4,19 @@ version: 1.0.0-alpha.1 homepage: https://github.com/danvick/form_builder_map_field environment: - sdk: ">=2.10.0 <3.0.0" + sdk: ">=2.12.0-0 <3.0.0" dependencies: flutter: sdk: flutter flutter_form_builder: ^4.2.0 - google_maps_flutter: ^1.1.1 + google_maps_flutter: ^1.2.0 dev_dependencies: flutter_test: sdk: flutter +dependency_overrides: + intl: 0.17.0-nullsafety.2 + flutter: From 4d74e97680f20b9b2ba6c8c5abe6ee24cbe1673a Mon Sep 17 00:00:00 2001 From: Martin Edlman Date: Fri, 12 Feb 2021 23:05:39 +0100 Subject: [PATCH 4/4] Upgrade pkgs deps Signed-off-by: Martin Edlman --- example/pubspec.lock | 40 ++++++++++++++++++++-------------------- example/pubspec.yaml | 3 ++- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/example/pubspec.lock b/example/pubspec.lock index 635f0a2..4e7c3c3 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -21,7 +21,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.5.0-nullsafety.3" + version: "2.5.0" basic_utils: dependency: transitive description: @@ -35,35 +35,35 @@ packages: name: boolean_selector url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.3" + version: "2.1.0" characters: dependency: transitive description: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.5" + version: "1.1.0" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.3" + version: "1.2.0" clock: dependency: transitive description: name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.3" + version: "1.1.0" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.15.0-nullsafety.5" + version: "1.15.0" convert: dependency: transitive description: @@ -105,7 +105,7 @@ packages: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.3" + version: "1.2.0" flutter: dependency: "direct main" description: flutter @@ -244,14 +244,14 @@ packages: name: intl url: "https://pub.dartlang.org" source: hosted - version: "0.17.0-nullsafety.2" + version: "0.17.0" js: dependency: transitive description: name: js url: "https://pub.dartlang.org" source: hosted - version: "0.6.3-nullsafety.3" + version: "0.6.3" json_annotation: dependency: transitive description: @@ -272,21 +272,21 @@ packages: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.10-nullsafety.3" + version: "0.12.10" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.6" + version: "1.3.0" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.0-nullsafety.3" + version: "1.8.0" pedantic: dependency: transitive description: @@ -347,21 +347,21 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.0-nullsafety.4" + version: "1.8.0" stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.10.0-nullsafety.6" + version: "1.10.0" stream_channel: dependency: transitive description: name: stream_channel url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.3" + version: "2.1.0" stream_transform: dependency: transitive description: @@ -375,28 +375,28 @@ packages: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.3" + version: "1.1.0" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.3" + version: "1.2.0" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.19-nullsafety.6" + version: "0.2.19" typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.5" + version: "1.3.0" validators: dependency: transitive description: @@ -410,7 +410,7 @@ packages: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.5" + version: "2.1.0" vin_decoder: dependency: transitive description: diff --git a/example/pubspec.yaml b/example/pubspec.yaml index ec0d0c7..d328209 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -2,6 +2,7 @@ name: example description: Example app for form_builder_map_field package homepage: https://github.com/danvick/form_builder_map_field/tree/master/example version: 1.0.0+1 +publish_to: 'none' environment: sdk: ">=2.12.0-0 <3.0.0" @@ -19,7 +20,7 @@ dev_dependencies: sdk: flutter dependency_overrides: - intl: 0.17.0-nullsafety.2 + intl: ^0.17.0 flutter: uses-material-design: true