Skip to main content

flutter_otp_text_field 2.0.0 copy "flutter_otp_text_field: ^2.0.0" to clipboard
flutter_otp_text_field: ^2.0.0 copied to clipboard

Fully customizable OTP Entry TextField for flutter, Widget accepts pin of any length. Built with the official material_ui package.

example/lib/main.dart

import 'package:example/verification_screen.dart';
import 'package:material_ui/material_ui.dart';

const Color accentPurpleColor = Color(0xFF6A53A1);
const Color accentPinkColor = Color(0xFFF99BBD);
const Color accentDarkGreenColor = Color(0xFF115C49);
const Color accentYellowColor = Color(0xFFFFB612);
const Color accentOrangeColor = Color(0xFFEA7A3B);

class Example {
  final String title;
  final String subtitle;
  final GestureTapCallback? onTap;
  final Route<Object?> route;

  Example({
    required this.title,
    required this.subtitle,
    required this.route,
    this.onTap,
  });
}

List<Example> examples = [
  Example(
    title: "OTP TextField Example 1",
    subtitle: "Verification Screen 1",
    route: MaterialPageRoute(
      builder: (context) => VerificationScreen1(),
    ),
  ),
  Example(
    title: "OTP TextField Example 2",
    subtitle: "Verification Screen 2",
    route: MaterialPageRoute(
      builder: (context) => VerificationScreen2(),
    ),
  ),
  // Example(
  //   title: "OTP TextField Example 3",
  //   subtitle: "Verification Screen 3",
  //   route: MaterialPageRoute(
  //     builder: (context) => Test(),
  //   ),
  // ),
];

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: Scaffold(
        appBar: AppBar(
          title: Text("Examples"),
        ),
        body: ListView(
          children: [
            Builder(builder: (context) {
              return ListTile(
                title: Text(
                  examples[0].title,
                  style: TextStyle(fontSize: 18),
                ),
                onTap: () {
                  Navigator.push(
                    context,
                    MaterialPageRoute(
                      builder: (context) => VerificationScreen1(),
                    ),
                  );
                },
              );
            }),
            Builder(
              builder: (context) {
                return ListTile(
                  title: Text(
                    examples[1].title,
                    style: TextStyle(fontSize: 18),
                  ),
                  onTap: () {
                    Navigator.push(
                      context,
                      MaterialPageRoute(
                        builder: (context) => VerificationScreen2(),
                      ),
                    );
                  },
                );
              },
            ),
            // Builder(
            //   builder: (context) {
            //     return ListTile(
            //       title: Text(
            //         examples[2].title,
            //         style: TextStyle(fontSize: 18),
            //       ),
            //       onTap: () {
            //         Navigator.push(
            //           context,
            //           MaterialPageRoute(
            //             builder: (context) => Test(),
            //           ),
            //         );
            //       },
            //     );
            //   },
            // ),
          ],
        ),
      ),
    );
  }

  void nav(BuildContext context) {
    Navigator.push(
      context,
      MaterialPageRoute(
        builder: (context) => VerificationScreen1(),
      ),
    );
  }
}
239
likes
150
points
912
downloads

Documentation

API reference

Publisher

verified publisherdavidcobbina.com

Weekly Downloads

Fully customizable OTP Entry TextField for flutter, Widget accepts pin of any length. Built with the official material_ui package.

Repository (GitHub)
View/report issues

License

BSD-3-Clause (license)

Dependencies

flutter, material_ui

More

Packages that depend on flutter_otp_text_field