numeric_keyboard 1.1.0 numeric_keyboard: ^1.1.0 copied to clipboard
Flutter plugin to display a simple numeric keyboard on Android & iOS.
import 'package:flutter/material.dart';
import 'package:numeric_keyboard/numeric_keyboard.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Numeric Keyboard Example',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Numeric Keyboard Example'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key? key, required this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
String text = '';
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Column(
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Text(text),
NumericKeyboard(
onKeyboardTap: _onKeyboardTap,
textColor: Colors.red,
rightButtonFn: () {
setState(() {
text = text.substring(0, text.length - 1);
});
},
rightIcon: Icon(
Icons.backspace,
color: Colors.red,
),
leftButtonFn: () {
print('left button clicked');
},
leftIcon: Icon(
Icons.check,
color: Colors.red,
),
),
],
),
);
}
_onKeyboardTap(String value) {
setState(() {
text = text + value;
});
}
}