flutter-form-builder-ecosystem / flutter-form-builder-ecosystem/form_builder_file_picker

General: Creating Multiple Duplicate Fields

Open
#66 3 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
C++
Stars
17
Forks
37
PR merge metrics
No merged PRs in 30d

Description

### Is there an existing issue for this?

- [X] I have searched the existing issues

### Package/Plugin version

4.0.0

### Platforms

- [X] Android
- [X] iOS
- [ ] Linux
- [ ] MacOS
- [ ] Web
- [ ] Windows

### Flutter doctor

Flutter doctor

```bash
[✓] Flutter (Channel stable, 3.10.5, on macOS 13.4 22F66 darwin-arm64, locale en-IN)
• Flutter version 3.10.5 on channel stable at /Users/bijoy/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 796c8ef792 (4 weeks ago), 2023-06-13 15:51:02 -0700
• Engine revision 45f6e00911
• Dart version 3.0.5
• DevTools version 2.23.1

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
• Android SDK at /Users/bijoy/Library/Android/sdk
• Platform android-33, build-tools 33.0.0
• Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
• All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.3.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 14E300c
• CocoaPods version 1.11.3

[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.2)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)

[✓] VS Code (version 1.79.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.68.0

[✓] Connected device (4 available)
• SM G990E (mobile) • RZCW118D1XK • android-arm64 • Android 13 (API 33)
• iPhone 14 Pro Max (mobile) • FE3A0644-69E3-4FE0-AA3B-A62AEA82C982 • ios •
com.apple.CoreSimulator.SimRuntime.iOS-16-4 (simulator)
• macOS (desktop) • macos • darwin-arm64 • macOS 13.4 22F66 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 114.0.5735.198

[✓] Network resources
• All expected network resources are available.

• No issues found!
```

### Minimal code example

Code sample

```dart
import 'package:flutter/material.dart';
import 'package:flutter_form_builder/flutter_form_builder.dart';

void main() {
runApp(const MyApp());
}

class MyApp extends StatelessWidget {
const MyApp({super.key});

@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: const MyHomePage(),
);
}
}

class MyHomePage extends StatefulWidget {
const MyHomePage({super.key});

@override
State createState() => _MyHomePageState();
}

class _MyHomePageState extends State {
final _formKey = GlobalKey();

@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Column(
children: [
FormBuilderFilePicker(
name: "doc",
maxFiles: 2,
previewImages: true,
onChanged: (val) => print(val),
decoration: const InputDecoration(
border: InputBorder.none,
),
typeSelectors: const [
TypeSelector(
type: FileType.media,
selector: Row(
children: [
Icon(
Icons.add_circle,
color: Colors.white,
),
Padding(
padding: EdgeInsets.only(left: 8.0),
child: Text(
"Add Passport Copy",
style: TextStyle(
color: Colors.white,
),
),
),
],
),
),
],
validator: FormBuilderValidators.compose([
FormBuilderValidators.required(),
]),
onFileLoading: (val) {
print(val);
},
),
],
),
),
);
}
}
```

### Current Behavior

Automatically creating multiple duplicate fields

![Screenshot_20230710_111700](https://github.com/flutter-form-builder-ecosystem/form_builder_file_picker/assets/20392649/12063537-ef29-4327-90e0-4ad056bfa5c9)

### Expected Behavior

Not create duplicate fields

### Steps To Reproduce

Just add file picker field in a formbuilder

### Aditional information

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.