Giter Club home page Giter Club logo

Comments (12)

jasonlaw avatar jasonlaw commented on May 12, 2024

To add more info, I found that the form is always redraw when a input is getting focus.

These printed whenever I try to focus on the input textbox.
2019-03-26_084404

from flutter_form_builder.

jasonlaw avatar jasonlaw commented on May 12, 2024

I have made a small changed in the code and it seems working, however, the behavior is still somewhat strange due to the formKey keep changing.

2019-03-26_092215

from flutter_form_builder.

danvick avatar danvick commented on May 12, 2024

Hey @jasonlaw,

Thanks for the help, you're the best.

Seems like I accidentally merged another branch which I was doing some experimental stuff on.

from flutter_form_builder.

danvick avatar danvick commented on May 12, 2024

@jasonlaw To avoid key changing, don't declare the global key inside your build method.

from flutter_form_builder.

jasonlaw avatar jasonlaw commented on May 12, 2024

@danvick, thanks for the quick response. Indeed after moving out from the build method, it works normally now, you are awesome! :)

from flutter_form_builder.

benoitverstraete avatar benoitverstraete commented on May 12, 2024

Hi,

I have the same behavior even if I move the global key in the class. I upgraded the package to the latest version (flutter_form_builder: ^2.0.3). It is impossible to enter a value in the fields.

Here is a sample of my code :

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

class ActivityPage extends StatelessWidget {
  final GlobalKey<FormBuilderState> _fbKey = GlobalKey();

  var data;

  final allCountries = [
    "Afghanistan",
    "Albania",
    "Algeria",
    "American Samoa",
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('New activity'),
      ),
      body: SingleChildScrollView(
        child: FormBuilder(context, key: _fbKey, controls: [
          FormBuilderInput.typeAhead(
            decoration: InputDecoration(labelText: "Country"),
            attribute: 'country',
            // require: true,
            itemBuilder: (context, country) {
              return ListTile(
                title: Text(country),
              );
            },
            suggestionsCallback: (query) {
              if (query.length != 0) {
                var lowercaseQuery = query.toLowerCase();
                return allCountries.where((country) {
                  return country.toLowerCase().contains(lowercaseQuery);
                }).toList(growable: false)
                  ..sort((a, b) => a.toLowerCase().indexOf(lowercaseQuery).compareTo(b.toLowerCase().indexOf(lowercaseQuery)));
              } else {
                return allCountries;
              }
            },
          ),
          FormBuilderInput.textField(
            type: FormBuilderInput.TYPE_TEXT,
            attribute: "name",
            decoration: InputDecoration(labelText: "Full Name"),
            value: "John Doe",
          ),
        ]),
      ),
    );
  }
}

Could you please help me with this ?

Thanks a lot !

from flutter_form_builder.

danvick avatar danvick commented on May 12, 2024

Hi @benoitverstraete,
I've been unable to reproduce your error. Could you kindly share your version of flutter or the result of your flutter doctor

from flutter_form_builder.

danvick avatar danvick commented on May 12, 2024

You could also try converting your widget to a StatefulWidget especially if you want to make use of the data variable to get the result of your form

from flutter_form_builder.

benoitverstraete avatar benoitverstraete commented on May 12, 2024

Yes, sure :

C:\src\flutter\bin\flutter.bat doctor --verbose
[√] Flutter (Channel stable, v1.2.1, on Microsoft Windows [Version 10.0.17763.379], locale en-GB)
    • Flutter version 1.2.1 at C:\src\flutter
    • Framework revision 8661d8aecd (7 weeks ago), 2019-02-14 19:19:53 -0800
    • Engine revision 3757390fa4
    • Dart version 2.1.2 (build 2.1.2-dev.0.0 0a7dcf17eb)

[√] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    • Android SDK at C:\Users\bve\AppData\Local\Android\sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-28, build-tools 28.0.3
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)
    • All Android licenses accepted.

[√] Android Studio (version 3.3)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin version 34.0.1
    • Dart plugin version 182.5215
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)

[!] VS Code (version 1.32.3)
    • VS Code at C:\Users\bve\AppData\Local\Programs\Microsoft VS Code
    X Flutter extension not installed; install from
      https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[√] Connected device (2 available)
    • Android SDK built for x86 • emulator-5554 • android-x86 • Android 9 (API 28) (emulator)
    • Android SDK built for x86 • emulator-5556 • android-x86 • Android 9 (API 28) (emulator)

! Doctor found issues in 1 category.

from flutter_form_builder.

benoitverstraete avatar benoitverstraete commented on May 12, 2024

@danvick this bug disappear when I convert the StatelessWidget to a Stateful one, thanks !lba

But, I keep getting the error from the issue #33 for the typeAhead control...

from flutter_form_builder.

danvick avatar danvick commented on May 12, 2024

@benoitverstraete I'm quite sorry for the inconveniences. The package, as I later realized has quite a number of issues with state management. That's why I've taken to do complete rewrite coming out as version 3.0.0, in fact I've released a beta version of it just a few hours ago.

Feel free to test it out. I doubt if there will be major API changes before it's release

from flutter_form_builder.

benoitverstraete avatar benoitverstraete commented on May 12, 2024

@danvick Ok, I will take a look at the new version and will open another issue if I encounter some issues.

from flutter_form_builder.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.