Coder Social home page Coder Social logo

flutter-form-builder-ecosystem / form_builder_phone_field Goto Github PK

View Code? Open in Web Editor NEW
10.0 10.0 12.0 209 KB

International phone number field for FlutterFormBuilder package

Home Page: https://pub.dev/packages/form_builder_phone_field

License: BSD 3-Clause "New" or "Revised" License

Kotlin 0.42% Swift 1.32% Objective-C 0.12% Dart 80.57% HTML 12.78% Ruby 4.78%
dart flutter form package phone

form_builder_phone_field's People

Contributors

deandreamatias avatar dependabot[bot] avatar wheeos avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

form_builder_phone_field's Issues

[form_builder_phone_field]: Wrong flag of Martinique

Is there an existing issue for this?

  • I have searched the existing issues

Package/Plugin version

1.3

Platforms

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

Flutter doctor

[✓] Flutter (Channel stable, 3.7.12, on macOS 13.4.1 22F770820d darwin-x64, locale fr-FR)
    • Flutter version 3.7.12 on channel stable at /Users/paul.trinko/dev/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 4d9e56e694 (4 months ago), 2023-04-17 21:47:46 -0400
    • Engine revision 1a65d409c7
    • Dart version 2.19.6
    • DevTools version 2.20.1

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
    • Android SDK at /Users/paul.trinko/Library/Android/sdk
    • Platform android-33, build-tools 33.0.2
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)
    • 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.12.1

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

[✓] Android Studio (version 2022.3)
    • 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 17.0.6+0-17.0.6b829.9-10027231)

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

[✓] Connected device (3 available)
    • Pixel 6 Pro (mobile) • 18261FDEE0015A • android-arm64  • Android 14 (API 34)
    • macOS (desktop)      • macos          • darwin-x64     • macOS 13.4.1 22F770820d darwin-x64
    • Chrome (web)         • chrome         • web-javascript • Google Chrome 115.0.5790.170

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!

Minimal code example

List<String> countryIsoList = const [
  'FR',
  'BE',
  'CH',
  'DE',
  'ES',
  'IT',
  'MA',
  'LU',
  'AD',
  'MC',
  'AT',
  'PT',
  'NL',
  'MQ', // Martinique
];

Current Behavior

The package uses a flag that is not a correct flag of Martinique

More to read here : https://en.wikipedia.org/wiki/Flag_of_Martinique

Expected Behavior

The official flag is Red-Green-Black

Steps To Reproduce

Using countryFilterByIsoCode for Martinique: "MQ"

Aditional information

Screenshot_20230811-154021

Not having a complete phone number with country code

Is there an existing issue for this?

  • I have searched the existing issues

Package/Plugin version

2.0.1

Flutter doctor

Flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.10.1, on macOS 13.3 22E252 darwin-arm64, locale en-KE)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
[✓] Xcode - develop for iOS and macOS (Xcode 14.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.3)
[✓] VS Code (version 1.78.2)
[✓] Connected device (3 available)
[✓] Network resources

• No issues found!
mark@Marks-MacBook-Air f

Minimal code example

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

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

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      // Locale config required by form_builder_validators
      // https://github.com/danvick/flutter_form_builder/blob/master/packages/form_builder_validators/example/lib/main.dart
      supportedLocales: const [...FormBuilderLocalizations.supportedLocales],
      localizationsDelegates: const [
        GlobalMaterialLocalizations.delegate,
        GlobalWidgetsLocalizations.delegate,
        GlobalCupertinoLocalizations.delegate,
        FormBuilderLocalizations.delegate,
      ],
      theme: ThemeData(
        primarySwatch: Colors.blue,
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: MyHomePage(),
    );
  }
}

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

  MyHomePage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text("FormBuilderPhoneField")),
      body: FormBuilder(
        key: _formKey,
        child: Padding(
          padding: const EdgeInsets.all(8.0),
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              FormBuilderPhoneField(
                name: 'phone_number',
                decoration: const InputDecoration(
                  labelText: 'Phone Number',
                  hintText: 'Hint',
                ),
                // onChanged: _onChanged,
                priorityListByIsoCode: const ['KE'],
                validator: FormBuilderValidators.compose([
                  FormBuilderValidators.numeric(),
                  FormBuilderValidators.required(),
                ]),
              ),
              const SizedBox(height: 15),
              FormBuilderPhoneField(
                name: 'phone_number_cupertino',
                isCupertinoPicker: true,
                decoration: const InputDecoration(
                  labelText: 'Phone Number',
                  hintText: 'Hint',
                ),
                // onChanged: _onChanged,
                priorityListByIsoCode: const ['US'],
                validator: FormBuilderValidators.compose([
                  FormBuilderValidators.numeric(),
                  FormBuilderValidators.required(),
                ]),
              ),
              const SizedBox(height: 15),
              Wrap(
                spacing: 16,
                children: [
                  ElevatedButton(
                    onPressed: () {
                      if (_formKey.currentState!.saveAndValidate()) {
                        debugPrint(_formKey.currentState!.value.toString());
                      }
                    },
                    child: const Text("Submit"),
                  ),
                  ElevatedButton(
                    onPressed: () {
                      _formKey.currentState?.reset();
                      debugPrint(
                          _formKey.currentState!.instantValue.toString());
                    },
                    child: const Text("Reset"),
                  )
                ],
              ),
            ],
          ),
        ),
      ),
    );
  }
}

