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
340f6fd4
Commit
340f6fd4
authored
Jan 26, 2016
by
Adam Barth
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1387 from abarth/stub_assert
Input asserts while keyboard is dismissed
parents
6e2f133e
2ba96877
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
33 deletions
+24
-33
input.dart
packages/flutter/lib/src/material/input.dart
+9
-6
keyboard.dart
packages/flutter/lib/src/services/keyboard.dart
+11
-24
editable.dart
packages/flutter/lib/src/widgets/editable.dart
+4
-3
No files found.
packages/flutter/lib/src/material/input.dart
View file @
340f6fd4
...
...
@@ -80,7 +80,7 @@ const Curve _kTransitionCurve = Curves.ease;
class
_InputState
extends
State
<
Input
>
{
String
_value
;
EditableString
_editableString
;
KeyboardHandle
_keyboardHandle
=
KeyboardHandle
.
unattached
;
KeyboardHandle
_keyboardHandle
;
// Used by tests.
EditableString
get
editableValue
=>
_editableString
;
...
...
@@ -96,19 +96,22 @@ class _InputState extends State<Input> {
}
void
dispose
()
{
if
(
_
keyboardHandle
.
attache
d
)
if
(
_
isAttachedToKeyboar
d
)
_keyboardHandle
.
release
();
super
.
dispose
();
}
bool
get
_isAttachedToKeyboard
=>
_keyboardHandle
!=
null
&&
_keyboardHandle
.
attached
;
void
_attachOrDetachKeyboard
(
bool
focused
)
{
if
(
focused
&&
!
_
keyboardHandle
.
attache
d
)
{
_keyboardHandle
=
keyboard
.
show
(
_editableString
.
stub
,
config
.
keyboardType
);
if
(
focused
&&
!
_
isAttachedToKeyboar
d
)
{
_keyboardHandle
=
keyboard
.
show
(
_editableString
.
createStub
()
,
config
.
keyboardType
);
_keyboardHandle
.
setText
(
_editableString
.
text
);
_keyboardHandle
.
setSelection
(
_editableString
.
selection
.
start
,
_editableString
.
selection
.
end
);
}
else
if
(!
focused
&&
_
keyboardHandle
.
attache
d
)
{
}
else
if
(!
focused
&&
_
isAttachedToKeyboar
d
)
{
_keyboardHandle
.
release
();
_keyboardHandle
=
null
;
_editableString
.
didDetachKeyboard
();
}
}
...
...
@@ -251,7 +254,7 @@ class _InputState extends State<Input> {
behavior:
HitTestBehavior
.
opaque
,
onTap:
()
{
if
(
Focus
.
at
(
context
))
{
assert
(
_
keyboardHandle
.
attache
d
);
assert
(
_
isAttachedToKeyboar
d
);
_keyboardHandle
.
showByRequest
();
}
else
{
Focus
.
moveTo
(
config
.
key
);
...
...
packages/flutter/lib/src/services/keyboard.dart
View file @
340f6fd4
...
...
@@ -10,19 +10,6 @@ import 'shell.dart';
export
'package:mojo_services/keyboard/keyboard.mojom.dart'
;
class
_KeyboardConnection
{
_KeyboardConnection
()
{
proxy
=
new
KeyboardServiceProxy
.
unbound
();
shell
.
connectToService
(
null
,
proxy
);
}
KeyboardServiceProxy
proxy
;
KeyboardService
get
keyboardService
=>
proxy
.
ptr
;
static
final
_KeyboardConnection
instance
=
new
_KeyboardConnection
();
}
/// An interface to the system's keyboard.
///
/// Most clients will want to use the [keyboard] singleton instance.
...
...
@@ -40,11 +27,8 @@ class Keyboard {
KeyboardHandle
show
(
KeyboardClientStub
stub
,
KeyboardType
keyboardType
)
{
assert
(
stub
!=
null
);
if
(
_currentHandle
!=
null
)
{
if
(
_currentHandle
.
stub
==
stub
)
return
_currentHandle
;
_currentHandle
.
release
();
}
_currentHandle
?.
release
();
assert
(
_currentHandle
==
null
);
_currentHandle
=
new
KeyboardHandle
.
_show
(
this
,
stub
,
keyboardType
);
return
_currentHandle
;
}
...
...
@@ -67,16 +51,12 @@ class Keyboard {
class
KeyboardHandle
{
KeyboardHandle
.
_show
(
Keyboard
keyboard
,
this
.
stub
,
KeyboardType
keyboardType
)
:
_keyboard
=
keyboard
{
KeyboardHandle
.
_show
(
Keyboard
keyboard
,
KeyboardClientStub
stub
,
KeyboardType
keyboardType
)
:
_keyboard
=
keyboard
{
_keyboard
.
service
.
show
(
stub
,
keyboardType
);
_attached
=
true
;
}
KeyboardHandle
.
_unattached
(
Keyboard
keyboard
)
:
_keyboard
=
keyboard
,
stub
=
null
,
_attached
=
false
;
static
final
unattached
=
new
KeyboardHandle
.
_unattached
(
keyboard
);
final
Keyboard
_keyboard
;
final
KeyboardClientStub
stub
;
bool
_attached
;
bool
get
attached
=>
_attached
;
...
...
@@ -111,4 +91,11 @@ class KeyboardHandle {
}
final
Keyboard
keyboard
=
new
Keyboard
(
_KeyboardConnection
.
instance
.
keyboardService
);
KeyboardServiceProxy
_initKeyboardProxy
(
)
{
KeyboardServiceProxy
proxy
=
new
KeyboardServiceProxy
.
unbound
();
shell
.
connectToService
(
null
,
proxy
);
return
proxy
;
}
final
KeyboardServiceProxy
_keyboardProxy
=
_initKeyboardProxy
();
final
Keyboard
keyboard
=
new
Keyboard
(
_keyboardProxy
.
ptr
);
packages/flutter/lib/src/widgets/editable.dart
View file @
340f6fd4
...
...
@@ -64,7 +64,6 @@ class _KeyboardClientImpl implements KeyboardClient {
})
{
assert
(
onUpdated
!=
null
);
assert
(
onSubmitted
!=
null
);
stub
=
new
KeyboardClientStub
.
unbound
()..
impl
=
this
;
selection
=
new
TextRange
(
start:
text
.
length
,
end:
text
.
length
);
}
...
...
@@ -84,7 +83,9 @@ class _KeyboardClientImpl implements KeyboardClient {
TextRange
selection
=
TextRange
.
empty
;
/// A keyboard client stub that can be attached to a keyboard service.
KeyboardClientStub
stub
;
KeyboardClientStub
createStub
()
{
return
new
KeyboardClientStub
.
unbound
()..
impl
=
this
;
}
void
_delete
(
TextRange
range
)
{
if
(
range
.
isCollapsed
||
!
range
.
isValid
)
return
;
...
...
@@ -196,7 +197,7 @@ class EditableString {
/// A keyboard client stub that can be attached to a keyboard service.
///
/// See [Keyboard].
KeyboardClientStub
get
stub
=>
_client
.
stub
;
KeyboardClientStub
createStub
()
=>
_client
.
createStub
()
;
void
didDetachKeyboard
()
{
_client
.
composing
=
TextRange
.
empty
;
...
...
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