input_phone_field 0.0.3 copy "input_phone_field: ^0.0.3" to clipboard
input_phone_field: ^0.0.3 copied to clipboard

Input phone field is a plugin to control your field.

example/lib/main.dart

import 'package:flutter/material.dart';

import 'package:flutter/services.dart';
import 'package:input_phone_field/input_phone_field.dart';

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

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  final GlobalKey<FormFieldState> _phoneFormFieldState = GlobalKey();
   final _phoneController = TextEditingController();

  final _phoneFocusNode = FocusNode();

  String _phoneError = '';

  @override
  void initState() {
    super.initState();
   _find();
  }

  Future<void> _find() async {
     final r = await findCountryByPhone('', 'vn');
     debugPrint('${r.toString()}');
  }

  @override
  void dispose() {
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: InputPhoneField(
                formFieldKey: _phoneFormFieldState,
                controller: _phoneController,
                focusNode: _phoneFocusNode,
                style: TextStyle(fontSize: 13),
                isHideCountring: true,
                dropdownIcon: const Icon(Icons.expand_more),
                dropdownIconPosition: IconPosition.trailing,
                invalidNumberMessage: _phoneError,
                autovalidateMode: AutovalidateMode.disabled,
                minLength: 4,
                errorMinLength: 'Phone number is too short.',
                pickerDialogStyle: PickerDialogStyle(
                  isHideBackIcon: true,
                  isHideSearch: true,
                  isTrailingCountryCode: false,
                  isHideCountryCodeOption: false,
                  countryNameStyle: TextStyle(fontSize: 16),
                  countryCodeStyle:  TextStyle(fontSize: 16),
                  backgroundColor: Colors.grey.shade50,
                  isHideCheckIcon: false,
                  checkColor: Colors.blueAccent,
                  title: 'Select country',
                  titleStyle: TextStyle(fontSize: 15),
                  pickerType: PickerDialogType.bottomsheet,
                  padding: const EdgeInsets.symmetric(horizontal: 16),
                ),
                decoration: InputDecoration(
                  labelText: 'Phone number',
                  hintText: 'Enter phone number',
                ),
                languageCode: "vn",
                initialCountryCode: "vn",
                isRequireString: _phoneError,
                onChanged: (phone) {
                  debugPrint(phone.completeNumber);
                },
                onError: (p0) {
                  _phoneError = p0 ?? '';
                },
                onCountryChanged: (country) {
                  _phoneController.text = '';
                },
              ),
            ),
        ),
    );
  }
}
0
likes
0
points
12
downloads

Publisher

unverified uploader

Weekly Downloads

Input phone field is a plugin to control your field.

License

unknown (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on input_phone_field

Packages that implement input_phone_field