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
421cd7c2
Commit
421cd7c2
authored
Feb 03, 2016
by
Adam Barth
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1531 from abarth/raw_keyboard_crash
RawKeyboardListener asserts if disposed without keyboard
parents
58156e18
12507d1b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
10 deletions
+26
-10
raw_keyboard_listener.dart
packages/flutter/lib/src/widgets/raw_keyboard_listener.dart
+10
-10
raw_keyboard_listener_test.dart
packages/flutter/test/widget/raw_keyboard_listener_test.dart
+16
-0
No files found.
packages/flutter/lib/src/widgets/raw_keyboard_listener.dart
View file @
421cd7c2
...
...
@@ -39,19 +39,20 @@ class _RawKeyboardListenerState extends State<RawKeyboardListener> implements mo
}
void
dispose
()
{
_detachKeyboard
();
_detachKeyboard
IfAttached
();
super
.
dispose
();
}
void
_attachOrDetachKeyboard
()
{
if
(
config
.
focused
&&
_stub
==
null
)
_attachKeyboard
();
else
if
(!
config
.
focused
&&
_stub
!=
null
)
_detachKeyboard
();
if
(
config
.
focused
)
_attachKeyboard
IfDetached
();
else
_detachKeyboard
IfAttached
();
}
void
_attachKeyboard
()
{
assert
(
_stub
==
null
);
void
_attachKeyboardIfDetached
()
{
if
(
_stub
!=
null
)
return
;
_stub
=
new
mojom
.
RawKeyboardListenerStub
.
unbound
()..
impl
=
this
;
mojom
.
RawKeyboardServiceProxy
keyboard
=
new
mojom
.
RawKeyboardServiceProxy
.
unbound
();
shell
.
connectToService
(
null
,
keyboard
);
...
...
@@ -59,9 +60,8 @@ class _RawKeyboardListenerState extends State<RawKeyboardListener> implements mo
keyboard
.
close
();
}
void
_detachKeyboard
()
{
assert
(
_stub
!=
null
);
_stub
.
close
();
void
_detachKeyboardIfAttached
()
{
_stub
?.
close
();
_stub
=
null
;
}
...
...
packages/flutter/test/widget/raw_keyboard_listener_test.dart
0 → 100644
View file @
421cd7c2
// Copyright 2016 The Chromium Authors. 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_test/flutter_test.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:test/test.dart'
;
void
main
(
)
{
test
(
'Can dispose without keyboard'
,
()
{
testWidgets
((
WidgetTester
tester
)
{
tester
.
pumpWidget
(
new
RawKeyboardListener
(
child:
new
Container
()));
tester
.
pumpWidget
(
new
Container
());
});
});
}
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