pin_code_fields 9.1.0 copy "pin_code_fields: ^9.1.0" to clipboard
pin_code_fields: ^9.1.0 copied to clipboard

A highly customizable PIN/OTP input field for Flutter with Material Design support and headless core for custom UIs.

example/lib/main.dart

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

import 'home_page.dart';

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

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    // Define separate light and dark PIN themes
    const lightPinTheme = MaterialPinTheme(
      shape: MaterialPinShape.outlined,
      cellSize: Size(56, 64),
      spacing: 12,
      borderRadius: BorderRadius.all(Radius.circular(12)),
      borderWidth: 1.5,
      focusedBorderWidth: 2.5,
      borderColor: Colors.grey,
      focusedBorderColor: Colors.indigo,
    );

    const darkPinTheme = MaterialPinTheme(
      shape: MaterialPinShape.outlined,
      cellSize: Size(56, 64),
      spacing: 12,
      borderRadius: BorderRadius.all(Radius.circular(12)),
      borderWidth: 1.5,
      focusedBorderWidth: 2.5,
      borderColor: Colors.grey,
      focusedBorderColor: Colors.indigoAccent,
    );

    return MaterialApp(
      title: 'Pin Code Fields',
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(
          seedColor: Colors.indigo,
          brightness: Brightness.light,
        ),
        useMaterial3: true,
        // Register the MaterialPinThemeExtension in the theme
        extensions: const [
          MaterialPinThemeExtension(theme: lightPinTheme),
        ],
      ),
      darkTheme: ThemeData(
        colorScheme: ColorScheme.fromSeed(
          seedColor: Colors.indigo,
          brightness: Brightness.dark,
        ),
        useMaterial3: true,
        // Register the MaterialPinThemeExtension in the dark theme
        extensions: const [
          MaterialPinThemeExtension(theme: darkPinTheme),
        ],
      ),
      themeMode: ThemeMode.system,
      home: const HomePage(),
    );
  }
}
2.34k
likes
160
points
287k
downloads
screenshot

Publisher

verified publishertheadar.xyz

Weekly Downloads

A highly customizable PIN/OTP input field for Flutter with Material Design support and headless core for custom UIs.

Repository (GitHub)
View/report issues

Topics

#ui #widget #pin-code #otp #input

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on pin_code_fields