Coder Social home page Coder Social logo

Comments (3)

natintosh avatar natintosh commented on June 21, 2024

@illiashvedov the package seems to work well on my end could you pls provide more information

from intl_phone_number_input.

illiashvedov avatar illiashvedov commented on June 21, 2024

Hi @natintosh

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

import 'package:my_project/assets/colors/colors.dart';
import 'package:my_project/localizations.dart';
import 'package:my_project/widgets/phone_number_input/const.dart';

class PhoneNumberInput extends StatefulWidget {
  PhoneNumberInput({
    Key key,
    @required this.focusNode,
    @required this.onSubmit,
    @required this.onInputChanged,
    this.inputDecoration,
    this.hintText,
    this.keyboardAction = TextInputAction.next,
    this.phoneNumber,
    this.autoValidate = false,
    TextStyle textStyle,
    TextEditingController textEditingController,
  })  : assert(focusNode != null),
        assert(onSubmit != null),
        assert(onInputChanged != null),
        textStyle = textStyle ?? TextStyle(fontSize: 20, color: greyColor),
        textEditingController =
            textEditingController ?? TextEditingController(),
        super(key: key);

  final FocusNode focusNode;
  final VoidCallback onSubmit;
  final ValueChanged<String> onInputChanged;
  final InputDecoration inputDecoration;
  final TextStyle textStyle;
  final String hintText;
  final String phoneNumber;
  final TextInputAction keyboardAction;
  final TextEditingController textEditingController;
  final bool autoValidate;

  @override
  _PhoneNumberInputState createState() => _PhoneNumberInputState();
}

class _PhoneNumberInputState extends State<PhoneNumberInput> {
  PhoneNumber _initialPhoneNumber;

  @override
  void initState() {
    if (widget.phoneNumber != null) {
      _parsablePhoneNumber(widget.phoneNumber);
    }

    super.initState();
  }

  Future _parsablePhoneNumber(String phoneNumber) async {
    if (phoneNumber.isNotEmpty) {
      PhoneNumber numberRegionInfo =
          await PhoneNumber.getRegionInfoFromPhoneNumber(phoneNumber);

      setState(() {
        _initialPhoneNumber = numberRegionInfo;
      });
    }
  }

  @override
  Widget build(BuildContext context) {
    final local = CarWashLocalizations.of(context);

    return InternationalPhoneNumberInput(
      textFieldController: widget.textEditingController,
      countries: countries,
      textStyle: widget.textStyle,
      hintText: widget.hintText,
      errorMessage: local.invalidPhoneNumber,
      keyboardAction: widget.keyboardAction,
      initialValue: _initialPhoneNumber,
      selectorType: PhoneInputSelectorType.DIALOG,
      inputDecoration: widget.inputDecoration,
      onInputChanged: _onInputChanged,
      ignoreBlank: true,
      focusNode: widget.focusNode,
      onSubmit: widget.onSubmit,
      autoValidate: widget.autoValidate,
    );
  }

  void _onInputChanged(PhoneNumber phoneNumber) =>
      widget.onInputChanged(phoneNumber.phoneNumber);
}

As you can see, I have a wrapper for your class, it is possible that it will explicitly null as the value passed to your class, after null gets there I cannot change the country, and also I can`t enter any values. I don’t exclude that I can do something wrong

from intl_phone_number_input.

illiashvedov avatar illiashvedov commented on June 21, 2024

Oh please forgive me, because I just realized that this is my personal problem with my project, I just made a new project and this problem did not reproduce, I apologize for the extra nerves

from intl_phone_number_input.

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.