· 6 years ago · Jul 11, 2019, 05:36 PM
1import 'package:flutter_web/material.dart';
2
3void main() => runApp(MyApp());
4
5class MyApp extends StatelessWidget {
6 // This widget is the root of your application.
7 @override
8 Widget build(BuildContext context) {
9 return MaterialApp(
10 title: 'Flutter Demo',
11 theme: ThemeData(
12 primarySwatch: Colors.blue,
13 ),
14 home: MyHomePage(title: 'Flutter Demo Home Page'),
15 );
16 }
17}
18
19class MyHomePage extends StatelessWidget {
20 MyHomePage({Key key, this.title}) : super(key: key);
21
22 final String title;
23
24 @override
25 Widget build(BuildContext context) {
26 return Scaffold(
27 appBar: AppBar(
28 title: Text(title),
29 ),
30 body: Center(
31 child: Column(
32 mainAxisAlignment: MainAxisAlignment.center,
33 children: <Widget>[
34 Text(
35 'Hello, World!',
36 ),
37 RawKeyboardListener(
38 child: TextField(
39 controller: TextEditingController(text: 'test'),
40 ),
41 focusNode: FocusNode(),
42 onKey: (RawKeyEvent value) {
43 print(value.logicalKey);
44 if (value.logicalKey == LogicalKeyboardKey.tab) print('tab');
45 if (value.logicalKey == LogicalKeyboardKey.keyA) print('A');
46 },
47 ),
48 ],
49 ),
50 ), // This trailing comma makes auto-formatting nicer for build methods.
51 );
52 }
53}