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.
myanmar_nrc_flutter #
Flutter integrations for the pure Dart myanmar_nrc package.
This package re-exports myanmar_nrc and adds Flutter-specific helpers for
forms and widgets.
Features #
- One-field NRC picker that opens a dialog or bottom sheet.
- Editable text field with a picker suffix button.
- Reusable NRC details view for selected or parsed values.
- Controller API for programmatic set, parse, clear, and listen workflows.
- Date-picker-style dialog API with
showMyanmarNrcPicker. - Mobile bottom-sheet API with
showMyanmarNrcPickerBottomSheet. - Embeddable picker body for custom dialogs and sheets.
- Full NRC
TextFormFieldwith built-in validation. - Structured
FormField<NrcNumber>with state, township, type, and serial controls. - Input formatters for full NRC strings and six-digit serial numbers.
- Optional and required form validators backed by
myanmar_nrc. - English and Myanmar presentation through
NrcLocale.
Usage #
Picker Field #
final controller = MyanmarNrcPickerController();
MyanmarNrcTextPickerFormField(
nrcController: controller,
isRequired: true,
locale: NrcLocale.en,
presentation: MyanmarNrcPickerPresentation.bottomSheet,
showClearButton: true,
onNrcChanged: (value) {
final formatted = value?.format(locale: NrcLocale.my);
},
)
For a read-only field that always opens the picker:
MyanmarNrcPickerField(
controller: controller,
isRequired: true,
locale: NrcLocale.my,
presentation: MyanmarNrcPickerPresentation.bottomSheet,
onChanged: (value) {
final formatted = value?.format(locale: NrcLocale.en);
},
)
Programmatic updates are supported through the controller:
controller.setFromText('12/LAMANA(N)123456');
controller.clear();
final text = controller.text(locale: NrcLocale.en);
Details View #
MyanmarNrcInfoView(
controller: controller,
locale: NrcLocale.en,
)
Picker Dialog #
final selected = await showMyanmarNrcPicker(
context: context,
initialValue: currentNrc,
locale: NrcLocale.en,
);
Picker Bottom Sheet #
final selected = await showMyanmarNrcPickerBottomSheet(
context: context,
initialValue: currentNrc,
locale: NrcLocale.my,
);
Custom Labels #
const labels = MyanmarNrcPickerLabels(
title: 'Choose NRC',
fieldLabel: 'NRC',
state: 'Region',
township: 'Township',
type: 'Type',
serial: 'Serial',
searchTownship: 'Search',
preview: 'Selected',
cancel: 'Close',
confirm: 'Use',
requiredMessage: 'Please choose an NRC.',
invalidSerialMessage: 'Enter 6 digits.',
);
Full Text Field #
import 'package:myanmar_nrc_flutter/myanmar_nrc_flutter.dart';
TextFormField(
validator: MyanmarNrcFormValidators.requiredField(),
)
Or use the preconfigured field:
MyanmarNrcTextFormField(
isRequired: true,
onSaved: (value) {
final result = MyanmarNrc.parse(value!);
},
)
Structured Field #
MyanmarNrcFormField(
locale: NrcLocale.my,
onChanged: (nrc) {
final formatted = nrc?.format(locale: NrcLocale.en);
},
)
You can still use the core APIs from the same import:
final result = MyanmarNrc.parse('12/LAMANA(N)123456');