myanmar_nrc_flutter 0.0.1
myanmar_nrc_flutter: ^0.0.1 copied to clipboard
Flutter form and widget integrations for Myanmar NRC parsing, validation, formatting, and localization.
example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:myanmar_nrc_flutter/myanmar_nrc_flutter.dart';
void main() {
runApp(const ExampleApp());
}
class ExampleApp extends StatelessWidget {
const ExampleApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: "Myanmar NRC Demo",
home: Scaffold(
appBar: AppBar(title: const Text('Myanmar NRC')),
body: const Padding(
padding: EdgeInsets.all(16),
child: NrcExampleForm(),
),
),
);
}
}
class NrcExampleForm extends StatefulWidget {
const NrcExampleForm({super.key});
@override
State<NrcExampleForm> createState() => _NrcExampleFormState();
}
class _NrcExampleFormState extends State<NrcExampleForm> {
final _formKey = GlobalKey<FormState>();
late final MyanmarNrcPickerController _controller;
@override
void initState() {
super.initState();
_controller = MyanmarNrcPickerController();
}
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Form(
key: _formKey,
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
MyanmarNrcTextPickerFormField(
nrcController: _controller,
isRequired: true,
locale: NrcLocale.en,
presentation: MyanmarNrcPickerPresentation.bottomSheet,
showClearButton: true,
),
const SizedBox(height: 12),
MyanmarNrcInfoView(
controller: _controller,
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
border: Border.all(
color: Theme.of(context).colorScheme.outlineVariant,
),
borderRadius: BorderRadius.circular(8),
),
),
const SizedBox(height: 16),
FilledButton(
onPressed: () {
if (_formKey.currentState!.validate()) {
_formKey.currentState!.save();
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(_controller.text().isEmpty
? 'No NRC value'
: _controller.text()),
),
);
}
},
child: const Text('Validate'),
),
],
),
);
}
}