Skip to content

Commit 6415c67

Browse files
committed
Added support for flutter_form_builder version 4.*
1 parent f963a15 commit 6415c67

10 files changed

+70
-145
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@
2929
.pub-cache/
3030
.pub/
3131
build/
32+
coverage/
33+
lib/generated_plugin_registrant.dart
34+
# For library packages, don’t commit the pubspec.lock file.
35+
# Regenerating the pubspec.lock file lets you test your package against the latest compatible versions of its dependencies.
36+
# See https://dart.dev/guides/libraries/private-files#pubspeclock
37+
pubspec.lock
3238

3339
# Android related
3440
**/android/**/gradle-wrapper.jar

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## [1.0.0] - 29-Dec-2020.
2+
* Added support for flutter_form_builder 4.*
3+
14
## [0.3.0] - 09-Aug-2020.
25
* Bump dependency `file_picker` plugin. Include additional `file_picker` options
36
* Included MIT License. Closes #3

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# form_builder_file_picker
22

3-
File Picker Field for [FlutterFormBuilder package](https://pub.dev/packages/flutter_form_builder)
3+
File Picker Field for [flutter_form_builder](https://pub.dev/packages/flutter_form_builder) package
44

55
# Setup
66

example/.flutter-plugins-dependencies

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"file_picker","path":"/Users/danvick/flutter/.pub-cache/hosted/pub.dartlang.org/file_picker-2.1.4/","dependencies":[]},{"name":"flutter_keyboard_visibility","path":"/Users/danvick/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_keyboard_visibility-4.0.2/","dependencies":[]},{"name":"image_picker","path":"/Users/danvick/flutter/.pub-cache/hosted/pub.dartlang.org/image_picker-0.6.7+17/","dependencies":[]},{"name":"permission_handler","path":"/Users/danvick/flutter/.pub-cache/hosted/pub.dartlang.org/permission_handler-5.0.1+1/","dependencies":[]},{"name":"phone_number","path":"/Users/danvick/flutter/.pub-cache/hosted/pub.dartlang.org/phone_number-0.8.1/","dependencies":[]}],"android":[{"name":"file_picker","path":"/Users/danvick/flutter/.pub-cache/hosted/pub.dartlang.org/file_picker-2.1.4/","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"flutter_keyboard_visibility","path":"/Users/danvick/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_keyboard_visibility-4.0.2/","dependencies":[]},{"name":"flutter_plugin_android_lifecycle","path":"/Users/danvick/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_plugin_android_lifecycle-1.0.6/","dependencies":[]},{"name":"image_picker","path":"/Users/danvick/flutter/.pub-cache/hosted/pub.dartlang.org/image_picker-0.6.7+17/","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"permission_handler","path":"/Users/danvick/flutter/.pub-cache/hosted/pub.dartlang.org/permission_handler-5.0.1+1/","dependencies":[]},{"name":"phone_number","path":"/Users/danvick/flutter/.pub-cache/hosted/pub.dartlang.org/phone_number-0.8.1/","dependencies":[]}],"macos":[],"linux":[],"windows":[],"web":[{"name":"file_picker","path":"/Users/danvick/flutter/.pub-cache/hosted/pub.dartlang.org/file_picker-2.1.4/","dependencies":[]},{"name":"flutter_keyboard_visibility_web","path":"/Users/danvick/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_keyboard_visibility_web-1.0.1/","dependencies":[]},{"name":"image_picker_for_web","path":"/Users/danvick/flutter/.pub-cache/hosted/pub.dartlang.org/image_picker_for_web-0.1.0+2/","dependencies":[]}]},"dependencyGraph":[{"name":"file_picker","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"flutter_keyboard_visibility","dependencies":["flutter_keyboard_visibility_web"]},{"name":"flutter_keyboard_visibility_web","dependencies":[]},{"name":"flutter_plugin_android_lifecycle","dependencies":[]},{"name":"image_picker","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"image_picker_for_web","dependencies":[]},{"name":"permission_handler","dependencies":[]},{"name":"phone_number","dependencies":[]}],"date_created":"2020-12-28 21:15:44.666605","version":"1.22.4"}
1+
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"file_picker","path":"/Users/danvick/flutter/.pub-cache/hosted/pub.dartlang.org/file_picker-2.1.4/","dependencies":[]},{"name":"flutter_keyboard_visibility","path":"/Users/danvick/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_keyboard_visibility-4.0.2/","dependencies":[]},{"name":"permission_handler","path":"/Users/danvick/flutter/.pub-cache/hosted/pub.dartlang.org/permission_handler-5.0.1+1/","dependencies":[]}],"android":[{"name":"file_picker","path":"/Users/danvick/flutter/.pub-cache/hosted/pub.dartlang.org/file_picker-2.1.4/","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"flutter_keyboard_visibility","path":"/Users/danvick/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_keyboard_visibility-4.0.2/","dependencies":[]},{"name":"flutter_plugin_android_lifecycle","path":"/Users/danvick/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_plugin_android_lifecycle-1.0.6/","dependencies":[]},{"name":"permission_handler","path":"/Users/danvick/flutter/.pub-cache/hosted/pub.dartlang.org/permission_handler-5.0.1+1/","dependencies":[]}],"macos":[],"linux":[],"windows":[],"web":[{"name":"file_picker","path":"/Users/danvick/flutter/.pub-cache/hosted/pub.dartlang.org/file_picker-2.1.4/","dependencies":[]},{"name":"flutter_keyboard_visibility_web","path":"/Users/danvick/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_keyboard_visibility_web-1.0.1/","dependencies":[]}]},"dependencyGraph":[{"name":"file_picker","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"flutter_keyboard_visibility","dependencies":["flutter_keyboard_visibility_web"]},{"name":"flutter_keyboard_visibility_web","dependencies":[]},{"name":"flutter_plugin_android_lifecycle","dependencies":[]},{"name":"permission_handler","dependencies":[]}],"date_created":"2020-12-29 23:25:41.907426","version":"1.22.4"}

