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

[Field name or Undefined name 'FormBuilderValidators'. Try correcting the name to one that is defined, or defining the name.General]: <title> #1280

Closed
3 of 7 tasks
Papatee04 opened this issue Aug 8, 2023 · 5 comments · Fixed by #1377
Labels
awaiting author response Waiting for author of issue to respond with more info bug Something isn't working Stale

Comments

@Papatee04
Copy link

Papatee04 commented Aug 8, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Package/Plugin version

9.0.0

Platforms

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

Flutter doctor

Flutter doctor
[√] Flutter (Channel stable, 3.10.6, on Microsoft Windows [Version 10.0.22000.2176], locale en-ZA)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[!] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    X cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.
    X Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/windows#android-setup for more details.
[X] Chrome - develop for the web (Cannot find Chrome executable at .\Google\Chrome\Application\chrome.exe)
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[X] Visual Studio - develop for Windows
    X Visual Studio not installed; this is necessary for Windows development.
      Download at https://visualstudio.microsoft.com/downloads/.
      Please install the "Desktop development with C++" workload, including all of its default components
[√] Android Studio (version 2022.2)
[√] VS Code (version 1.81.0)
[√] Connected device (3 available)
[√] Network resources

! Doctor found issues in 3 categories.

Minimal code example

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

class MakeListingPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Make a Listing"),
        backgroundColor: Color(0xFF00944D),
      ),
      body: Padding(
        padding: const EdgeInsets.all(16.0),
        child: ListView(
          children: [
            FormBuilder(
              child: Column(
                children: [
                  FormBuilderTextField(
                    name: 'carModel',
                    decoration: InputDecoration(labelText: 'Car Model'),
                    validator: FormBuilderValidators.required(context),
                  ),
                  FormBuilderTextField(
                    name: 'country',
                    decoration: InputDecoration(labelText: 'Country'),
                    validator: FormBuilderValidators.required(context),
                  ),
                  FormBuilderTextField(
                    name: 'price',
                    decoration: InputDecoration(labelText: 'Price'),
                    keyboardType: TextInputType.number,
                    validator: FormBuilderValidators.compose([
                      FormBuilderValidators.required(context),
                      FormBuilderValidators.numeric(context),
                    ]),
                  ),
                  // Add more form fields as needed
                  SizedBox(height: 20),
                  ElevatedButton(
                    onPressed: () {
                      if (FormBuilder.of(context).validate()) {
                        // Perform the listing submission logic here
                        // Access form values using FormBuilder.of(context).value
                      }
                    },
                    child: Text('Submit Listing'),
                    style: ElevatedButton.styleFrom(
                      primary: Color(0xFF00944D),
                      textStyle: TextStyle(color: Colors.white),
                    ),
                  ),
                ],
              ),
            ),
          ],
        ),
      ),
    );
  }
}

Current Behavior

i have installed the dependency and imported the package, but tyhe method isn't recognized

Expected Behavior

the method should work since i have imported the package

Steps To Reproduce

run flutter pub add flutter_form_builder
import 'package:flutter_form_builder/flutter_form_builder.dart';
use the the method

Aditional information

No response

@Papatee04 Papatee04 added the bug Something isn't working label Aug 8, 2023
@ustych
Copy link

ustych commented Aug 10, 2023

@Papatee04 Hey. The validators related logic is in a separate repo. Add the form_builder_validators: ^9.0.0 to the pubspec.yaml.

For more context: https://pub.dev/packages/form_builder_validators

@deandreamatias
Copy link
Collaborator

What method do you try use? ´FormBuilder.of(context).validate()´?
You need use key on FormBuilder to validate the form. Take a look on readme examples

@deandreamatias deandreamatias added the awaiting author response Waiting for author of issue to respond with more info label Aug 10, 2023
@iqfareez
Copy link

@Papatee04 Hey. The validators related logic is in a separate repo. Add the form_builder_validators: ^9.0.0 to the pubspec.yaml.

For more context: https://pub.dev/packages/form_builder_validators

This instruction should be added in the package readme, or endorsed together with this package.

@github-actions
Copy link

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@github-actions github-actions bot added the Stale label Sep 16, 2023
@github-actions
Copy link

This issue was closed because it has been stalled for 7 days with no activity.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Sep 23, 2023
mgalgs added a commit to mgalgs/flutter_form_builder that referenced this issue Mar 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting author response Waiting for author of issue to respond with more info bug Something isn't working Stale
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants