cash_input_formatter 0.1.1+2
cash_input_formatter: ^0.1.1+2 copied to clipboard
Another cash formatter for TextFormField. This package is another way to format input for cash values, unlike other formatters this does not automatically show the decimal place, only on user input.
example/main.dart
import 'package:cash_input_formatter/cash_input_formatter.dart';
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Cash Input Formatter Example',
theme: ThemeData(
primarySwatch: Colors.green,
),
home: const MyHomePage(title: 'Cash Input Formatter Example'),
);
}
}
class MyHomePage extends StatefulWidget {
final String title;
const MyHomePage({super.key, required this.title});
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
const Align(
alignment: Alignment.centerLeft,
child: Text("With symbol:"),
),
Padding(
padding: const EdgeInsets.symmetric(vertical: 16.0),
child: Column(
children: [
const Text("Enter amount here"),
Padding(
padding: const EdgeInsets.symmetric(
horizontal: 50,
),
child: TextFormField(
textAlign: TextAlign.center,
inputFormatters: const [
CashInputFormatter(),
],
),
),
],
),
),
const Padding(
padding: EdgeInsets.symmetric(vertical: 40.0),
),
const Align(
alignment: Alignment.centerLeft,
child: Text("Without symbol:")),
Padding(
padding: const EdgeInsets.symmetric(vertical: 16.0),
child: Column(
children: [
const Text("Enter amount here"),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 50),
child: TextFormField(
textAlign: TextAlign.center,
inputFormatters: const [
CashInputFormatter(useSymbol: false)
],
),
)
],
),
),
],
),
),
),
);
}
}