example/pubspec.lock

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,6 @@ packages:
8585
url: "https://pub.dartlang.org"
8686
source: hosted
8787
version: "2.1.1"
88-
country_pickers:
89-
dependency: transitive
90-
description:
91-
name: country_pickers
92-
url: "https://pub.dartlang.org"
93-
source: hosted
94-
version: "1.3.0"
9588
crypto:
9689
dependency: transitive
9790
description:
@@ -173,7 +166,7 @@ packages:
173166
name: flutter_form_builder
174167
url: "https://pub.dartlang.org"
175168
source: hosted
176-
version: "4.1.0"
169+
version: "4.2.0"
177170
flutter_keyboard_visibility:
178171
dependency: transitive
179172
description:
@@ -259,41 +252,13 @@ packages:
259252
url: "https://pub.dartlang.org"
260253
source: hosted
261254
version: "2.1.14"
262-
image_picker:
263-
dependency: transitive
264-
description:
265-
name: image_picker
266-
url: "https://pub.dartlang.org"
267-
source: hosted
268-
version: "0.6.7+17"
269-
image_picker_for_web:
270-
dependency: transitive
271-
description:
272-
name: image_picker_for_web
273-
url: "https://pub.dartlang.org"
274-
source: hosted
275-
version: "0.1.0+2"
276-
image_picker_platform_interface:
277-
dependency: transitive
278-
description:
279-
name: image_picker_platform_interface
280-
url: "https://pub.dartlang.org"
281-
source: hosted
282-
version: "1.1.0"
283255
intl:
284256
dependency: transitive
285257
description:
286258
name: intl
287259
url: "https://pub.dartlang.org"
288260
source: hosted
289261
version: "0.16.1"
290-
js:
291-
dependency: transitive
292-
description:
293-
name: js
294-
url: "https://pub.dartlang.org"
295-
source: hosted
296-
version: "0.6.2"
297262
json_annotation:
298263
dependency: transitive
299264
description:
@@ -357,13 +322,6 @@ packages:
357322
url: "https://pub.dartlang.org"
358323
source: hosted
359324
version: "3.0.4"
360-
phone_number:
361-
dependency: transitive
362-
description:
363-
name: phone_number
364-
url: "https://pub.dartlang.org"
365-
source: hosted
366-
version: "0.8.1"
367325
plugin_platform_interface:
368326
dependency: transitive
369327
description:

