smart_multi_form_fields 1.0.0-alpha.1
smart_multi_form_fields: ^1.0.0-alpha.1 copied to clipboard
A single, production-grade Flutter form field widget rendering text, password, phone, OTP, date, dropdown, and file inputs via sealed configurations.
example/lib/main.dart
// example/lib/main.dart
//
// Example application demonstrating smart_form_field package.
//
// This app is a testing ground for the package. It shows:
// - How to use SmartFormField with different config types
// - Navigation between different field type demos
// - How to access field state via GlobalKey
// - Validation and value retrieval patterns
import 'package:flutter/material.dart';
import 'screens/home_screen.dart';
/// Entry point for the example application.
void main() {
runApp(const SmartFormFieldExampleApp());
}
/// Root widget for the example application.
///
/// Sets up:
/// - Material 3 theme with custom seed color
/// - Navigation structure
/// - Dark/light mode support
class SmartFormFieldExampleApp extends StatelessWidget {
const SmartFormFieldExampleApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Smart Form Field - Example',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(
seedColor: const Color(0xFF02569B),
brightness: Brightness.light,
),
useMaterial3: true,
inputDecorationTheme: InputDecorationTheme(
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
borderSide: const BorderSide(color: Color(0xFF54C5F8), width: 1.5),
),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
borderSide: const BorderSide(color: Color(0xFF54C5F8), width: 1.5),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
borderSide: const BorderSide(color: Color(0xFF02569B), width: 2.0),
),
errorBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
borderSide: const BorderSide(color: Colors.redAccent, width: 1.5),
),
focusedErrorBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
borderSide: BorderSide(color: Colors.red.shade700, width: 2.0),
),
),
),
darkTheme: ThemeData(
colorScheme: ColorScheme.fromSeed(
seedColor: const Color(0xFF02569B),
brightness: Brightness.dark,
),
useMaterial3: true,
inputDecorationTheme: InputDecorationTheme(
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
borderSide: const BorderSide(color: Color(0xFF02569B), width: 1.5),
),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
borderSide: const BorderSide(color: Color(0xFF02569B), width: 1.5),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
borderSide: const BorderSide(color: Color(0xFF54C5F8), width: 2.0),
),
errorBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
borderSide: BorderSide(color: Colors.red.shade700, width: 1.5),
),
focusedErrorBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
borderSide: const BorderSide(color: Colors.redAccent, width: 2.0),
),
),
),
// Default to system theme
themeMode: ThemeMode.system,
// Start with the home screen (field type selector)
home: const HomeScreen(),
);
}
}