Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

General: Creating Multiple Duplicate Fields #66

Open
3 of 7 tasks
holy-dev opened this issue Jul 10, 2023 · 3 comments
Open
3 of 7 tasks

General: Creating Multiple Duplicate Fields #66

holy-dev opened this issue Jul 10, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@holy-dev
Copy link

holy-dev commented Jul 10, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Package/Plugin version

4.0.0

Platforms

  • Android
  • iOS
  • Linux
  • MacOS
  • Web
  • Windows

Flutter doctor

Flutter doctor
[✓] 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
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<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  final _formKey = GlobalKey<FormBuilderState>();

  @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: <Widget>[
                      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

Expected Behavior

Not create duplicate fields

Steps To Reproduce

Just add file picker field in a formbuilder

Aditional information

No response

@holy-dev holy-dev added the bug Something isn't working label Jul 10, 2023
@deandreamatias
Copy link
Contributor

Hi!
Where is the file picker field in example code? Please add a complete example code

@holy-dev
Copy link
Author

holy-dev commented Jul 10, 2023

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<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  final _formKey = GlobalKey<FormBuilderState>();

  @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: <Widget>[
                      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);
              },
            ),
          ],
        ),
      ),
    );
  }
}

@holy-dev
Copy link
Author

@deandreamatias Please check I've updated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants