A PasswordInput or Checkcode Textfield

Features

image.png

Getting started

hb_password_input_textfield: ^1.0.1

Usage

import 'package:hb_password_input_textfield/hb_password_input_textfield.dart';

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

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(
        title: "MyHomePage",
      ),
    );
  }
}

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

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  final TextEditingController _controller = TextEditingController();
  final FocusNode _node = FocusNode();
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: GestureDetector(
          behavior: HitTestBehavior.opaque,
          onTap: () {
            _node.unfocus();
          },
          child: Container(
            margin: const EdgeInsets.only(top: 50),
            child: HBPasswordInputTextField(
              backgroundColor: Colors.white,
              fillColor: Colors.red,
              borderWidth: 0.5,
              borderRaiuds: 5,
              controller: _controller,
              node: _node,
              obscureText: true,
              obscureTextString: "🤪",
              boxWidth: 50,
              boxHeight: 50,
              type: HBPasswordInputTextFieldType.BOXES,
              length: 6,
              textStyle: const TextStyle(fontSize: 20),
              onChange: (text) {
                if (text.length == 6) {
                  _node.unfocus();
                }
              },
              borderColor: Colors.grey,
              spacing: 10,
            ),
          )),
    );
  }
}

Libraries

hb_password_input_textfield