flutter_soft_keyboard 0.0.1 flutter_soft_keyboard: ^0.0.1 copied to clipboard
Flutter Virtual SoftKeyboard Widget package
import 'package:flutter/material.dart';
import 'package:soft_keyboard/key/key_type.dart';
import 'package:soft_keyboard/key/virtual_key.dart';
import 'package:soft_keyboard/keyboard_input_controller.dart';
import 'package:soft_keyboard/soft_keyboard_widget.dart';
import 'package:ripple_container/widget/container_decoration.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
final keyboardController = KeyboardInputController();
final ContainerDecoration keyDecoration = ContainerDecoration(
borderRadius: BorderRadius.circular(20),
backgroundColor: Colors.amber,
);
final TextStyle keyTextStyle = const TextStyle(
fontSize: 50,
color: Colors.white,
);
@override
void initState() {
super.initState();
keyboardController.addListener(() {
print('${keyboardController.text} [${keyboardController.lastInputKey?.type}]');
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: SoftKeyboardWidget(
width: 400,
height: 300,
columnSpacing: 4,
rowSpacing: 4,
keyLayout: [
[VirtualKey(label: '1', decoration: keyDecoration, textStyle: keyTextStyle), VirtualKey(label: '2', decoration: keyDecoration, textStyle: keyTextStyle), VirtualKey(label: '3', decoration: keyDecoration, textStyle: keyTextStyle), VirtualKey(decoration: keyDecoration, textStyle: keyTextStyle, type: KeyType.backspace, icon: Icon(Icons.abc))],
[VirtualKey(label: '1', decoration: keyDecoration, textStyle: keyTextStyle), VirtualKey(label: '2', decoration: keyDecoration, textStyle: keyTextStyle), VirtualKey(label: '3', decoration: keyDecoration, textStyle: keyTextStyle)],
],
keyboardInputController: keyboardController,
),
),
);
}
}