Current Behavior

flutter: {phone_number: 743234567, phone_number_cupertino: 743234567}
The phone numbers are not complete with the country codes either after selecting or the initial country selected

Expected Behavior

The phone numbers inputed should have a country code
flutter: {phone_number: +254743234567, phone_number_cupertino: +254743234567,}

Steps To Reproduce

Using the example here and run it

Aditional information

Screenshot 2023-05-25 at 11 12 33

can't reset phone field (form_builder_phone_field package)

hi , i'm using flutter_form_builder & form_builder_phone_field this version :

flutter_form_builder: ^4.2.0
form_builder_phone_field: ^0.1.0 

i'm trying to use _formBuilderKey.currentState.reset(); to reset form but form_builder_phone_field it doesn't reset , how can i reset it ? 🤔

General: Support for flutter_form_builder 9.0.0

Is there an existing issue for this?

  • I have searched the existing issues

Package/Plugin version

1.4.0

Flutter doctor

Flutter doctor
[✓] Flutter (Channel stable, 3.10.0, on Microsoft Windows [Version 10.0.22621.1702], locale en-US)
    • Flutter version 3.10.0 on channel stable at C:\dev\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 84a1e904f4 (2 days ago), 2023-05-09 07:41:44 -0700
    • Engine revision d44b5a94c9
    • Dart version 3.0.0
    • DevTools version 2.23.1

[✓] Windows Version (Installed version of Windows is version 10 or higher)

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
    • Android SDK at C:\Users\Preston\AppData\Local\Android\sdk
    • Platform android-33-ext5, build-tools 33.0.2
    • Java binary at: C:\Users\Preston\AppData\Local\JetBrains\Toolbox\apps\AndroidStudio\ch-0\222.4459.24.2221.9971841\jbr\bin\java
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-b2043.56-9586694)
    • All Android licenses accepted.

[✗] 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.

[✓] Visual Studio - develop for Windows (Visual Studio Build Tools 2019 16.11.26)
    • Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools
    • Visual Studio Build Tools 2019 version 16.11.33529.622
    • Windows 10 SDK version 10.0.19041.0

[✓] Android Studio (version 2022.2)
    • Android Studio at C:\Users\Preston\AppData\Local\JetBrains\Toolbox\apps\AndroidStudio\ch-0\222.4459.24.2221.9971841
    • Flutter plugin version 73.0.1
    • Dart plugin version 221.6103.1
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-b2043.56-9586694)

[✓] VS Code (version 1.78.2)
    • VS Code at C:\Users\Preston\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.64.0

[✓] Connected device (3 available)
    • Pixel 4 XL (mobile) • 9B071FFBA003B1 • android-arm64  • Android 13 (API 33)
    • Windows (desktop)   • windows        • windows-x64    • Microsoft Windows [Version 10.0.22621.1702]
    • Edge (web)          • edge           • web-javascript • Microsoft Edge 113.0.1774.35

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

Minimal code example

Code sample

N/A

Current Behavior

Updating project to Flutter 3.10 and Dart 3, getting this error when trying to install dependencies