lib/form_builder_file_picker.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
export 'src/form_builder_form_picker.dart';
1+
library form_builder_file_picker;
2+
3+
export 'src/form_builder_file_picker.dart';
24
export 'package:file_picker/file_picker.dart';

lib/src/form_builder_form_picker.dart renamed to lib/src/form_builder_file_picker.dart

Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -72,47 +72,47 @@ class FormBuilderFilePicker extends FormBuilderField<List<PlatformFile>> {
7272
this.onFileLoading,
7373
this.allowCompression,
7474
}) : super(
75-
key: key,
76-
initialValue: initialValue,
77-
name: name,
78-
validator: validator,
79-
valueTransformer: valueTransformer,
80-
onChanged: onChanged,
81-
autovalidateMode: autovalidateMode,
82-
onSaved: onSaved,
83-
enabled: enabled,
84-
onReset: onReset,
85-
decoration: decoration,
86-
focusNode: focusNode,
87-
builder: (FormFieldState<List<PlatformFile>> field) {
88-
final state = field as _FormBuilderFilePickerState;
75+
key: key,
76+
initialValue: initialValue,
77+
name: name,
78+
validator: validator,
79+
valueTransformer: valueTransformer,
80+
onChanged: onChanged,
81+
autovalidateMode: autovalidateMode,
82+
onSaved: onSaved,
83+
enabled: enabled,
84+
onReset: onReset,
85+
decoration: decoration,
86+
focusNode: focusNode,
87+
builder: (FormFieldState<List<PlatformFile>> field) {
88+
final state = field as _FormBuilderFilePickerState;
8989

90-
return InputDecorator(
91-
decoration: state.decoration(),
92-
child: Column(
93-
children: <Widget>[
94-
Row(
95-
mainAxisAlignment: MainAxisAlignment.spaceBetween,
96-
children: <Widget>[
97-
if (maxFiles != null)
98-
Text('${state._files.length} / $maxFiles'),
99-
InkWell(
100-
child: selector,
101-
onTap: state.enabled &&
102-
(null == state._remainingItemCount ||
103-
state._remainingItemCount > 0)
104-
? () => state.pickFiles(field)
105-
: null,
106-
),
107-
],
108-
),
109-
const SizedBox(height: 3),
110-
state.defaultFileViewer(state._files, field),
111-
],
112-
),
113-
);
114-
},
115-
);
90+
return InputDecorator(
91+
decoration: state.decoration(),
92+
child: Column(
93+
children: <Widget>[
94+
Row(
95+
mainAxisAlignment: MainAxisAlignment.spaceBetween,
96+
children: <Widget>[
97+
if (maxFiles != null)
98+
Text('${state._files.length} / $maxFiles'),
99+
InkWell(
100+
child: selector,
101+
onTap: state.enabled &&
102+
(null == state._remainingItemCount ||
103+
state._remainingItemCount > 0)
104+
? () => state.pickFiles(field)
105+
: null,
106+
),
107+
],
108+
),
109+
const SizedBox(height: 3),
110+
state.defaultFileViewer(state._files, field),
111+
],
112+
),
113+
);
114+
},
115+
);
116116

