added keyboard input
parent
7880da056a
commit
5d5ae63c16
|
@ -1,4 +1,5 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
void main() {
|
||||
runApp(const MyApp());
|
||||
|
@ -51,7 +52,14 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
|
||||
title: Text(widget.title),
|
||||
),
|
||||
body: Center(
|
||||
body: RawKeyboardListener(
|
||||
focusNode: FocusNode(),
|
||||
autofocus: true,
|
||||
onKey: (RawKeyEvent event) {
|
||||
if (event.isKeyPressed(LogicalKeyboardKey.keyD)) _decrementCounter();
|
||||
if (event.isKeyPressed(LogicalKeyboardKey.keyI)) _incrementCounter();
|
||||
},
|
||||
child: Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
|
@ -65,10 +73,11 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
floatingActionButton: Stack(
|
||||
children: <Widget>[
|
||||
Padding(
|
||||
padding: EdgeInsets.only(left: 31),
|
||||
padding: const EdgeInsets.only(left: 31),
|
||||
child: Align(
|
||||
alignment: Alignment.bottomLeft,
|
||||
child: FloatingActionButton(
|
||||
|
|
Loading…
Reference in New Issue