Because form_builder_phone_field 1.4.0 depends on flutter_form_builder ^8.0.0 and no versions of form_builder_phone_field match >1.4.0 <2.0.0, form_builder_phone_field ^1.4.0 requires flutter_form_builder ^8.0.0.
So, because level_tap depends on both flutter_form_builder ^9.0.0 and form_builder_phone_field ^1.4.0, version solving failed.

Expected Behavior

Should install dependencies with no errors

Steps To Reproduce

  1. Create new project with Flutter 3.10 and Dart 3
  2. Add the following dependencies to the pubspec.yaml
  flutter_form_builder: ^9.0.0
  form_builder_validators: ^9.0.0
  form_builder_phone_field: ^1.4.0
  1. Run flutter pub get

Aditional information

No response

Phone number can't get country value

Some country codes are shared by more than one country. For example, the US and Canada share +1. So, when a user selects a country for their phone number I want to capture and store it so when I display it again, the correct country is selected.

For example, when a user selects the US as their phone number's country, but if I'm not able to persist that country selection then when I go to display that phone number later I don't know whether it's a US or Canadian phone number so I might show a US flag for a Canadian phone number.

The issue is that FormBuilderPhoneField's onChanged method does not provide the country that was selected. I believe the issue occurs in the configuration of CountryPickerDialog where the country code is preserved in a private variable, but not propagated forward into the didChange(...) callback:

          onValuePicked: (Country country) {
            setState(() => _selectedDialogCountry = country);
            field.didChange(fullNumber);
          },

Replace country_pickers to an updated package

Environment

Package name: form_builder_phone_field
Package version: 1.0.0-beta.0
Platform: All
Device information: N/A

Description

What you'd like to happen: Replace dependency country_pickers, because these package don't receive more update

Alternatives you've considered:

PlatformException(InvalidNumber, Number 4034717829 is invalid, null, null)

Is there an existing issue for this?

  • I have searched the existing issues

Package/Plugin version

2.0.1

Platforms

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

Flutter doctor

flutter doctor -v
[!] Flutter (Channel stable, 3.10.2, on macOS 13.4 22F66 darwin-arm64, locale en-CA)
• Flutter version 3.10.2 on channel stable at /Users/warren/dev/flutter
! Warning: dart on your path resolves to /opt/homebrew/Cellar/dart/3.0.2/libexec/bin/dart, which is not inside your current Flutter SDK checkout at /Users/warren/dev/flutter. Consider adding
/Users/warren/dev/flutter/bin to the front of your path.
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 9cd3d0d9ff (7 days ago), 2023-05-23 20:57:28 -0700
• Engine revision 90fa3ae28f
• Dart version 3.0.2
• DevTools version 2.23.1
• If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
• Android SDK at /Users/warren/Library/Android/sdk
• Platform android-33, build-tools 31.0.0
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
• All Android licenses accepted.

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

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

[✓] Android Studio (version 2022.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 17.0.6+0-17.0.6b802.4-9586694)

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

[✓] Connected device (3 available)
• Pixel 6 (mobile) • adb-1A021FDF6001YN-JUzR7Q._adb-tls-connect._tcp. • android-arm64 • Android 13 (API 33)
• macOS (desktop) • macos • darwin-arm64 • macOS 13.4 22F66 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 113.0.5672.126

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

Minimal code example

      FormBuilderPhoneField(
              name: 'phone',
              initialValue: user.phone,
              decoration: const InputDecoration(
                labelText: 'Phone Number',
                hintText: 'phone',
              ),
              // priorityListByIsoCode: ['EN'],
              validator: FormBuilderValidators.compose([
                FormBuilderValidators.required(),
              ]),
            ),

Current Behavior

On android, consistently getting the PlatformException. I have tried various number formats (no dashes, with dashes, leading +1 , no leading 1, etc)

This is no doubt caused by the underlying phone library (and on the android native library), but it seems like this wrapper should handle exceptions from the underlying library?

Possibly related to flutter-form-builder-ecosystem/phone_number#101

Expected Behavior

Phone number validates OK and saves

Steps To Reproduce

