iban_form_field 0.2.3 copy "iban_form_field: ^0.2.3" to clipboard
iban_form_field: ^0.2.3 copied to clipboard

An IBAN form which deals with spacing and country specific rules.

example/lib/main.dart

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

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        title: 'Flutter IBAN Demo',
        theme: ThemeData(
          primarySwatch: Colors.blue,
        ),
        home: Example());
  }
}

final _formKey = GlobalKey<FormState>();

class Example extends StatefulWidget {
  @override
  _ExampleState createState() => _ExampleState();
}

class _ExampleState extends State<Example> {
  Iban? _iban;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Padding(
          padding: EdgeInsets.all(10),
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Form(
                key: _formKey,
                child: IbanFormField(
                  onSaved: (iban) => _iban = iban,
                  initialValue: Iban('NL'),
                  autofocus: true,
                  validator: (iban) {
                    if (!iban!.isValid) {
                      return 'This IBAN is not valid';
                    }
                    return null;
                  },
                ),
              ),
              ElevatedButton(
                onPressed: () {
                  if (!_formKey.currentState!.validate()) {
                    return;
                  }

                  _formKey.currentState!.save();
                  showDialog(
                    context: context,
                    builder: (context) {
                      return AlertDialog(
                        content: Text(_iban.toString()),
                      );
                    },
                  );
                },
                child: Text('show'),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
7
likes
80
points
126
downloads

Publisher

verified publishermindshards.net

Weekly Downloads

An IBAN form which deals with spacing and country specific rules.

Repository (GitHub)

Documentation

API reference

License

MIT (license)

Dependencies

collection, flutter, iban

More

Packages that depend on iban_form_field