error with maxImage when set value more than 1 [only IOS]
YouSour opened this issue ยท 5 comments
hi , i got a problem with this package only on IOS when i set maxImages value more than 1 when i choose a image and then i got an error output like this :
Unhandled Exception: type 'String' is not a subtype of type 'List<dynamic>?' in type cast
any idea , pls share , thank in advance
Hi @YouSour!
Do you have a minimal code example of this?
Thanks!
@deandreamatias here
flutter_form_builder: ^7.1.1
form_builder_image_picker: ^2.0.0
import 'package:flutter_form_builder/flutter_form_builder.dart';
...
final _formKey = GlobalKey<FormBuilderState>();
...
@override
Widget build(BuildContext context) {
return Column(
children: <Widget>[
FormBuilder(
key: _formKey,
autovalidateMode: AutovalidateMode.disabled,
child: Column(
children: <Widget>[
FormBuilderImagePicker(
name: 'images',
decoration: CustomDecoration.formFieldDecoration(
label: 'Pick Photos'),
displayCustomType: (obj) =>
obj is ProductImageModel ? obj.filePath : obj,
valueTransformer: (List<dynamic>? images) {
return images?.map((image) {
return image is ProductImageModel
? ProductImageModel(
fileName: image.fileName,
filePathFromDevice:
image.filePathFromDevice,
filePath: image.filePath)
.toJson()
: ProductImageModel(
fileName: XFileImage(file: image).file.name,
filePathFromDevice:
XFileImage(file: image).file.path,
).toJson();
}).toList();
},
maxImages: 2,
),
],
),
),
Row(
children: <Widget>[
Expanded(
child: MaterialButton(
color: Theme.of(context).colorScheme.secondary,
child: const Text(
"Submit",
style: TextStyle(color: Colors.white),
),
onPressed: () {
_formKey.currentState!.save();
if (_formKey.currentState!.validate()) {
print(_formKey.currentState!.value);
} else {
print("validation failed");
}
},
),
),
const SizedBox(width: 20),
Expanded(
child: MaterialButton(
color: Theme.of(context).colorScheme.secondary,
child: const Text(
"Reset",
style: TextStyle(color: Colors.white),
),
onPressed: () {
_formKey.currentState!.reset();
},
),
),
],
)
],
);
}
Thanks for sample code.
I'm working now in a update to Flutter 3 with PR #28
When I has time, I take a look to this bug.
Meanwhile, if other person or you want try fix this bug, I will apreciate
@deandreamatias ok, i appreciate that ๐
I could not reproduce this on a Simulator device with version 4.0.1 of this package.