FormBuilderPhoneField(

Aditional information

No response

FormBuilderPhoneField not show value after patchValue

final formKey = GlobalKey<FormBuilderState>();

formKey.currentState?.patchValue({
      'phoneNo': '+66987654321',
 });
FormBuilder(
    key: formKey,
 ....
FormBuilderPhoneField(
       name: 'phoneNo',
    decoration: const InputDecoration(
      hintText: 'หมายเลขโทรศัพท์',
      errorStyle: TextStyle(color: Colors.red),
      contentPadding: EdgeInsets.all(0.0),
    ),
    priorityListByIsoCode: const ['TH'],
    defaultSelectedCountryIsoCode: 'TH',
    validator: FormBuilderValidators.compose([
      FormBuilderValidators.numeric(errorText: 'ใช้เฉพาะตัวเลขเท่านั้น')
    ]),
  ),

dependencies:
flutter_form_builder: ^7.7.0
form_builder_phone_field: ^1.3.0
form_builder_validators: ^8.3.0

Adding maxLength changing UI and setting counterText to blank string has no effect

Environment

Package version:
form_builder_phone_field: ^1.1.0

Flutter doctor
[✓] Flutter (Channel stable, 3.0.5, on macOS 12.5 21G72 darwin-arm, locale en-IN)
    • Flutter version 3.0.5 at /Users/username/Desktop/Development/flutter/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision f1875d570e (5 weeks ago), 2022-07-13 11:24:16 -0700
    • Engine revision e85ea0e79c
    • Dart version 2.17.6
    • DevTools version 2.12.2

[✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
    • Android SDK at /Users/username/Library/Android/sdk
    • Platform android-32, build-tools 32.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7772763)
    • All Android licenses accepted.

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

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

[✓] Android Studio (version 2021.1)
    • 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.11+0-b60-7772763)

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

[✓] Connected device (3 available)
    • sdk gphone64 arm64 (mobile) • emulator-5554 • android-arm64  • Android 12 (API 32) (emulator)
    • macOS (desktop)             • macos         • darwin-arm64   • macOS 12.5 21G72 darwin-arm
    • Chrome (web)                • chrome        • web-javascript • Google Chrome 104.0.5112.79

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!

Code sample
Scaffold(
      appBar: AppBar(
        // Here we take the value from the MyHomePage object that was created by
        // the App.build method, and use it to set our appbar title.
        title: Text(widget.title),
      ),
      body: Container(
        padding: const EdgeInsets.only(top: 16, left: 16, right: 16),
        child: Container(
          padding: const EdgeInsets.all(1.0),
          child: FormBuilderPhoneField(
            autovalidateMode: AutovalidateMode.onUserInteraction,
            key: phoneNumberFieldKey,
            maxLength: 10, //Adding this
            name: 'phoneNumber',
            priorityListByIsoCode: const ['US'],
            titlePadding: EdgeInsets.zero,
            keyboardType: TextInputType.phone,
            focusNode: phoneNumberFocus,
            textInputAction: TextInputAction.next,
            iconSelector: const SizedBox(
              width: 0,
              height: 0,
            ),
            decoration: const InputDecoration(
              counterText: "", //This has no effect
              labelText: "Phone Number",
              contentPadding: EdgeInsets.symmetric(vertical: 7, horizontal: 16),
              fillColor: Colors.white,
              filled: true,
              enabledBorder: OutlineInputBorder(
                borderSide: BorderSide(color: Colors.black, width: 0.5),
                borderRadius: BorderRadius.all(Radius.circular(
                        8.0) //                 <--- border radius here
                    ),
              ),
              errorBorder: OutlineInputBorder(
                borderSide: BorderSide(color: Colors.red, width: 0.5),
                borderRadius: BorderRadius.all(Radius.circular(
                        8.0) //                 <--- border radius here
                    ),
              ),
              border: OutlineInputBorder(
                borderSide: BorderSide(color: Colors.black, width: 0.5),
                borderRadius: BorderRadius.all(Radius.circular(
                        8.0) //                 <--- border radius here
                    ),
              ),
              focusedErrorBorder: OutlineInputBorder(
                borderSide: BorderSide(color: Colors.red, width: 0.5),
                borderRadius: BorderRadius.all(Radius.circular(
                        8.0) //                 <--- border radius here
                    ),
              ),
              disabledBorder: OutlineInputBorder(
                borderSide: BorderSide(color: Colors.black, width: 0.5),
                borderRadius: BorderRadius.all(Radius.circular(
                        8.0) //                 <--- border radius here
                    ),
              ),
              focusedBorder: OutlineInputBorder(
                borderSide: BorderSide(color: Colors.black, width: 0.5),
                borderRadius: BorderRadius.all(Radius.circular(
                        8.0) //                 <--- border radius here
                    ),
              ),
              floatingLabelBehavior: FloatingLabelBehavior.auto,
            ),
            validator: FormBuilderValidators.compose([
              FormBuilderValidators.required(),
              //FormBuilderValidators.numeric(),
            ]),
          ),
        ),
      ),
    );

Description

Expected behavior:
It Should not change UI on adding maxLength property and it should hide counters when added counterText as blank string ("")

Current behavior:

  1. Adding maxLength property, it changes UI. I had borders set in InputDecoration.
  2. Adding counterText property to "" in InputDecoration does nothing

Steps to reproduce

  1. Added property maxLength
  2. Added property counterText as "" in InputDecoration

Images

Before adding maxLength=10 to both widget, 2nd widget is FormBuilderTextField from flutter_form_builder package

Screenshot_1660472611

After adding maxLength=10 to both widget

Screenshot_1660472629

After adding counterText = "" in InputDecoration

Screenshot_1660472650

Stacktrace/Logcat

FormBuilderPhoneField

There are few issues with FormBuilderPhoneField in flutter_form_builder 3.11.2

Code to reproduce:

final GlobalKey<FormBuilderState> signIn = GlobalKey<FormBuilderState>();

FormBuilder(
    key: signIn,
    child: Column(
        children: <Widget> [
            FormBuilderPhoneField(
                attribute: 'phone',
                decoration: InputDecoration(labelText: 'Phone', hintText: 'Enter your phone'),
            ),
            FormBuilderTextField(
                attribute: 'password',
                maxLines: 1,
                obscureText: true,
                textInputAction: TextInputAction.done,
                onFieldSubmitted: (_) {},
                decoration: InputDecoration(labelText: 'Password', hintText: 'Enter your password'),
                validators: [
                    FormBuilderValidators.required()
                ]
            )
        ]
    )
),

Issues:

  1. It allows me to enter more symbols than should be allowed per phone number. It actually doesn't have limits
  2. Nothing happens when I click "done" on keyboard (expecting keyboard to be hidden)
  3. Focus phone field then focus text field. Focus occurs on both fields. After this you can even click back on phone field, start typing and after first tap focus will come back to text field

Add complete web support

Environment

Package version: 1.2.0

Description

What you'd like to happen: Complete support to web. Currently when use PhoneNumberUtil from phone_number package to parsing phone, don't work in web platform

Alternatives you've considered: Update dependency phone_number when this package support web (flutter-form-builder-ecosystem/phone_number#44)

Problem with cocoaPods

Is there an existing issue for this?

  • I have searched the existing issues

Package/Plugin version

2.0.1

Platforms

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

Flutter doctor

Flutter doctor
armandom@Laptop-de-Armando flutter_application_1 % flutter doctor                   
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.16.0, on macOS 14.2 23C5047e darwin-arm64, locale es-MX)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 15.0.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2022.3)
[✓] IntelliJ IDEA Community Edition (version 2023.2.5)
[✓] VS Code (version 1.84.2)
[✓] VS Code (version 1.85.0-insider)
[✓] Connected device (3 available)
[✓] Network resources

