idkit_inputformatters 0.0.1 copy "idkit_inputformatters: ^0.0.1" to clipboard
idkit_inputformatters: ^0.0.1 copied to clipboard

This package is mainly a formatter for digital text input.

example/lib/main.dart

import 'dart:async';

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

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

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

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key}) : super(key: key);

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

class _MyHomePageState extends State<MyHomePage> {
  late StreamController<InputFormatterError> streamController =
      StreamController();

  @override
  void initState() {
    // Handling of broadcast monitoring events for abnormal input values.
    streamController.stream.listen((event) {
      print(event);
      // Your codes...
    });
    super.initState();
  }

  @override
  void dispose() {
    // Destroy of control objects.
    streamController.close();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('IDKitInputFormatters package test'),
      ),
      body: Container(
        child: TextField(
          controller: TextEditingController(),
          inputFormatters: [
            // // Only limit the input is the number.
            IDKitNumeralTextInputFormatter(
              minValue: 1,
            ),

            // Limit the maximum length of the input value.
            // IDKitNumeralTextInputFormatter.length(
            //   maxLength: 10,
            //   errorStreamController: streamController,
            // ),

            // Limit the maximum value of the input value.
            IDKitNumeralTextInputFormatter.max(
              maxValue: 100,
              maxDecimalDigit: 2,
              decimalPoint: true,
              errorStreamController: streamController,
            ),

            // Limit the minimum value of the input value.
            IDKitNumeralTextInputFormatter.min(
              minValue: 1,
              maxDecimalDigit: 2,
              decimalPoint: true,
              errorStreamController: streamController,
            ),

            // Limit the range of input values.
            IDKitNumeralTextInputFormatter.range(
              minValue: 2,
              maxValue: 100,
              maxDecimalDigit: 2,
              decimalPoint: false,
              errorStreamController: streamController,
            ),
          ],
        ),
      ),
    );
  }
}
5
likes
100
pub points
72%
popularity

Publisher

unverified uploader

This package is mainly a formatter for digital text input.

Repository (GitHub)
View/report issues

Documentation

API reference

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on idkit_inputformatters