validate_rut 0.2.2 copy "validate_rut: ^0.2.2" to clipboard
validate_rut: ^0.2.2 copied to clipboard

A Dart package for the validation and formatting of the Chilean Unique Tax Role (RUT).

example/main.dart

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

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'RUT Validator',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'RUT Validator Home Page'),
    );
  }
}

class MyHomePage extends StatelessWidget {
  MyHomePage({Key? key, required this.title}) : super(key: key);

  final String title;

  final TextEditingController rutController = TextEditingController();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(title),
      ),
      body: Padding(
        padding: const EdgeInsets.all(16.0),
        child: Column(
          children: <Widget>[
            TextFormField(
              inputFormatters: [
                RutInputFormatter(),
              ],
              controller: rutController,
              decoration: InputDecoration(
                labelText: 'Enter RUT',
              ),
              validator: (value) {
                if (value == null || !validateRut(value)) {
                  return 'Please enter a valid RUT';
                }
                return null;
              },
            ),
            ElevatedButton(
              onPressed: () {
                if (Form.of(context).validate()) {
                  // All fields are valid, you can process the data.
                } else {
                  // One or more fields are invalid, displays an error message.
                }
              },
              child: Text('Submit'),
            ),
          ],
        ),
      ),
    );
  }
}
2
likes
150
pub points
75%
popularity

Publisher

verified publisheraugurio.cl

A Dart package for the validation and formatting of the Chilean Unique Tax Role (RUT).

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on validate_rut