117117
@override
118118
_FormBuilderFilePickerState createState() => _FormBuilderFilePickerState();
@@ -209,7 +209,7 @@ class _FormBuilderFilePickerState
209209
spacing: 10,
210210
children: List.generate(
211211
files.length,
212-
(index) {
212+
(index) {
213213
return Container(
214214
height: itemSize,
215215
width: itemSize,
@@ -220,19 +220,19 @@ class _FormBuilderFilePickerState
220220
Container(
221221
alignment: Alignment.center,
222222
child: (imageFileExts.contains(
223-
files[index].extension.toLowerCase()) &&
224-
widget.previewImages)
223+
files[index].extension.toLowerCase()) &&
224+
widget.previewImages)
225225
? Image.file(File(files[index].path),
226-
fit: BoxFit.cover)
226+
fit: BoxFit.cover)
227227
: Container(
228-
alignment: Alignment.center,
229-
child: Icon(
230-
getIconData(files[index].extension),
231-
color: Colors.white,
232-
size: 56,
233-
),
234-
color: theme.primaryColor,
235-
),
228+
alignment: Alignment.center,
229+
child: Icon(
230+
getIconData(files[index].extension),
231+
color: Colors.white,
232+
size: 56,
233+
),
234+
color: theme.primaryColor,
235+
),
236236
),
237237
Container(
238238
padding: const EdgeInsets.symmetric(horizontal: 2),

pubspec.lock

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,6 @@ packages:
8585
url: "https://pub.dartlang.org"
8686
source: hosted
8787
version: "2.1.1"
88-
country_pickers:
89-
dependency: transitive
90-
description:
91-
name: country_pickers
92-
url: "https://pub.dartlang.org"
93-
source: hosted
94-
version: "1.3.0"
9588
crypto:
9689
dependency: transitive
9790
description:
@@ -173,7 +166,7 @@ packages:
173166
name: flutter_form_builder
174167
url: "https://pub.dartlang.org"
175168
source: hosted
176-
version: "4.1.0"
169+
version: "4.2.0"
177170
flutter_keyboard_visibility:
178171
dependency: transitive
179172
description:
@@ -252,41 +245,13 @@ packages:
252245
url: "https://pub.dartlang.org"
253246
source: hosted
254247
version: "2.1.14"
255-
image_picker:
256-
dependency: transitive
257-
description:
258-
name: image_picker
259-
url: "https://pub.dartlang.org"
260-
source: hosted
261-
version: "0.6.7+17"
262-
image_picker_for_web:
263-
dependency: transitive
264-
description:
265-
name: image_picker_for_web
266-
url: "https://pub.dartlang.org"
267-
source: hosted
268-
version: "0.1.0+2"
269-
image_picker_platform_interface:
270-
dependency: transitive
271-
description:
272-
name: image_picker_platform_interface
273-
url: "https://pub.dartlang.org"
274-
source: hosted
275-
version: "1.1.0"
276248
intl:
277249
dependency: transitive
278250
description:
279251
name: intl
280252
url: "https://pub.dartlang.org"
281253
source: hosted
282254
version: "0.16.1"
283-
js:
284-
dependency: transitive
285-
description:
286-
name: js
287-
url: "https://pub.dartlang.org"
288-
source: hosted
289-
version: "0.6.2"
290255
json_annotation:
291256
dependency: transitive
292257
description:
@@ -350,13 +315,6 @@ packages:
350315
url: "https://pub.dartlang.org"
351316
source: hosted
352317
version: "3.0.4"
353-
phone_number:
354-
dependency: transitive
355-
description:
356-
name: phone_number
357-
url: "https://pub.dartlang.org"
358-
source: hosted
359-
version: "0.8.1"
360318
plugin_platform_interface:
361319
dependency: transitive
362320
description:

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: form_builder_file_picker
22
description: FilePicker Field for flutter_form_builder package. Used to select files as part of form input.
3-
version: 0.3.0
3+
version: 1.0.0
44
homepage: https://github.com/danvick/form_builder_file_picker
55

66
environment:
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
// import 'package:flutter_test/flutter_test.dart';
22

3-
void main() {
4-
5-
}
3+
void main() {}

0 commit comments

Comments
 (0)