Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
b79c78c0
Commit
b79c78c0
authored
Nov 11, 2015
by
Collin Jackson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Raw keyboard example
parent
05ad96a1
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
78 additions
and
0 deletions
+78
-0
raw_keyboard.dart
examples/widgets/raw_keyboard.dart
+78
-0
No files found.
examples/widgets/raw_keyboard.dart
0 → 100644
View file @
b79c78c0
// Copyright (c) 2015, the Flutter project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import
'package:flutter/material.dart'
;
import
'package:flutter/services.dart'
;
import
'package:sky_services/raw_keyboard/raw_keyboard.mojom.dart'
as
mojo
;
import
'package:sky_services/sky/input_event.mojom.dart'
as
mojo
;
void
main
(
)
{
runApp
(
new
MaterialApp
(
title:
"Hardware Key Demo"
,
routes:
{
'/'
:
(
RouteArguments
args
)
=>
const
HardwareKeyDemo
()
}
)
);
}
class
HardwareKeyDemo
extends
StatefulComponent
{
const
HardwareKeyDemo
();
HardwareKeyDemoState
createState
()
=>
new
HardwareKeyDemoState
();
}
class
HardwareKeyDemoState
extends
State
<
HardwareKeyDemo
>
implements
mojo
.
RawKeyboardListener
{
mojo
.
InputEvent
_event
=
null
;
void
initState
()
{
mojo
.
RawKeyboardServiceProxy
rawKeyboardService
=
new
mojo
.
RawKeyboardServiceProxy
.
unbound
();
try
{
shell
.
connectToService
(
null
,
rawKeyboardService
);
mojo
.
RawKeyboardListenerStub
listener
=
new
mojo
.
RawKeyboardListenerStub
.
unbound
()
..
impl
=
this
;
rawKeyboardService
.
ptr
.
addListener
(
listener
);
}
finally
{
rawKeyboardService
.
close
();
}
super
.
initState
();
}
void
onKey
(
mojo
.
InputEvent
event
)
{
setState
(()
{
_event
=
event
;
});
}
Widget
_buildBody
()
{
if
(
_event
==
null
)
{
return
new
Center
(
child:
new
Text
(
"Press a key"
,
style:
Typography
.
black
.
display1
)
);
}
return
new
Column
([
new
Text
(
'
${_event?.type}
'
,
style:
Typography
.
black
.
body2
),
new
Text
(
'
${_event?.keyData?.keyCode}
'
,
style:
Typography
.
black
.
display4
)
],
justifyContent:
FlexJustifyContent
.
center
);
}
Widget
build
(
BuildContext
context
)
{
return
new
Scaffold
(
toolBar:
new
ToolBar
(
center:
new
Text
(
"Hardware Key Demo"
)
),
body:
new
Material
(
child:
_buildBody
()
)
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment