Updated on January 21, 2021
- Support controller. The clear ()
Body content
Supports iOS, Android, and Web
Support plain text/ciphertext, two styles to choose from, and support a variety of UI style customization, including ciphertext characters, borders, rounded corners, colors, TextStyle, and so on, the following is all supported content.
final HBPasswordInputTextFieldType type; // Final Function onChange; // Input listener final int length; Final TextEditingController Controller; // Enter final FocusNode node; // Focus final double boxWidth; // Final double boxHeight; // Final double borderWidth; // Final double borderRaiuds; // Final Color borderColor; // Final Color fillColor; // Fill the final Color backgroundColor; // Padding color final double spacing; // Final bool obscureText; // Ciphertext final String obscureTextString; // Ciphertext character final TextStyle TextStyle; // Text styleCopy the code
The installation
Pub. Dev address
Add pubspec.yaml to your project
Dependencies: hb_password_input_textfield: ^ 0.1.2Copy the code
If necessary, execute this command, which I saved with VSCode and then executed automatically. $ flutter pub get
Then reference him in the corresponding file
import 'package:hb_password_input_textfield/hb_password_input_textfield.dart';
Copy the code
Example
import 'package:flutter/material.dart'; import 'package:hb_password_input_textfield/hb_password_input_textfield.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: 'HBPasswordInputTextField Demo', theme: ThemeData( primarySwatch: Colors.blue, visualDensity: VisualDensity.adaptivePlatformDensity, ), home: HBPasswordInputTextFieldPage(), ); } } class HBPasswordInputTextFieldPage extends StatefulWidget { @override _HBPasswordInputTextFieldPageState createState() => _HBPasswordInputTextFieldPageState(); } class _HBPasswordInputTextFieldPageState extends State<HBPasswordInputTextFieldPage> { // int length = 0; TextEditingController _controller = TextEditingController(); FocusNode _node = FocusNode(); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text("HBPasswordInputTextField"), ), body: GestureDetector( behavior: HitTestBehavior.opaque, onTap: () { _node.unfocus(); }, child: Container( margin: EdgeInsets.only(top: 50), child: HBPasswordInputTextField( // backgroundColor: Color. red, // fillColor: color. red, borderWidth: 0.5, borderRaiuds: 5, Controller: _controller, node: ObscureText: true, // obscureTextString: "🤪", // boxWidth: 50, // boxHeight: 50, type: HBPasswordInputTextFieldType.BOXES, length: 6, textStyle: TextStyle(fontSize: 20), onChange: (text) { print(text); },),))); }}Copy the code