• No issues found!

</details>


### Minimal code example

<details>
  <summary>Code sample</summary>

<!-- Paste the output below inside ``` and ``` -->

pubspec.yaml
dependencies:
  flutter:
    sdk: flutter
  flutter_form_builder: ^9.1.1
  shared_preferences: ^2.2.2
  form_builder_phone_field: ^2.0.1

```dart
import 'package:form_builder_phone_field/form_builder_phone_field.dart';
import 'package:form_builder_validators/form_builder_validators.dart';

Padding(padding: const EdgeInsets.only(left: 30, top: 2, right: 30, bottom: 4),
                        child:
                      FormBuilderPhoneField(
                        name: 'phone_number',
                        keyboardType: TextInputType.number,
                        controller: ctrlPhone,
                        defaultSelectedCountryIsoCode: 'MX',
                        pickerItemHeight: 10,
                        pickerSheetHeight: 10,
                        decoration: const InputDecoration(
                          hintText: 'Phone Number',
                          suffixIcon: Icon(CupertinoIcons.phone),
                          enabledBorder: OutlineInputBorder(
                            borderSide: BorderSide(width: 2, color: Colors.blue),
                            borderRadius: BorderRadius.all(Radius.circular(15)),
                          ),
                      ),
                        priorityListByIsoCode: const ['MX'],
                        validator: FormBuilderValidators.compose([
                          FormBuilderValidators.numeric(),
                          FormBuilderValidators.required(),
                          FormBuilderValidators.minLength(8),
                        ]),
                      ),
                      ),

Current Behavior

I can't run the app on an iOS simulator

Expected Behavior

When form_builder_phone_field: ^2.0.1 is included in the pubspec.yaml file and the app is run in ios simulator (iphone 15 pro).
sends the following error:

[!] CocoaPods could not find compatible versions for pod "PhoneNumberKit/PhoneNumberKitCore":
In Podfile:
phone_number (from .symlinks/plugins/phone_number/ios) was resolved to 2.0.1, which depends on
PhoneNumberKit/PhoneNumberKitCore (= 3.5.10)

Steps To Reproduce

Error to run App

[!] CocoaPods could not find compatible versions for pod "PhoneNumberKit/PhoneNumberKitCore":
       In Podfile:
         phone_number (from `.symlinks/plugins/phone_number/ios`) was resolved to 2.0.1, which depends on
           PhoneNumberKit/PhoneNumberKitCore (= 3.5.10)

Aditional information

No response

Phone field validation might be wrong

Hello, I'm having issue in PhoneNumber field.
I did not have any problem while using v3.13.2, but when I updated to v3.14.0, I got this problem.
The problem is

  • Validation fails in valid phoneNumber(+12125550162, +12125550160 etc)

スクリーンショット 2020-10-04 12 06 33

Here is my code

FormBuilderPhoneField(
  attribute: 'phoneNumber',
  defaultSelectedCountryIsoCode: 'JP',
  decoration: const InputDecoration(
    labelText: 'Phone',
    errorMaxLines: 1,
  ),
  priorityListByIsoCode: const ['JP', 'US'],
  validators: [
    FormBuilderValidators.required(errorText: emptyErrorMessage),
    FormBuilderValidators.numeric(errorText: phoneErrorMessage),
  ],
  onChanged: (dynamic value) {
    context
      .read<PhoneRegistrationStateNotifier>()
      .updatePhoneNumber(value, 'phoneNumber');
  }
),

// context.read.updatePhoneNumber
void updatePhoneNumber(dynamic number, String attribute) {
  final validationResult = !state
    .formBuilderKey.currentState.fields[attribute].currentState
    .validate();
  phoneNumber = number.toString();
  hasError = validationResult;
}

I think the number I am using is valid number, but I can't figure out what is wrong with this input.
My error messages are Japanese, so actually English message is not going to be displayed, and this means the validation error is not from my validator.
Am I missing something?

[form_builder_phone_field] Implement automatic deploy to pub.dev

Environment

Package name: form_builder_phone_field
Package version: N/A
Platform: N/A
Device information: N/A

Description

What you'd like to happen: Automatic publish packages when create related tag

Alternatives you've considered:

Comments:

  • Apply this to form_builder_phone_field, test and apply to other packages
  • Based on the chosen, will need create some Github Secrets with repo owner help
  • Step by step reference: flutter_mrmilu

Phone number parser not working

The phone number parsing fails. So loading phone number from memory leads to unwanted results.


  Future<bool> _parsePhone() async {
    if (_initialValue != null && _initialValue.isNotEmpty) {
      print('here $_initialValue');
      try {
        var parseResult = await PhoneNumber().parse(_initialValue);
        print(parseResult);
        if (parseResult != null) {
          setState(() {
            _selectedDialogCountry = CountryPickerUtils.getCountryByPhoneCode(
                parseResult['country_code']);
          });
          _effectiveController.text = parseResult['national_number'];
        }
      } catch (error) {
        _effectiveController.text = _initialValue.replaceFirst('+', '');
      }
    }
    return true;
  }

For initial value of +25443534543543 it returns
image

It also gives incorrect errors when validated.

image

Can you please help ?

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.