indonesian_form_kit 0.1.0
indonesian_form_kit: ^0.1.0 copied to clipboard
A Flutter form toolkit for Indonesian apps with validators, input formatters, parsers, and ready-to-use form fields.
import 'package:flutter/material.dart';
import 'package:indonesian_form_kit/indonesian_form_kit.dart';
void main() {
runApp(const ExampleApp());
}
class ExampleApp extends StatelessWidget {
const ExampleApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Indonesian Form Kit',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.red),
useMaterial3: true,
),
home: const ExampleFormPage(),
);
}
}
class ExampleFormPage extends StatefulWidget {
const ExampleFormPage({super.key});
@override
State<ExampleFormPage> createState() => _ExampleFormPageState();
}
class _ExampleFormPageState extends State<ExampleFormPage> {
final _formKey = GlobalKey<FormState>();
int? _amount;
String? _phone;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Indonesian Form Kit')),
body: SafeArea(
child: Form(
key: _formKey,
child: ListView(
padding: const EdgeInsets.all(16),
children: [
IndonesianRupiahField(
label: 'Harga',
required: true,
onChangedValue: (value) => setState(() => _amount = value),
),
const SizedBox(height: 12),
IndonesianPhoneField(
label: 'Nomor HP',
required: true,
onChangedNormalized: (value) => setState(() => _phone = value),
),
const SizedBox(height: 12),
const IndonesianNikField(
label: 'NIK',
required: true,
validateDateOfBirth: true,
),
const SizedBox(height: 12),
const IndonesianNpwpField(label: 'NPWP'),
const SizedBox(height: 12),
const IndonesianPostalCodeField(label: 'Kode Pos'),
const SizedBox(height: 12),
const IndonesianPlateNumberField(label: 'Plat Nomor'),
const SizedBox(height: 20),
FilledButton(
onPressed: () {
_formKey.currentState?.validate();
},
child: const Text('Validate'),
),
const SizedBox(height: 16),
Text('Parsed Rupiah: ${_amount ?? '-'}'),
Text('Normalized Phone: ${_phone ?? '-'}'),
],
),
),
),
);
}
}