Pin Entry Input Text Field Using Flutter Android App

admin_img Posted By Bajarangi soft , Posted On 09-10-2020

Pin entry text field example

Pin Entry Input Text Field Using Flutter Android App

Pin Entry Input Text Field

Step 1: 
We cannot directly remove the time stamp from  Pin Entry Input Text Field but using the intl.dart package we can easily filter the date stamp from time stamp. So open your flutter project’s pubspec.yaml in code

dependencies:
  flutter:
    sdk: flutter
  pin_entry_text_field: ^0.1.4

step 2: 
After done saving the pubspec.yaml file, Open your flutter project root folder in Command Prompt or Terminal and execute flutter pub get command. 
flutter pub get

Step 3: 
Open your project’s main.dart file and import material.dart and  pin_entry_text_field: ^0.1.4. dart package.
import 'package:pin_entry_text_field/pin_entry_text_field.dart';

Step 4:
 
Pin Entry Input Text Field Short Code Example
PinEntryTextField(
  showFieldAsBox: true,
  onSubmit: (String pin){
    showDialog(
        context: context,
        builder: (context){
          return AlertDialog(
            title: Text("Pin"),
            content: Text('Pin entered is $pin'),
          );
        }
    ); //end showDialog()
  }, // end onSubmit
),

Complete Code For Pin Entry Input Text Field In Flutter
Main.dart
import 'package:flutter/material.dart';
import 'package:pin_entry_text_field/pin_entry_text_field.dart';

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        debugShowCheckedModeBanner: false,
        home: Scaffold(
            body: Center(
                child: PinEntry()
            )
        )
    );
  }
}

class PinEntry extends StatelessWidget {

  @override
  Widget build(BuildContext context) {

    return Scaffold(
      appBar: AppBar(
        backgroundColor: Colors.lightGreen,
        title: Text("Pin Entry Example"),
      ),
      body: Container(
        child: Padding(
          padding: const EdgeInsets.all(8.0),
          child: Center(
            child: PinEntryTextField(
              showFieldAsBox: true,
              onSubmit: (String pin){
                showDialog(
                    context: context,
                    builder: (context){
                      return AlertDialog(
                        title: Text("Pin"),
                        content: Text('Pin entered is $pin'),
                      );
                    }
                ); 
              }, 
            ),
          ),
        ), 
      ), 
    );
  }
}

Related Post