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
7884420a
Unverified
Commit
7884420a
authored
Jul 31, 2020
by
Alexandre Ardhuin
Committed by
GitHub
Jul 31, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
migrate services to nullsafety (#62513)
NNBD migration for services
parent
7cbec567
Changes
31
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
31 changed files
with
388 additions
and
454 deletions
+388
-454
keyboard_key.tmpl
dev/tools/gen_keycodes/data/keyboard_key.tmpl
+9
-7
services.dart
packages/flutter/lib/services.dart
+0
-2
asset_bundle.dart
packages/flutter/lib/src/services/asset_bundle.dart
+5
-6
autofill.dart
packages/flutter/lib/src/services/autofill.dart
+6
-7
binary_messenger.dart
packages/flutter/lib/src/services/binary_messenger.dart
+6
-7
binding.dart
packages/flutter/lib/src/services/binding.dart
+23
-24
clipboard.dart
packages/flutter/lib/src/services/clipboard.dart
+4
-5
font_loader.dart
packages/flutter/lib/src/services/font_loader.dart
+1
-2
haptic_feedback.dart
packages/flutter/lib/src/services/haptic_feedback.dart
+0
-1
keyboard_key.dart
packages/flutter/lib/src/services/keyboard_key.dart
+9
-8
keyboard_maps.dart
packages/flutter/lib/src/services/keyboard_maps.dart
+0
-1
message_codec.dart
packages/flutter/lib/src/services/message_codec.dart
+7
-8
message_codecs.dart
packages/flutter/lib/src/services/message_codecs.dart
+21
-22
platform_channel.dart
packages/flutter/lib/src/services/platform_channel.dart
+28
-29
platform_messages.dart
packages/flutter/lib/src/services/platform_messages.dart
+3
-4
platform_views.dart
packages/flutter/lib/src/services/platform_views.dart
+73
-84
raw_keyboard.dart
packages/flutter/lib/src/services/raw_keyboard.dart
+39
-43
raw_keyboard_android.dart
packages/flutter/lib/src/services/raw_keyboard_android.dart
+8
-14
raw_keyboard_fuchsia.dart
packages/flutter/lib/src/services/raw_keyboard_fuchsia.dart
+4
-10
raw_keyboard_linux.dart
packages/flutter/lib/src/services/raw_keyboard_linux.dart
+18
-25
raw_keyboard_macos.dart
packages/flutter/lib/src/services/raw_keyboard_macos.dart
+7
-12
raw_keyboard_web.dart
packages/flutter/lib/src/services/raw_keyboard_web.dart
+4
-5
raw_keyboard_windows.dart
packages/flutter/lib/src/services/raw_keyboard_windows.dart
+7
-12
restoration.dart
packages/flutter/lib/src/services/restoration.dart
+34
-37
system_channels.dart
packages/flutter/lib/src/services/system_channels.dart
+1
-2
system_chrome.dart
packages/flutter/lib/src/services/system_chrome.dart
+18
-19
system_navigator.dart
packages/flutter/lib/src/services/system_navigator.dart
+1
-2
system_sound.dart
packages/flutter/lib/src/services/system_sound.dart
+0
-1
text_editing.dart
packages/flutter/lib/src/services/text_editing.dart
+7
-8
text_formatter.dart
packages/flutter/lib/src/services/text_formatter.dart
+5
-6
text_input.dart
packages/flutter/lib/src/services/text_input.dart
+40
-41
No files found.
dev/tools/gen_keycodes/data/keyboard_key.tmpl
View file @
7884420a
...
@@ -149,13 +149,15 @@ class LogicalKeyboardKey extends KeyboardKey {
...
@@ -149,13 +149,15 @@ class LogicalKeyboardKey extends KeyboardKey {
/// The debug string to print for this keyboard key, which will be null in
/// The debug string to print for this keyboard key, which will be null in
/// release mode.
/// release mode.
final String debugName;
final String
?
debugName;
/// The Unicode string representing the character produced by a [RawKeyEvent].
/// The Unicode string representing the character produced by a [RawKeyEvent].
///
///
/// This value is useful for describing or matching mnemonic keyboard
/// This value is useful for describing or matching mnemonic keyboard
/// shortcuts.
/// shortcuts.
///
///
/// This value can be null if there's no key label data for a key.
///
/// On most platforms this is a single code point, but it could contain any
/// On most platforms this is a single code point, but it could contain any
/// Unicode string. The `keyLabel` differs from [RawKeyEvent.character]
/// Unicode string. The `keyLabel` differs from [RawKeyEvent.character]
/// because `keyLabel` only takes into account the key being pressed, not any
/// because `keyLabel` only takes into account the key being pressed, not any
...
@@ -164,7 +166,7 @@ class LogicalKeyboardKey extends KeyboardKey {
...
@@ -164,7 +166,7 @@ class LogicalKeyboardKey extends KeyboardKey {
/// “o” for [keyLabel], but would return “ö” for [RawKeyEvent.character].
/// “o” for [keyLabel], but would return “ö” for [RawKeyEvent.character].
///
///
/// {@macro flutter.services.RawKeyEventData.keyLabel}
/// {@macro flutter.services.RawKeyEventData.keyLabel}
final String keyLabel;
final String
?
keyLabel;
@override
@override
int get hashCode => keyId.hashCode;
int get hashCode => keyId.hashCode;
...
@@ -180,7 +182,7 @@ class LogicalKeyboardKey extends KeyboardKey {
...
@@ -180,7 +182,7 @@ class LogicalKeyboardKey extends KeyboardKey {
/// Returns the [LogicalKeyboardKey] constant that matches the given ID, or
/// Returns the [LogicalKeyboardKey] constant that matches the given ID, or
/// null, if not found.
/// null, if not found.
static LogicalKeyboardKey findKeyByKeyId(int keyId) => _knownLogicalKeys[keyId];
static LogicalKeyboardKey
?
findKeyByKeyId(int keyId) => _knownLogicalKeys[keyId];
/// Returns true if the given label represents a Unicode control character.
/// Returns true if the given label represents a Unicode control character.
///
///
...
@@ -237,7 +239,7 @@ class LogicalKeyboardKey extends KeyboardKey {
...
@@ -237,7 +239,7 @@ class LogicalKeyboardKey extends KeyboardKey {
/// this is a [shiftLeft] key, this accessor will return the set
/// this is a [shiftLeft] key, this accessor will return the set
/// `<LogicalKeyboardKey>{ shift }`.
/// `<LogicalKeyboardKey>{ shift }`.
Set<LogicalKeyboardKey> get synonyms {
Set<LogicalKeyboardKey> get synonyms {
final LogicalKeyboardKey result = _synonyms[this];
final LogicalKeyboardKey
?
result = _synonyms[this];
return result == null ? <LogicalKeyboardKey>{} : <LogicalKeyboardKey>{result};
return result == null ? <LogicalKeyboardKey>{} : <LogicalKeyboardKey>{result};
}
}
...
@@ -250,7 +252,7 @@ class LogicalKeyboardKey extends KeyboardKey {
...
@@ -250,7 +252,7 @@ class LogicalKeyboardKey extends KeyboardKey {
static Set<LogicalKeyboardKey> collapseSynonyms(Set<LogicalKeyboardKey> input) {
static Set<LogicalKeyboardKey> collapseSynonyms(Set<LogicalKeyboardKey> input) {
final Set<LogicalKeyboardKey> result = <LogicalKeyboardKey>{};
final Set<LogicalKeyboardKey> result = <LogicalKeyboardKey>{};
for (final LogicalKeyboardKey key in input) {
for (final LogicalKeyboardKey key in input) {
final LogicalKeyboardKey synonym = _synonyms[key];
final LogicalKeyboardKey
?
synonym = _synonyms[key];
result.add(synonym ?? key);
result.add(synonym ?? key);
}
}
return result;
return result;
...
@@ -434,11 +436,11 @@ class PhysicalKeyboardKey extends KeyboardKey {
...
@@ -434,11 +436,11 @@ class PhysicalKeyboardKey extends KeyboardKey {
/// The debug string to print for this keyboard key, which will be null in
/// The debug string to print for this keyboard key, which will be null in
/// release mode.
/// release mode.
final String debugName;
final String
?
debugName;
/// Finds a known [PhysicalKeyboardKey] that matches the given USB HID usage
/// Finds a known [PhysicalKeyboardKey] that matches the given USB HID usage
/// code.
/// code.
static PhysicalKeyboardKey findKeyByCode(int usageCode) => _knownPhysicalKeys[usageCode];
static PhysicalKeyboardKey
?
findKeyByCode(int usageCode) => _knownPhysicalKeys[usageCode];
@override
@override
int get hashCode => usbHidUsage.hashCode;
int get hashCode => usbHidUsage.hashCode;
...
...
packages/flutter/lib/services.dart
View file @
7884420a
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
/// Platform services exposed to Flutter apps.
/// Platform services exposed to Flutter apps.
///
///
/// To use, import `package:flutter/services.dart`.
/// To use, import `package:flutter/services.dart`.
...
...
packages/flutter/lib/src/services/asset_bundle.dart
View file @
7884420a
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'dart:async'
;
import
'dart:async'
;
import
'dart:convert'
;
import
'dart:convert'
;
...
@@ -181,11 +180,11 @@ abstract class CachingAssetBundle extends AssetBundle {
...
@@ -181,11 +180,11 @@ abstract class CachingAssetBundle extends AssetBundle {
assert
(
parser
!=
null
);
assert
(
parser
!=
null
);
if
(
_structuredDataCache
.
containsKey
(
key
))
if
(
_structuredDataCache
.
containsKey
(
key
))
return
_structuredDataCache
[
key
]
as
Future
<
T
>;
return
_structuredDataCache
[
key
]
as
Future
<
T
>;
Completer
<
T
>
completer
;
Completer
<
T
>
?
completer
;
Future
<
T
>
result
;
Future
<
T
>
?
result
;
loadString
(
key
,
cache:
false
).
then
<
T
>(
parser
).
then
<
void
>((
T
value
)
{
loadString
(
key
,
cache:
false
).
then
<
T
>(
parser
).
then
<
void
>((
T
value
)
{
result
=
SynchronousFuture
<
T
>(
value
);
result
=
SynchronousFuture
<
T
>(
value
);
_structuredDataCache
[
key
]
=
result
;
_structuredDataCache
[
key
]
=
result
!
;
if
(
completer
!=
null
)
{
if
(
completer
!=
null
)
{
// We already returned from the loadStructuredData function, which means
// We already returned from the loadStructuredData function, which means
// we are in the asynchronous mode. Pass the value to the completer. The
// we are in the asynchronous mode. Pass the value to the completer. The
...
@@ -196,7 +195,7 @@ abstract class CachingAssetBundle extends AssetBundle {
...
@@ -196,7 +195,7 @@ abstract class CachingAssetBundle extends AssetBundle {
if
(
result
!=
null
)
{
if
(
result
!=
null
)
{
// The code above ran synchronously, and came up with an answer.
// The code above ran synchronously, and came up with an answer.
// Return the SynchronousFuture that we created above.
// Return the SynchronousFuture that we created above.
return
result
;
return
result
!
;
}
}
// The code above hasn't yet run its "then" handler yet. Let's prepare a
// The code above hasn't yet run its "then" handler yet. Let's prepare a
// completer for it to use when it does run.
// completer for it to use when it does run.
...
@@ -217,7 +216,7 @@ class PlatformAssetBundle extends CachingAssetBundle {
...
@@ -217,7 +216,7 @@ class PlatformAssetBundle extends CachingAssetBundle {
@override
@override
Future
<
ByteData
>
load
(
String
key
)
async
{
Future
<
ByteData
>
load
(
String
key
)
async
{
final
Uint8List
encoded
=
utf8
.
encoder
.
convert
(
Uri
(
path:
Uri
.
encodeFull
(
key
)).
path
);
final
Uint8List
encoded
=
utf8
.
encoder
.
convert
(
Uri
(
path:
Uri
.
encodeFull
(
key
)).
path
);
final
ByteData
asset
=
final
ByteData
?
asset
=
await
defaultBinaryMessenger
.
send
(
'flutter/assets'
,
encoded
.
buffer
.
asByteData
());
await
defaultBinaryMessenger
.
send
(
'flutter/assets'
,
encoded
.
buffer
.
asByteData
());
if
(
asset
==
null
)
if
(
asset
==
null
)
throw
FlutterError
(
'Unable to load asset:
$key
'
);
throw
FlutterError
(
'Unable to load asset:
$key
'
);
...
...
packages/flutter/lib/src/services/autofill.dart
View file @
7884420a
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter/foundation.dart'
;
import
'package:flutter/foundation.dart'
;
import
'text_input.dart'
;
import
'text_input.dart'
;
...
@@ -629,9 +628,9 @@ class AutofillConfiguration {
...
@@ -629,9 +628,9 @@ class AutofillConfiguration {
/// Creates autofill related configuration information that can be sent to the
/// Creates autofill related configuration information that can be sent to the
/// platform.
/// platform.
const
AutofillConfiguration
({
const
AutofillConfiguration
({
@
required
this
.
uniqueIdentifier
,
required
this
.
uniqueIdentifier
,
@
required
this
.
autofillHints
,
required
this
.
autofillHints
,
this
.
currentEditingValue
,
required
this
.
currentEditingValue
,
})
:
assert
(
uniqueIdentifier
!=
null
),
})
:
assert
(
uniqueIdentifier
!=
null
),
assert
(
autofillHints
!=
null
);
assert
(
autofillHints
!=
null
);
...
@@ -749,7 +748,7 @@ abstract class AutofillScope {
...
@@ -749,7 +748,7 @@ abstract class AutofillScope {
/// this [AutofillScope].
/// this [AutofillScope].
///
///
/// Returns null if there's no matching [AutofillClient].
/// Returns null if there's no matching [AutofillClient].
AutofillClient
getAutofillClient
(
String
autofillId
);
AutofillClient
?
getAutofillClient
(
String
autofillId
);
/// The collection of [AutofillClient]s currently tied to this [AutofillScope].
/// The collection of [AutofillClient]s currently tied to this [AutofillScope].
///
///
...
@@ -767,8 +766,8 @@ abstract class AutofillScope {
...
@@ -767,8 +766,8 @@ abstract class AutofillScope {
@immutable
@immutable
class
_AutofillScopeTextInputConfiguration
extends
TextInputConfiguration
{
class
_AutofillScopeTextInputConfiguration
extends
TextInputConfiguration
{
_AutofillScopeTextInputConfiguration
({
_AutofillScopeTextInputConfiguration
({
@
required
this
.
allConfigurations
,
required
this
.
allConfigurations
,
@
required
TextInputConfiguration
currentClientConfiguration
,
required
TextInputConfiguration
currentClientConfiguration
,
})
:
assert
(
allConfigurations
!=
null
),
})
:
assert
(
allConfigurations
!=
null
),
assert
(
currentClientConfiguration
!=
null
),
assert
(
currentClientConfiguration
!=
null
),
super
(
inputType:
currentClientConfiguration
.
inputType
,
super
(
inputType:
currentClientConfiguration
.
inputType
,
...
...
packages/flutter/lib/src/services/binary_messenger.dart
View file @
7884420a
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'dart:async'
;
import
'dart:async'
;
import
'dart:typed_data'
;
import
'dart:typed_data'
;
...
@@ -12,7 +11,7 @@ import 'package:flutter/foundation.dart';
...
@@ -12,7 +11,7 @@ import 'package:flutter/foundation.dart';
import
'binding.dart'
;
import
'binding.dart'
;
/// A function which takes a platform message and asynchronously returns an encoded response.
/// A function which takes a platform message and asynchronously returns an encoded response.
typedef
MessageHandler
=
Future
<
ByteData
>
Function
(
ByteData
message
);
typedef
MessageHandler
=
Future
<
ByteData
?>
Function
(
ByteData
?
message
);
/// A messenger which sends binary data across the Flutter platform barrier.
/// A messenger which sends binary data across the Flutter platform barrier.
///
///
...
@@ -27,13 +26,13 @@ abstract class BinaryMessenger {
...
@@ -27,13 +26,13 @@ abstract class BinaryMessenger {
/// from [Window.onPlatformMessage].
/// from [Window.onPlatformMessage].
///
///
/// To register a handler for a given message channel, see [setMessageHandler].
/// To register a handler for a given message channel, see [setMessageHandler].
Future
<
void
>
handlePlatformMessage
(
String
channel
,
ByteData
data
,
ui
.
PlatformMessageResponseCallback
callback
);
Future
<
void
>
handlePlatformMessage
(
String
channel
,
ByteData
?
data
,
ui
.
PlatformMessageResponseCallback
?
callback
);
/// Send a binary message to the platform plugins on the given channel.
/// Send a binary message to the platform plugins on the given channel.
///
///
/// Returns a [Future] which completes to the received response, undecoded,
/// Returns a [Future] which completes to the received response, undecoded,
/// in binary form.
/// in binary form.
Future
<
ByteData
>
send
(
String
channel
,
ByteData
message
);
Future
<
ByteData
?>
send
(
String
channel
,
ByteData
?
message
);
/// Set a callback for receiving messages from the platform plugins on the
/// Set a callback for receiving messages from the platform plugins on the
/// given channel, without decoding them.
/// given channel, without decoding them.
...
@@ -43,7 +42,7 @@ abstract class BinaryMessenger {
...
@@ -43,7 +42,7 @@ abstract class BinaryMessenger {
/// argument.
/// argument.
///
///
/// The handler's return value, if non-null, is sent as a response, unencoded.
/// The handler's return value, if non-null, is sent as a response, unencoded.
void
setMessageHandler
(
String
channel
,
MessageHandler
handler
);
void
setMessageHandler
(
String
channel
,
MessageHandler
?
handler
);
/// Returns true if the `handler` argument matches the `handler` previously
/// Returns true if the `handler` argument matches the `handler` previously
/// passed to [setMessageHandler].
/// passed to [setMessageHandler].
...
@@ -63,7 +62,7 @@ abstract class BinaryMessenger {
...
@@ -63,7 +62,7 @@ abstract class BinaryMessenger {
///
///
/// This is intended for testing. Messages intercepted in this manner are not
/// This is intended for testing. Messages intercepted in this manner are not
/// sent to platform plugins.
/// sent to platform plugins.
void
setMockMessageHandler
(
String
channel
,
MessageHandler
handler
);
void
setMockMessageHandler
(
String
channel
,
MessageHandler
?
handler
);
/// Returns true if the `handler` argument matches the `handler` previously
/// Returns true if the `handler` argument matches the `handler` previously
/// passed to [setMockMessageHandler].
/// passed to [setMockMessageHandler].
...
@@ -104,5 +103,5 @@ BinaryMessenger get defaultBinaryMessenger {
...
@@ -104,5 +103,5 @@ BinaryMessenger get defaultBinaryMessenger {
}
}
return
true
;
return
true
;
}());
}());
return
ServicesBinding
.
instance
.
defaultBinaryMessenger
;
return
ServicesBinding
.
instance
!
.
defaultBinaryMessenger
;
}
}
packages/flutter/lib/src/services/binding.dart
View file @
7884420a
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'dart:async'
;
import
'dart:async'
;
import
'dart:typed_data'
;
import
'dart:typed_data'
;
...
@@ -31,14 +30,14 @@ mixin ServicesBinding on BindingBase, SchedulerBinding {
...
@@ -31,14 +30,14 @@ mixin ServicesBinding on BindingBase, SchedulerBinding {
_restorationManager
=
createRestorationManager
();
_restorationManager
=
createRestorationManager
();
window
.
onPlatformMessage
=
defaultBinaryMessenger
.
handlePlatformMessage
;
window
.
onPlatformMessage
=
defaultBinaryMessenger
.
handlePlatformMessage
;
initLicenses
();
initLicenses
();
SystemChannels
.
system
.
setMessageHandler
(
handleSystemMessage
);
SystemChannels
.
system
.
setMessageHandler
(
(
dynamic
message
)
=>
handleSystemMessage
(
message
as
Object
)
);
SystemChannels
.
lifecycle
.
setMessageHandler
(
_handleLifecycleMessage
);
SystemChannels
.
lifecycle
.
setMessageHandler
(
_handleLifecycleMessage
);
readInitialLifecycleStateFromNativeWindow
();
readInitialLifecycleStateFromNativeWindow
();
}
}
/// The current [ServicesBinding], if one has been created.
/// The current [ServicesBinding], if one has been created.
static
ServicesBinding
get
instance
=>
_instance
;
static
ServicesBinding
?
get
instance
=>
_instance
;
static
ServicesBinding
_instance
;
static
ServicesBinding
?
_instance
;
/// The default instance of [BinaryMessenger].
/// The default instance of [BinaryMessenger].
///
///
...
@@ -46,7 +45,7 @@ mixin ServicesBinding on BindingBase, SchedulerBinding {
...
@@ -46,7 +45,7 @@ mixin ServicesBinding on BindingBase, SchedulerBinding {
/// keeps track of which handlers have been registered on each channel so
/// keeps track of which handlers have been registered on each channel so
/// it may dispatch incoming messages to the registered handler.
/// it may dispatch incoming messages to the registered handler.
BinaryMessenger
get
defaultBinaryMessenger
=>
_defaultBinaryMessenger
;
BinaryMessenger
get
defaultBinaryMessenger
=>
_defaultBinaryMessenger
;
BinaryMessenger
_defaultBinaryMessenger
;
late
BinaryMessenger
_defaultBinaryMessenger
;
/// Creates a default [BinaryMessenger] instance that can be used for sending
/// Creates a default [BinaryMessenger] instance that can be used for sending
/// platform messages.
/// platform messages.
...
@@ -110,7 +109,7 @@ mixin ServicesBinding on BindingBase, SchedulerBinding {
...
@@ -110,7 +109,7 @@ mixin ServicesBinding on BindingBase, SchedulerBinding {
await
rawLicenses
.
future
;
await
rawLicenses
.
future
;
final
Completer
<
List
<
LicenseEntry
>>
parsedLicenses
=
Completer
<
List
<
LicenseEntry
>>();
final
Completer
<
List
<
LicenseEntry
>>
parsedLicenses
=
Completer
<
List
<
LicenseEntry
>>();
scheduleTask
(()
async
{
scheduleTask
(()
async
{
parsedLicenses
.
complete
(
compute
(
_parseLicenses
,
await
rawLicenses
.
future
,
debugLabel:
'parseLicenses'
));
parsedLicenses
.
complete
(
compute
<
String
,
List
<
LicenseEntry
>>
(
_parseLicenses
,
await
rawLicenses
.
future
,
debugLabel:
'parseLicenses'
));
},
Priority
.
animation
);
},
Priority
.
animation
);
await
parsedLicenses
.
future
;
await
parsedLicenses
.
future
;
yield
*
Stream
<
LicenseEntry
>.
fromIterable
(
await
parsedLicenses
.
future
);
yield
*
Stream
<
LicenseEntry
>.
fromIterable
(
await
parsedLicenses
.
future
);
...
@@ -183,18 +182,18 @@ mixin ServicesBinding on BindingBase, SchedulerBinding {
...
@@ -183,18 +182,18 @@ mixin ServicesBinding on BindingBase, SchedulerBinding {
if
(
lifecycleState
!=
null
)
{
if
(
lifecycleState
!=
null
)
{
return
;
return
;
}
}
final
AppLifecycleState
state
=
_parseAppLifecycleMessage
(
window
.
initialLifecycleState
);
final
AppLifecycleState
?
state
=
_parseAppLifecycleMessage
(
window
.
initialLifecycleState
);
if
(
state
!=
null
)
{
if
(
state
!=
null
)
{
handleAppLifecycleStateChanged
(
state
);
handleAppLifecycleStateChanged
(
state
);
}
}
}
}
Future
<
String
>
_handleLifecycleMessage
(
String
message
)
async
{
Future
<
String
?>
_handleLifecycleMessage
(
String
?
message
)
async
{
handleAppLifecycleStateChanged
(
_parseAppLifecycleMessage
(
message
)
);
handleAppLifecycleStateChanged
(
_parseAppLifecycleMessage
(
message
!)!
);
return
null
;
return
null
;
}
}
static
AppLifecycleState
_parseAppLifecycleMessage
(
String
message
)
{
static
AppLifecycleState
?
_parseAppLifecycleMessage
(
String
message
)
{
switch
(
message
)
{
switch
(
message
)
{
case
'AppLifecycleState.paused'
:
case
'AppLifecycleState.paused'
:
return
AppLifecycleState
.
paused
;
return
AppLifecycleState
.
paused
;
...
@@ -218,7 +217,7 @@ mixin ServicesBinding on BindingBase, SchedulerBinding {
...
@@ -218,7 +217,7 @@ mixin ServicesBinding on BindingBase, SchedulerBinding {
/// [createRestorationManager], which is called to create the instance
/// [createRestorationManager], which is called to create the instance
/// returned by this getter.
/// returned by this getter.
RestorationManager
get
restorationManager
=>
_restorationManager
;
RestorationManager
get
restorationManager
=>
_restorationManager
;
RestorationManager
_restorationManager
;
late
RestorationManager
_restorationManager
;
/// Creates the [RestorationManager] instance available via
/// Creates the [RestorationManager] instance available via
/// [restorationManager].
/// [restorationManager].
...
@@ -248,15 +247,15 @@ class _DefaultBinaryMessenger extends BinaryMessenger {
...
@@ -248,15 +247,15 @@ class _DefaultBinaryMessenger extends BinaryMessenger {
static
final
Map
<
String
,
MessageHandler
>
_mockHandlers
=
static
final
Map
<
String
,
MessageHandler
>
_mockHandlers
=
<
String
,
MessageHandler
>{};
<
String
,
MessageHandler
>{};
Future
<
ByteData
>
_sendPlatformMessage
(
String
channel
,
ByteData
message
)
{
Future
<
ByteData
?>
_sendPlatformMessage
(
String
channel
,
ByteData
?
message
)
{
final
Completer
<
ByteData
>
completer
=
Completer
<
ByteData
>();
final
Completer
<
ByteData
?>
completer
=
Completer
<
ByteData
?
>();
// ui.window is accessed directly instead of using ServicesBinding.instance.window
// ui.window is accessed directly instead of using ServicesBinding.instance.window
// because this method might be invoked before any binding is initialized.
// because this method might be invoked before any binding is initialized.
// This issue was reported in #27541. It is not ideal to statically access
// This issue was reported in #27541. It is not ideal to statically access
// ui.window because the Window may be dependency injected elsewhere with
// ui.window because the Window may be dependency injected elsewhere with
// a different instance. However, static access at this location seems to be
// a different instance. However, static access at this location seems to be
// the least bad option.
// the least bad option.
ui
.
window
.
sendPlatformMessage
(
channel
,
message
,
(
ByteData
reply
)
{
ui
.
window
.
sendPlatformMessage
(
channel
,
message
,
(
ByteData
?
reply
)
{
try
{
try
{
completer
.
complete
(
reply
);
completer
.
complete
(
reply
);
}
catch
(
exception
,
stack
)
{
}
catch
(
exception
,
stack
)
{
...
@@ -274,16 +273,16 @@ class _DefaultBinaryMessenger extends BinaryMessenger {
...
@@ -274,16 +273,16 @@ class _DefaultBinaryMessenger extends BinaryMessenger {
@override
@override
Future
<
void
>
handlePlatformMessage
(
Future
<
void
>
handlePlatformMessage
(
String
channel
,
String
channel
,
ByteData
data
,
ByteData
?
data
,
ui
.
PlatformMessageResponseCallback
callback
,
ui
.
PlatformMessageResponseCallback
?
callback
,
)
async
{
)
async
{
ByteData
response
;
ByteData
?
response
;
try
{
try
{
final
MessageHandler
handler
=
_handlers
[
channel
];
final
MessageHandler
?
handler
=
_handlers
[
channel
];
if
(
handler
!=
null
)
{
if
(
handler
!=
null
)
{
response
=
await
handler
(
data
);
response
=
await
handler
(
data
);
}
else
{
}
else
{
ui
.
channelBuffers
.
push
(
channel
,
data
,
callback
);
ui
.
channelBuffers
.
push
(
channel
,
data
,
callback
!
);
callback
=
null
;
callback
=
null
;
}
}
}
catch
(
exception
,
stack
)
{
}
catch
(
exception
,
stack
)
{
...
@@ -301,20 +300,20 @@ class _DefaultBinaryMessenger extends BinaryMessenger {
...
@@ -301,20 +300,20 @@ class _DefaultBinaryMessenger extends BinaryMessenger {
}
}
@override
@override
Future
<
ByteData
>
send
(
String
channel
,
ByteData
message
)
{
Future
<
ByteData
?>
send
(
String
channel
,
ByteData
?
message
)
{
final
MessageHandler
handler
=
_mockHandlers
[
channel
];
final
MessageHandler
?
handler
=
_mockHandlers
[
channel
];
if
(
handler
!=
null
)
if
(
handler
!=
null
)
return
handler
(
message
);
return
handler
(
message
);
return
_sendPlatformMessage
(
channel
,
message
);
return
_sendPlatformMessage
(
channel
,
message
);
}
}
@override
@override
void
setMessageHandler
(
String
channel
,
MessageHandler
handler
)
{
void
setMessageHandler
(
String
channel
,
MessageHandler
?
handler
)
{
if
(
handler
==
null
)
if
(
handler
==
null
)
_handlers
.
remove
(
channel
);
_handlers
.
remove
(
channel
);
else
else
_handlers
[
channel
]
=
handler
;
_handlers
[
channel
]
=
handler
;
ui
.
channelBuffers
.
drain
(
channel
,
(
ByteData
data
,
ui
.
PlatformMessageResponseCallback
callback
)
async
{
ui
.
channelBuffers
.
drain
(
channel
,
(
ByteData
?
data
,
ui
.
PlatformMessageResponseCallback
callback
)
async
{
await
handlePlatformMessage
(
channel
,
data
,
callback
);
await
handlePlatformMessage
(
channel
,
data
,
callback
);
});
});
}
}
...
@@ -323,7 +322,7 @@ class _DefaultBinaryMessenger extends BinaryMessenger {
...
@@ -323,7 +322,7 @@ class _DefaultBinaryMessenger extends BinaryMessenger {
bool
checkMessageHandler
(
String
channel
,
MessageHandler
handler
)
=>
_handlers
[
channel
]
==
handler
;
bool
checkMessageHandler
(
String
channel
,
MessageHandler
handler
)
=>
_handlers
[
channel
]
==
handler
;
@override
@override
void
setMockMessageHandler
(
String
channel
,
MessageHandler
handler
)
{
void
setMockMessageHandler
(
String
channel
,
MessageHandler
?
handler
)
{
if
(
handler
==
null
)
if
(
handler
==
null
)
_mockHandlers
.
remove
(
channel
);
_mockHandlers
.
remove
(
channel
);
else
else
...
...
packages/flutter/lib/src/services/clipboard.dart
View file @
7884420a
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'dart:async'
;
import
'dart:async'
;
...
@@ -20,7 +19,7 @@ class ClipboardData {
...
@@ -20,7 +19,7 @@ class ClipboardData {
const
ClipboardData
({
this
.
text
});
const
ClipboardData
({
this
.
text
});
/// Plain text variant of this clipboard data.
/// Plain text variant of this clipboard data.
final
String
text
;
final
String
?
text
;
}
}
/// Utility methods for interacting with the system's clipboard.
/// Utility methods for interacting with the system's clipboard.
...
@@ -54,13 +53,13 @@ class Clipboard {
...
@@ -54,13 +53,13 @@ class Clipboard {
///
///
/// Returns a future which completes to null if the data could not be
/// Returns a future which completes to null if the data could not be
/// obtained, and to a [ClipboardData] object if it could.
/// obtained, and to a [ClipboardData] object if it could.
static
Future
<
ClipboardData
>
getData
(
String
format
)
async
{
static
Future
<
ClipboardData
?
>
getData
(
String
format
)
async
{
final
Map
<
String
,
dynamic
>
result
=
await
SystemChannels
.
platform
.
invokeMethod
(
final
Map
<
String
,
dynamic
>
?
result
=
await
SystemChannels
.
platform
.
invokeMethod
(
'Clipboard.getData'
,
'Clipboard.getData'
,
format
,
format
,
);
);
if
(
result
==
null
)
if
(
result
==
null
)
return
null
;
return
null
;
return
ClipboardData
(
text:
result
[
'text'
]
as
String
);
return
ClipboardData
(
text:
result
[
'text'
]
as
String
?
);
}
}
}
}
packages/flutter/lib/src/services/font_loader.dart
View file @
7884420a
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'dart:async'
;
import
'dart:async'
;
import
'dart:typed_data'
;
import
'dart:typed_data'
;
...
@@ -64,7 +63,7 @@ class FontLoader {
...
@@ -64,7 +63,7 @@ class FontLoader {
(
Uint8List
list
)
=>
loadFont
(
list
,
family
)
(
Uint8List
list
)
=>
loadFont
(
list
,
family
)
)
)
);
);
return
Future
.
wait
(
loadFutures
.
toList
());
await
Future
.
wait
(
loadFutures
.
toList
());
}
}
/// Hook called to load a font asset into the engine.
/// Hook called to load a font asset into the engine.
...
...
packages/flutter/lib/src/services/haptic_feedback.dart
View file @
7884420a
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'dart:async'
;
import
'dart:async'
;
...
...
packages/flutter/lib/src/services/keyboard_key.dart
View file @
7884420a
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
// DO NOT EDIT -- DO NOT EDIT -- DO NOT EDIT
// DO NOT EDIT -- DO NOT EDIT -- DO NOT EDIT
// This file is generated by dev/tools/gen_keycodes/bin/gen_keycodes.dart and
// This file is generated by dev/tools/gen_keycodes/bin/gen_keycodes.dart and
...
@@ -149,13 +148,15 @@ class LogicalKeyboardKey extends KeyboardKey {
...
@@ -149,13 +148,15 @@ class LogicalKeyboardKey extends KeyboardKey {
/// The debug string to print for this keyboard key, which will be null in
/// The debug string to print for this keyboard key, which will be null in
/// release mode.
/// release mode.
final
String
debugName
;
final
String
?
debugName
;
/// The Unicode string representing the character produced by a [RawKeyEvent].
/// The Unicode string representing the character produced by a [RawKeyEvent].
///
///
/// This value is useful for describing or matching mnemonic keyboard
/// This value is useful for describing or matching mnemonic keyboard
/// shortcuts.
/// shortcuts.
///
///
/// This value can be null if there's no key label data for a key.
///
/// On most platforms this is a single code point, but it could contain any
/// On most platforms this is a single code point, but it could contain any
/// Unicode string. The `keyLabel` differs from [RawKeyEvent.character]
/// Unicode string. The `keyLabel` differs from [RawKeyEvent.character]
/// because `keyLabel` only takes into account the key being pressed, not any
/// because `keyLabel` only takes into account the key being pressed, not any
...
@@ -164,7 +165,7 @@ class LogicalKeyboardKey extends KeyboardKey {
...
@@ -164,7 +165,7 @@ class LogicalKeyboardKey extends KeyboardKey {
/// “o” for [keyLabel], but would return “ö” for [RawKeyEvent.character].
/// “o” for [keyLabel], but would return “ö” for [RawKeyEvent.character].
///
///
/// {@macro flutter.services.RawKeyEventData.keyLabel}
/// {@macro flutter.services.RawKeyEventData.keyLabel}
final
String
keyLabel
;
final
String
?
keyLabel
;
@override
@override
int
get
hashCode
=>
keyId
.
hashCode
;
int
get
hashCode
=>
keyId
.
hashCode
;
...
@@ -180,7 +181,7 @@ class LogicalKeyboardKey extends KeyboardKey {
...
@@ -180,7 +181,7 @@ class LogicalKeyboardKey extends KeyboardKey {
/// Returns the [LogicalKeyboardKey] constant that matches the given ID, or
/// Returns the [LogicalKeyboardKey] constant that matches the given ID, or
/// null, if not found.
/// null, if not found.
static
LogicalKeyboardKey
findKeyByKeyId
(
int
keyId
)
=>
_knownLogicalKeys
[
keyId
];
static
LogicalKeyboardKey
?
findKeyByKeyId
(
int
keyId
)
=>
_knownLogicalKeys
[
keyId
];
/// Returns true if the given label represents a Unicode control character.
/// Returns true if the given label represents a Unicode control character.
///
///
...
@@ -237,7 +238,7 @@ class LogicalKeyboardKey extends KeyboardKey {
...
@@ -237,7 +238,7 @@ class LogicalKeyboardKey extends KeyboardKey {
/// this is a [shiftLeft] key, this accessor will return the set
/// this is a [shiftLeft] key, this accessor will return the set
/// `<LogicalKeyboardKey>{ shift }`.
/// `<LogicalKeyboardKey>{ shift }`.
Set
<
LogicalKeyboardKey
>
get
synonyms
{
Set
<
LogicalKeyboardKey
>
get
synonyms
{
final
LogicalKeyboardKey
result
=
_synonyms
[
this
];
final
LogicalKeyboardKey
?
result
=
_synonyms
[
this
];
return
result
==
null
?
<
LogicalKeyboardKey
>{}
:
<
LogicalKeyboardKey
>{
result
};
return
result
==
null
?
<
LogicalKeyboardKey
>{}
:
<
LogicalKeyboardKey
>{
result
};
}
}
...
@@ -250,7 +251,7 @@ class LogicalKeyboardKey extends KeyboardKey {
...
@@ -250,7 +251,7 @@ class LogicalKeyboardKey extends KeyboardKey {
static
Set
<
LogicalKeyboardKey
>
collapseSynonyms
(
Set
<
LogicalKeyboardKey
>
input
)
{
static
Set
<
LogicalKeyboardKey
>
collapseSynonyms
(
Set
<
LogicalKeyboardKey
>
input
)
{
final
Set
<
LogicalKeyboardKey
>
result
=
<
LogicalKeyboardKey
>{};
final
Set
<
LogicalKeyboardKey
>
result
=
<
LogicalKeyboardKey
>{};
for
(
final
LogicalKeyboardKey
key
in
input
)
{
for
(
final
LogicalKeyboardKey
key
in
input
)
{
final
LogicalKeyboardKey
synonym
=
_synonyms
[
key
];
final
LogicalKeyboardKey
?
synonym
=
_synonyms
[
key
];
result
.
add
(
synonym
??
key
);
result
.
add
(
synonym
??
key
);
}
}
return
result
;
return
result
;
...
@@ -2087,11 +2088,11 @@ class PhysicalKeyboardKey extends KeyboardKey {
...
@@ -2087,11 +2088,11 @@ class PhysicalKeyboardKey extends KeyboardKey {
/// The debug string to print for this keyboard key, which will be null in
/// The debug string to print for this keyboard key, which will be null in
/// release mode.
/// release mode.
final
String
debugName
;
final
String
?
debugName
;
/// Finds a known [PhysicalKeyboardKey] that matches the given USB HID usage
/// Finds a known [PhysicalKeyboardKey] that matches the given USB HID usage
/// code.
/// code.
static
PhysicalKeyboardKey
findKeyByCode
(
int
usageCode
)
=>
_knownPhysicalKeys
[
usageCode
];
static
PhysicalKeyboardKey
?
findKeyByCode
(
int
usageCode
)
=>
_knownPhysicalKeys
[
usageCode
];
@override
@override
int
get
hashCode
=>
usbHidUsage
.
hashCode
;
int
get
hashCode
=>
usbHidUsage
.
hashCode
;
...
...
packages/flutter/lib/src/services/keyboard_maps.dart
View file @
7884420a
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
// DO NOT EDIT -- DO NOT EDIT -- DO NOT EDIT
// DO NOT EDIT -- DO NOT EDIT -- DO NOT EDIT
// This file is generated by dev/tools/gen_keycodes/bin/gen_keycodes.dart and
// This file is generated by dev/tools/gen_keycodes/bin/gen_keycodes.dart and
...
...
packages/flutter/lib/src/services/message_codec.dart
View file @
7884420a
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'dart:typed_data'
;
import
'dart:typed_data'
;
...
@@ -25,12 +24,12 @@ abstract class MessageCodec<T> {
...
@@ -25,12 +24,12 @@ abstract class MessageCodec<T> {
/// Encodes the specified [message] in binary.
/// Encodes the specified [message] in binary.
///
///
/// Returns null if the message is null.
/// Returns null if the message is null.
ByteData
encodeMessage
(
T
message
);
ByteData
?
encodeMessage
(
T
message
);
/// Decodes the specified [message] from binary.
/// Decodes the specified [message] from binary.
///
///
/// Returns null if the message is null.
/// Returns null if the message is null.
T
decodeMessage
(
ByteData
message
);
T
decodeMessage
(
ByteData
?
message
);
}
}
/// An command object representing the invocation of a named method.
/// An command object representing the invocation of a named method.
...
@@ -68,7 +67,7 @@ abstract class MethodCodec {
...
@@ -68,7 +67,7 @@ abstract class MethodCodec {
ByteData
encodeMethodCall
(
MethodCall
methodCall
);
ByteData
encodeMethodCall
(
MethodCall
methodCall
);
/// Decodes the specified [methodCall] from binary.
/// Decodes the specified [methodCall] from binary.
MethodCall
decodeMethodCall
(
ByteData
methodCall
);
MethodCall
decodeMethodCall
(
ByteData
?
methodCall
);
/// Decodes the specified result [envelope] from binary.
/// Decodes the specified result [envelope] from binary.
///
///
...
@@ -83,7 +82,7 @@ abstract class MethodCodec {
...
@@ -83,7 +82,7 @@ abstract class MethodCodec {
///
///
/// The specified error [code], human-readable error [message], and error
/// The specified error [code], human-readable error [message], and error
/// [details] correspond to the fields of [PlatformException].
/// [details] correspond to the fields of [PlatformException].
ByteData
encodeErrorEnvelope
({
@required
String
code
,
String
message
,
dynamic
details
});
ByteData
encodeErrorEnvelope
({
required
String
code
,
String
?
message
,
dynamic
details
});
}
}
...
@@ -105,7 +104,7 @@ class PlatformException implements Exception {
...
@@ -105,7 +104,7 @@ class PlatformException implements Exception {
/// [message], and with the optional error [details] which must be a valid
/// [message], and with the optional error [details] which must be a valid
/// value for the [MethodCodec] involved in the interaction.
/// value for the [MethodCodec] involved in the interaction.
PlatformException
({
PlatformException
({
@
required
this
.
code
,
required
this
.
code
,
this
.
message
,
this
.
message
,
this
.
details
,
this
.
details
,
})
:
assert
(
code
!=
null
);
})
:
assert
(
code
!=
null
);
...
@@ -114,7 +113,7 @@ class PlatformException implements Exception {
...
@@ -114,7 +113,7 @@ class PlatformException implements Exception {
final
String
code
;
final
String
code
;
/// A human-readable error message, possibly null.
/// A human-readable error message, possibly null.
final
String
message
;
final
String
?
message
;
/// Error details, possibly null.
/// Error details, possibly null.
final
dynamic
details
;
final
dynamic
details
;
...
@@ -139,7 +138,7 @@ class MissingPluginException implements Exception {
...
@@ -139,7 +138,7 @@ class MissingPluginException implements Exception {
MissingPluginException
([
this
.
message
]);
MissingPluginException
([
this
.
message
]);
/// A human-readable error message, possibly null.
/// A human-readable error message, possibly null.
final
String
message
;
final
String
?
message
;
@override
@override
String
toString
()
=>
'MissingPluginException(
$message
)'
;
String
toString
()
=>
'MissingPluginException(
$message
)'
;
...
...
packages/flutter/lib/src/services/message_codecs.dart
View file @
7884420a
...
@@ -2,12 +2,11 @@
...
@@ -2,12 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'dart:convert'
;
import
'dart:convert'
;
import
'dart:typed_data'
;
import
'dart:typed_data'
;
import
'package:flutter/foundation.dart'
show
ReadBuffer
,
WriteBuffer
,
required
;
import
'package:flutter/foundation.dart'
show
ReadBuffer
,
WriteBuffer
;
import
'message_codec.dart'
;
import
'message_codec.dart'
;
...
@@ -19,35 +18,35 @@ import 'message_codec.dart';
...
@@ -19,35 +18,35 @@ import 'message_codec.dart';
/// When sending outgoing messages from Android, be sure to use direct `ByteBuffer`
/// When sending outgoing messages from Android, be sure to use direct `ByteBuffer`
/// as opposed to indirect. The `wrap()` API provides indirect buffers by default
/// as opposed to indirect. The `wrap()` API provides indirect buffers by default
/// and you will get empty `ByteData` objects in Dart.
/// and you will get empty `ByteData` objects in Dart.
class
BinaryCodec
implements
MessageCodec
<
ByteData
>
{
class
BinaryCodec
implements
MessageCodec
<
ByteData
?
>
{
/// Creates a [MessageCodec] with unencoded binary messages represented using
/// Creates a [MessageCodec] with unencoded binary messages represented using
/// [ByteData].
/// [ByteData].
const
BinaryCodec
();
const
BinaryCodec
();
@override
@override
ByteData
decodeMessage
(
ByteData
message
)
=>
message
;
ByteData
?
decodeMessage
(
ByteData
?
message
)
=>
message
;
@override
@override
ByteData
encodeMessage
(
ByteData
message
)
=>
message
;
ByteData
?
encodeMessage
(
ByteData
?
message
)
=>
message
;
}
}
/// [MessageCodec] with UTF-8 encoded String messages.
/// [MessageCodec] with UTF-8 encoded String messages.
///
///
/// On Android, messages will be represented using `java.util.String`.
/// On Android, messages will be represented using `java.util.String`.
/// On iOS, messages will be represented using `NSString`.
/// On iOS, messages will be represented using `NSString`.
class
StringCodec
implements
MessageCodec
<
String
>
{
class
StringCodec
implements
MessageCodec
<
String
?
>
{
/// Creates a [MessageCodec] with UTF-8 encoded String messages.
/// Creates a [MessageCodec] with UTF-8 encoded String messages.
const
StringCodec
();
const
StringCodec
();
@override
@override
String
decodeMessage
(
ByteData
message
)
{
String
?
decodeMessage
(
ByteData
?
message
)
{
if
(
message
==
null
)
if
(
message
==
null
)
return
null
;
return
null
;
return
utf8
.
decoder
.
convert
(
message
.
buffer
.
asUint8List
(
message
.
offsetInBytes
,
message
.
lengthInBytes
));
return
utf8
.
decoder
.
convert
(
message
.
buffer
.
asUint8List
(
message
.
offsetInBytes
,
message
.
lengthInBytes
));
}
}
@override
@override
ByteData
encodeMessage
(
String
message
)
{
ByteData
?
encodeMessage
(
String
?
message
)
{
if
(
message
==
null
)
if
(
message
==
null
)
return
null
;
return
null
;
final
Uint8List
encoded
=
utf8
.
encoder
.
convert
(
message
);
final
Uint8List
encoded
=
utf8
.
encoder
.
convert
(
message
);
...
@@ -82,17 +81,17 @@ class JSONMessageCodec implements MessageCodec<dynamic> {
...
@@ -82,17 +81,17 @@ class JSONMessageCodec implements MessageCodec<dynamic> {
const
JSONMessageCodec
();
const
JSONMessageCodec
();
@override
@override
ByteData
encodeMessage
(
dynamic
message
)
{
ByteData
?
encodeMessage
(
dynamic
message
)
{
if
(
message
==
null
)
if
(
message
==
null
)
return
null
;
return
null
;
return
const
StringCodec
().
encodeMessage
(
json
.
encode
(
message
));
return
const
StringCodec
().
encodeMessage
(
json
.
encode
(
message
));
}
}
@override
@override
dynamic
decodeMessage
(
ByteData
message
)
{
dynamic
decodeMessage
(
ByteData
?
message
)
{
if
(
message
==
null
)
if
(
message
==
null
)
return
message
;
return
message
;
return
json
.
decode
(
const
StringCodec
().
decodeMessage
(
message
));
return
json
.
decode
(
const
StringCodec
().
decodeMessage
(
message
)
!
);
}
}
}
}
...
@@ -123,11 +122,11 @@ class JSONMethodCodec implements MethodCodec {
...
@@ -123,11 +122,11 @@ class JSONMethodCodec implements MethodCodec {
return
const
JSONMessageCodec
().
encodeMessage
(<
String
,
dynamic
>{
return
const
JSONMessageCodec
().
encodeMessage
(<
String
,
dynamic
>{
'method'
:
call
.
method
,
'method'
:
call
.
method
,
'args'
:
call
.
arguments
,
'args'
:
call
.
arguments
,
});
})
!
;
}
}
@override
@override
MethodCall
decodeMethodCall
(
ByteData
methodCall
)
{
MethodCall
decodeMethodCall
(
ByteData
?
methodCall
)
{
final
dynamic
decoded
=
const
JSONMessageCodec
().
decodeMessage
(
methodCall
);
final
dynamic
decoded
=
const
JSONMessageCodec
().
decodeMessage
(
methodCall
);
if
(
decoded
is
!
Map
)
if
(
decoded
is
!
Map
)
throw
FormatException
(
'Expected method call Map, got
$decoded
'
);
throw
FormatException
(
'Expected method call Map, got
$decoded
'
);
...
@@ -158,13 +157,13 @@ class JSONMethodCodec implements MethodCodec {
...
@@ -158,13 +157,13 @@ class JSONMethodCodec implements MethodCodec {
@override
@override
ByteData
encodeSuccessEnvelope
(
dynamic
result
)
{
ByteData
encodeSuccessEnvelope
(
dynamic
result
)
{
return
const
JSONMessageCodec
().
encodeMessage
(<
dynamic
>[
result
]);
return
const
JSONMessageCodec
().
encodeMessage
(<
dynamic
>[
result
])
!
;
}
}
@override
@override
ByteData
encodeErrorEnvelope
({
@required
String
code
,
String
message
,
dynamic
details
})
{
ByteData
encodeErrorEnvelope
({
required
String
code
,
String
?
message
,
dynamic
details
})
{
assert
(
code
!=
null
);
assert
(
code
!=
null
);
return
const
JSONMessageCodec
().
encodeMessage
(<
dynamic
>[
code
,
message
,
details
]);
return
const
JSONMessageCodec
().
encodeMessage
(<
dynamic
>[
code
,
message
,
details
])
!
;
}
}
}
}
...
@@ -281,7 +280,7 @@ class StandardMessageCodec implements MessageCodec<dynamic> {
...
@@ -281,7 +280,7 @@ class StandardMessageCodec implements MessageCodec<dynamic> {
static
const
int
_valueMap
=
13
;
static
const
int
_valueMap
=
13
;
@override
@override
ByteData
encodeMessage
(
dynamic
message
)
{
ByteData
?
encodeMessage
(
dynamic
message
)
{
if
(
message
==
null
)
if
(
message
==
null
)
return
null
;
return
null
;
final
WriteBuffer
buffer
=
WriteBuffer
();
final
WriteBuffer
buffer
=
WriteBuffer
();
...
@@ -290,7 +289,7 @@ class StandardMessageCodec implements MessageCodec<dynamic> {
...
@@ -290,7 +289,7 @@ class StandardMessageCodec implements MessageCodec<dynamic> {
}
}
@override
@override
dynamic
decodeMessage
(
ByteData
message
)
{
dynamic
decodeMessage
(
ByteData
?
message
)
{
if
(
message
==
null
)
if
(
message
==
null
)
return
null
;
return
null
;
final
ReadBuffer
buffer
=
ReadBuffer
(
message
);
final
ReadBuffer
buffer
=
ReadBuffer
(
message
);
...
@@ -444,7 +443,7 @@ class StandardMessageCodec implements MessageCodec<dynamic> {
...
@@ -444,7 +443,7 @@ class StandardMessageCodec implements MessageCodec<dynamic> {
return
buffer
.
getFloat64List
(
length
);
return
buffer
.
getFloat64List
(
length
);
case
_valueList:
case
_valueList:
final
int
length
=
readSize
(
buffer
);
final
int
length
=
readSize
(
buffer
);
final
dynamic
result
=
List
<
dynamic
>
(
length
);
final
dynamic
result
=
List
<
dynamic
>
.
filled
(
length
,
null
,
growable:
false
);
for
(
int
i
=
0
;
i
<
length
;
i
++)
for
(
int
i
=
0
;
i
<
length
;
i
++)
result
[
i
]
=
readValue
(
buffer
);
result
[
i
]
=
readValue
(
buffer
);
return
result
;
return
result
;
...
@@ -529,8 +528,8 @@ class StandardMethodCodec implements MethodCodec {
...
@@ -529,8 +528,8 @@ class StandardMethodCodec implements MethodCodec {
}
}
@override
@override
MethodCall
decodeMethodCall
(
ByteData
methodCall
)
{
MethodCall
decodeMethodCall
(
ByteData
?
methodCall
)
{
final
ReadBuffer
buffer
=
ReadBuffer
(
methodCall
);
final
ReadBuffer
buffer
=
ReadBuffer
(
methodCall
!
);
final
dynamic
method
=
messageCodec
.
readValue
(
buffer
);
final
dynamic
method
=
messageCodec
.
readValue
(
buffer
);
final
dynamic
arguments
=
messageCodec
.
readValue
(
buffer
);
final
dynamic
arguments
=
messageCodec
.
readValue
(
buffer
);
if
(
method
is
String
&&
!
buffer
.
hasRemaining
)
if
(
method
is
String
&&
!
buffer
.
hasRemaining
)
...
@@ -548,7 +547,7 @@ class StandardMethodCodec implements MethodCodec {
...
@@ -548,7 +547,7 @@ class StandardMethodCodec implements MethodCodec {
}
}
@override
@override
ByteData
encodeErrorEnvelope
({
@required
String
code
,
String
message
,
dynamic
details
})
{
ByteData
encodeErrorEnvelope
({
required
String
code
,
String
?
message
,
dynamic
details
})
{
final
WriteBuffer
buffer
=
WriteBuffer
();
final
WriteBuffer
buffer
=
WriteBuffer
();
buffer
.
putUint8
(
1
);
buffer
.
putUint8
(
1
);
messageCodec
.
writeValue
(
buffer
,
code
);
messageCodec
.
writeValue
(
buffer
,
code
);
...
...
packages/flutter/lib/src/services/platform_channel.dart
View file @
7884420a
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'dart:async'
;
import
'dart:async'
;
import
'dart:typed_data'
;
import
'dart:typed_data'
;
...
@@ -36,7 +35,7 @@ class BasicMessageChannel<T> {
...
@@ -36,7 +35,7 @@ class BasicMessageChannel<T> {
///
///
/// The [name] and [codec] arguments cannot be null. The default [ServicesBinding.defaultBinaryMessenger]
/// The [name] and [codec] arguments cannot be null. The default [ServicesBinding.defaultBinaryMessenger]
/// instance is used if [binaryMessenger] is null.
/// instance is used if [binaryMessenger] is null.
const
BasicMessageChannel
(
this
.
name
,
this
.
codec
,
{
BinaryMessenger
binaryMessenger
})
const
BasicMessageChannel
(
this
.
name
,
this
.
codec
,
{
BinaryMessenger
?
binaryMessenger
})
:
assert
(
name
!=
null
),
:
assert
(
name
!=
null
),
assert
(
codec
!=
null
),
assert
(
codec
!=
null
),
_binaryMessenger
=
binaryMessenger
;
_binaryMessenger
=
binaryMessenger
;
...
@@ -49,7 +48,7 @@ class BasicMessageChannel<T> {
...
@@ -49,7 +48,7 @@ class BasicMessageChannel<T> {
/// The messenger which sends the bytes for this channel, not null.
/// The messenger which sends the bytes for this channel, not null.
BinaryMessenger
get
binaryMessenger
=>
_binaryMessenger
??
defaultBinaryMessenger
;
BinaryMessenger
get
binaryMessenger
=>
_binaryMessenger
??
defaultBinaryMessenger
;
final
BinaryMessenger
_binaryMessenger
;
final
BinaryMessenger
?
_binaryMessenger
;
/// Sends the specified [message] to the platform plugins on this channel.
/// Sends the specified [message] to the platform plugins on this channel.
///
///
...
@@ -72,7 +71,7 @@ class BasicMessageChannel<T> {
...
@@ -72,7 +71,7 @@ class BasicMessageChannel<T> {
if
(
handler
==
null
)
{
if
(
handler
==
null
)
{
binaryMessenger
.
setMessageHandler
(
name
,
null
);
binaryMessenger
.
setMessageHandler
(
name
,
null
);
}
else
{
}
else
{
binaryMessenger
.
setMessageHandler
(
name
,
(
ByteData
message
)
async
{
binaryMessenger
.
setMessageHandler
(
name
,
(
ByteData
?
message
)
async
{
return
codec
.
encodeMessage
(
await
handler
(
codec
.
decodeMessage
(
message
)));
return
codec
.
encodeMessage
(
await
handler
(
codec
.
decodeMessage
(
message
)));
});
});
}
}
...
@@ -93,7 +92,7 @@ class BasicMessageChannel<T> {
...
@@ -93,7 +92,7 @@ class BasicMessageChannel<T> {
if
(
handler
==
null
)
{
if
(
handler
==
null
)
{
binaryMessenger
.
setMockMessageHandler
(
name
,
null
);
binaryMessenger
.
setMockMessageHandler
(
name
,
null
);
}
else
{
}
else
{
binaryMessenger
.
setMockMessageHandler
(
name
,
(
ByteData
message
)
async
{
binaryMessenger
.
setMockMessageHandler
(
name
,
(
ByteData
?
message
)
async
{
return
codec
.
encodeMessage
(
await
handler
(
codec
.
decodeMessage
(
message
)));
return
codec
.
encodeMessage
(
await
handler
(
codec
.
decodeMessage
(
message
)));
});
});
}
}
...
@@ -128,7 +127,7 @@ class MethodChannel {
...
@@ -128,7 +127,7 @@ class MethodChannel {
///
///
/// The [name] and [codec] arguments cannot be null. The default [ServicesBinding.defaultBinaryMessenger]
/// The [name] and [codec] arguments cannot be null. The default [ServicesBinding.defaultBinaryMessenger]
/// instance is used if [binaryMessenger] is null.
/// instance is used if [binaryMessenger] is null.
const
MethodChannel
(
this
.
name
,
[
this
.
codec
=
const
StandardMethodCodec
(),
BinaryMessenger
binaryMessenger
])
const
MethodChannel
(
this
.
name
,
[
this
.
codec
=
const
StandardMethodCodec
(),
BinaryMessenger
?
binaryMessenger
])
:
assert
(
name
!=
null
),
:
assert
(
name
!=
null
),
assert
(
codec
!=
null
),
assert
(
codec
!=
null
),
_binaryMessenger
=
binaryMessenger
;
_binaryMessenger
=
binaryMessenger
;
...
@@ -143,12 +142,12 @@ class MethodChannel {
...
@@ -143,12 +142,12 @@ class MethodChannel {
///
///
/// The messenger may not be null.
/// The messenger may not be null.
BinaryMessenger
get
binaryMessenger
=>
_binaryMessenger
??
defaultBinaryMessenger
;
BinaryMessenger
get
binaryMessenger
=>
_binaryMessenger
??
defaultBinaryMessenger
;
final
BinaryMessenger
_binaryMessenger
;
final
BinaryMessenger
?
_binaryMessenger
;
@optionalTypeArgs
@optionalTypeArgs
Future
<
T
>
_invokeMethod
<
T
>(
String
method
,
{
bool
missingOk
,
dynamic
arguments
})
async
{
Future
<
T
?>
_invokeMethod
<
T
>(
String
method
,
{
required
bool
missingOk
,
dynamic
arguments
})
async
{
assert
(
method
!=
null
);
assert
(
method
!=
null
);
final
ByteData
result
=
await
binaryMessenger
.
send
(
final
ByteData
?
result
=
await
binaryMessenger
.
send
(
name
,
name
,
codec
.
encodeMethodCall
(
MethodCall
(
method
,
arguments
)),
codec
.
encodeMethodCall
(
MethodCall
(
method
,
arguments
)),
);
);
...
@@ -330,7 +329,7 @@ class MethodChannel {
...
@@ -330,7 +329,7 @@ class MethodChannel {
/// * <https://api.flutter.dev/javadoc/io/flutter/plugin/common/MethodCall.html>
/// * <https://api.flutter.dev/javadoc/io/flutter/plugin/common/MethodCall.html>
/// for how to access method call arguments on Android.
/// for how to access method call arguments on Android.
@optionalTypeArgs
@optionalTypeArgs
Future
<
T
>
invokeMethod
<
T
>(
String
method
,
[
dynamic
arguments
])
{
Future
<
T
?
>
invokeMethod
<
T
>(
String
method
,
[
dynamic
arguments
])
{
return
_invokeMethod
<
T
>(
method
,
missingOk:
false
,
arguments:
arguments
);
return
_invokeMethod
<
T
>(
method
,
missingOk:
false
,
arguments:
arguments
);
}
}
...
@@ -343,8 +342,8 @@ class MethodChannel {
...
@@ -343,8 +342,8 @@ class MethodChannel {
/// See also:
/// See also:
///
///
/// * [invokeMethod], which this call delegates to.
/// * [invokeMethod], which this call delegates to.
Future
<
List
<
T
>>
invokeListMethod
<
T
>(
String
method
,
[
dynamic
arguments
])
async
{
Future
<
List
<
T
>
?
>
invokeListMethod
<
T
>(
String
method
,
[
dynamic
arguments
])
async
{
final
List
<
dynamic
>
result
=
await
invokeMethod
<
List
<
dynamic
>
>(
method
,
arguments
);
final
List
<
dynamic
>
?
result
=
await
invokeMethod
<
List
<
dynamic
>?
>(
method
,
arguments
);
return
result
?.
cast
<
T
>();
return
result
?.
cast
<
T
>();
}
}
...
@@ -357,8 +356,8 @@ class MethodChannel {
...
@@ -357,8 +356,8 @@ class MethodChannel {
/// See also:
/// See also:
///
///
/// * [invokeMethod], which this call delegates to.
/// * [invokeMethod], which this call delegates to.
Future
<
Map
<
K
,
V
>>
invokeMapMethod
<
K
,
V
>(
String
method
,
[
dynamic
arguments
])
async
{
Future
<
Map
<
K
,
V
>
?
>
invokeMapMethod
<
K
,
V
>(
String
method
,
[
dynamic
arguments
])
async
{
final
Map
<
dynamic
,
dynamic
>
result
=
await
invokeMethod
<
Map
<
dynamic
,
dynamic
>
>(
method
,
arguments
);
final
Map
<
dynamic
,
dynamic
>
?
result
=
await
invokeMethod
<
Map
<
dynamic
,
dynamic
>?
>(
method
,
arguments
);
return
result
?.
cast
<
K
,
V
>();
return
result
?.
cast
<
K
,
V
>();
}
}
...
@@ -376,13 +375,13 @@ class MethodChannel {
...
@@ -376,13 +375,13 @@ class MethodChannel {
/// completes with a [MissingPluginException], an empty reply is sent
/// completes with a [MissingPluginException], an empty reply is sent
/// similarly to what happens if no method call handler has been set.
/// similarly to what happens if no method call handler has been set.
/// Any other exception results in an error envelope being sent.
/// Any other exception results in an error envelope being sent.
void
setMethodCallHandler
(
Future
<
dynamic
>
handler
(
MethodCall
call
)
)
{
void
setMethodCallHandler
(
Future
<
dynamic
>
Function
(
MethodCall
call
)?
handler
)
{
_methodChannelHandlers
[
this
]
=
handler
;
_methodChannelHandlers
[
this
]
=
handler
;
binaryMessenger
.
setMessageHandler
(
binaryMessenger
.
setMessageHandler
(
name
,
name
,
handler
==
null
handler
==
null
?
null
?
null
:
(
ByteData
message
)
=>
_handleAsMethodCall
(
message
,
handler
),
:
(
ByteData
?
message
)
=>
_handleAsMethodCall
(
message
,
handler
),
);
);
}
}
...
@@ -415,7 +414,7 @@ class MethodChannel {
...
@@ -415,7 +414,7 @@ class MethodChannel {
_methodChannelMockHandlers
[
this
]
=
handler
;
_methodChannelMockHandlers
[
this
]
=
handler
;
binaryMessenger
.
setMockMessageHandler
(
binaryMessenger
.
setMockMessageHandler
(
name
,
name
,
handler
==
null
?
null
:
(
ByteData
message
)
=>
_handleAsMethodCall
(
message
,
handler
),
handler
==
null
?
null
:
(
ByteData
?
message
)
=>
_handleAsMethodCall
(
message
,
handler
),
);
);
}
}
...
@@ -426,7 +425,7 @@ class MethodChannel {
...
@@ -426,7 +425,7 @@ class MethodChannel {
/// handler for the specified channel has not been altered by a previous test.
/// handler for the specified channel has not been altered by a previous test.
bool
checkMockMethodCallHandler
(
Future
<
dynamic
>
handler
(
MethodCall
call
))
=>
_methodChannelMockHandlers
[
this
]
==
handler
;
bool
checkMockMethodCallHandler
(
Future
<
dynamic
>
handler
(
MethodCall
call
))
=>
_methodChannelMockHandlers
[
this
]
==
handler
;
Future
<
ByteData
>
_handleAsMethodCall
(
ByteData
message
,
Future
<
dynamic
>
handler
(
MethodCall
call
))
async
{
Future
<
ByteData
?>
_handleAsMethodCall
(
ByteData
?
message
,
Future
<
dynamic
>
handler
(
MethodCall
call
))
async
{
final
MethodCall
call
=
codec
.
decodeMethodCall
(
message
);
final
MethodCall
call
=
codec
.
decodeMethodCall
(
message
);
try
{
try
{
return
codec
.
encodeSuccessEnvelope
(
await
handler
(
call
));
return
codec
.
encodeSuccessEnvelope
(
await
handler
(
call
));
...
@@ -454,20 +453,20 @@ class OptionalMethodChannel extends MethodChannel {
...
@@ -454,20 +453,20 @@ class OptionalMethodChannel extends MethodChannel {
:
super
(
name
,
codec
);
:
super
(
name
,
codec
);
@override
@override
Future
<
T
>
invokeMethod
<
T
>(
String
method
,
[
dynamic
arguments
])
async
{
Future
<
T
?
>
invokeMethod
<
T
>(
String
method
,
[
dynamic
arguments
])
async
{
return
super
.
_invokeMethod
<
T
>(
method
,
missingOk:
true
,
arguments:
arguments
);
return
super
.
_invokeMethod
<
T
>(
method
,
missingOk:
true
,
arguments:
arguments
);
}
}
@override
@override
Future
<
List
<
T
>>
invokeListMethod
<
T
>(
String
method
,
[
dynamic
arguments
])
async
{
Future
<
List
<
T
>
?
>
invokeListMethod
<
T
>(
String
method
,
[
dynamic
arguments
])
async
{
final
List
<
dynamic
>
result
=
await
invokeMethod
<
List
<
dynamic
>>(
method
,
arguments
);
final
List
<
dynamic
>
?
result
=
await
invokeMethod
<
List
<
dynamic
>>(
method
,
arguments
);
return
result
.
cast
<
T
>();
return
result
?
.
cast
<
T
>();
}
}
@override
@override
Future
<
Map
<
K
,
V
>>
invokeMapMethod
<
K
,
V
>(
String
method
,
[
dynamic
arguments
])
async
{
Future
<
Map
<
K
,
V
>
?
>
invokeMapMethod
<
K
,
V
>(
String
method
,
[
dynamic
arguments
])
async
{
final
Map
<
dynamic
,
dynamic
>
result
=
await
invokeMethod
<
Map
<
dynamic
,
dynamic
>>(
method
,
arguments
);
final
Map
<
dynamic
,
dynamic
>
?
result
=
await
invokeMethod
<
Map
<
dynamic
,
dynamic
>>(
method
,
arguments
);
return
result
.
cast
<
K
,
V
>();
return
result
?
.
cast
<
K
,
V
>();
}
}
}
}
...
@@ -494,7 +493,7 @@ class EventChannel {
...
@@ -494,7 +493,7 @@ class EventChannel {
///
///
/// Neither [name] nor [codec] may be null. The default [ServicesBinding.defaultBinaryMessenger]
/// Neither [name] nor [codec] may be null. The default [ServicesBinding.defaultBinaryMessenger]
/// instance is used if [binaryMessenger] is null.
/// instance is used if [binaryMessenger] is null.
const
EventChannel
(
this
.
name
,
[
this
.
codec
=
const
StandardMethodCodec
(),
BinaryMessenger
binaryMessenger
])
const
EventChannel
(
this
.
name
,
[
this
.
codec
=
const
StandardMethodCodec
(),
BinaryMessenger
?
binaryMessenger
])
:
assert
(
name
!=
null
),
:
assert
(
name
!=
null
),
assert
(
codec
!=
null
),
assert
(
codec
!=
null
),
_binaryMessenger
=
binaryMessenger
;
_binaryMessenger
=
binaryMessenger
;
...
@@ -507,7 +506,7 @@ class EventChannel {
...
@@ -507,7 +506,7 @@ class EventChannel {
/// The messenger used by this channel to send platform messages, not null.
/// The messenger used by this channel to send platform messages, not null.
BinaryMessenger
get
binaryMessenger
=>
_binaryMessenger
??
defaultBinaryMessenger
;
BinaryMessenger
get
binaryMessenger
=>
_binaryMessenger
??
defaultBinaryMessenger
;
final
BinaryMessenger
_binaryMessenger
;
final
BinaryMessenger
?
_binaryMessenger
;
/// Sets up a broadcast stream for receiving events on this channel.
/// Sets up a broadcast stream for receiving events on this channel.
///
///
...
@@ -524,9 +523,9 @@ class EventChannel {
...
@@ -524,9 +523,9 @@ class EventChannel {
/// only when stream listener count changes from 1 to 0.
/// only when stream listener count changes from 1 to 0.
Stream
<
dynamic
>
receiveBroadcastStream
([
dynamic
arguments
])
{
Stream
<
dynamic
>
receiveBroadcastStream
([
dynamic
arguments
])
{
final
MethodChannel
methodChannel
=
MethodChannel
(
name
,
codec
);
final
MethodChannel
methodChannel
=
MethodChannel
(
name
,
codec
);
StreamController
<
dynamic
>
controller
;
late
StreamController
<
dynamic
>
controller
;
controller
=
StreamController
<
dynamic
>.
broadcast
(
onListen:
()
async
{
controller
=
StreamController
<
dynamic
>.
broadcast
(
onListen:
()
async
{
binaryMessenger
.
setMessageHandler
(
name
,
(
ByteData
reply
)
async
{
binaryMessenger
.
setMessageHandler
(
name
,
(
ByteData
?
reply
)
async
{
if
(
reply
==
null
)
{
if
(
reply
==
null
)
{
controller
.
close
();
controller
.
close
();
}
else
{
}
else
{
...
...
packages/flutter/lib/src/services/platform_messages.dart
View file @
7884420a
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'dart:async'
;
import
'dart:async'
;
import
'dart:typed_data'
;
import
'dart:typed_data'
;
...
@@ -67,7 +66,7 @@ class BinaryMessages {
...
@@ -67,7 +66,7 @@ class BinaryMessages {
'Use defaultBinaryMessenger.send instead. '
'Use defaultBinaryMessenger.send instead. '
'This feature was deprecated after v1.6.5.'
'This feature was deprecated after v1.6.5.'
)
)
static
Future
<
ByteData
>
send
(
String
channel
,
ByteData
message
)
{
static
Future
<
ByteData
?>
send
(
String
channel
,
ByteData
?
message
)
{
return
_binaryMessenger
.
send
(
channel
,
message
);
return
_binaryMessenger
.
send
(
channel
,
message
);
}
}
...
@@ -83,7 +82,7 @@ class BinaryMessages {
...
@@ -83,7 +82,7 @@ class BinaryMessages {
'Use defaultBinaryMessenger.setMessageHandler instead. '
'Use defaultBinaryMessenger.setMessageHandler instead. '
'This feature was deprecated after v1.6.5.'
'This feature was deprecated after v1.6.5.'
)
)
static
void
setMessageHandler
(
String
channel
,
Future
<
ByteData
>
handler
(
ByteData
message
)
)
{
static
void
setMessageHandler
(
String
channel
,
Future
<
ByteData
?>
Function
(
ByteData
?
message
)
handler
)
{
_binaryMessenger
.
setMessageHandler
(
channel
,
handler
);
_binaryMessenger
.
setMessageHandler
(
channel
,
handler
);
}
}
...
@@ -102,7 +101,7 @@ class BinaryMessages {
...
@@ -102,7 +101,7 @@ class BinaryMessages {
'Use defaultBinaryMessenger.setMockMessageHandler instead. '
'Use defaultBinaryMessenger.setMockMessageHandler instead. '
'This feature was deprecated after v1.6.5.'
'This feature was deprecated after v1.6.5.'
)
)
static
void
setMockMessageHandler
(
String
channel
,
Future
<
ByteData
>
handler
(
ByteData
message
)
)
{
static
void
setMockMessageHandler
(
String
channel
,
Future
<
ByteData
?>
Function
(
ByteData
?
message
)
handler
)
{
_binaryMessenger
.
setMockMessageHandler
(
channel
,
handler
);
_binaryMessenger
.
setMockMessageHandler
(
channel
,
handler
);
}
}
}
}
packages/flutter/lib/src/services/platform_views.dart
View file @
7884420a
This diff is collapsed.
Click to expand it.
packages/flutter/lib/src/services/raw_keyboard.dart
View file @
7884420a
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'dart:async'
;
import
'dart:async'
;
import
'dart:io'
;
import
'dart:io'
;
...
@@ -138,7 +137,7 @@ abstract class RawKeyEventData {
...
@@ -138,7 +137,7 @@ abstract class RawKeyEventData {
/// null. If the given key only appears in one place on the keyboard, returns
/// null. If the given key only appears in one place on the keyboard, returns
/// [KeyboardSide.all] if pressed. Never returns [KeyboardSide.any], because
/// [KeyboardSide.all] if pressed. Never returns [KeyboardSide.any], because
/// that doesn't make sense in this context.
/// that doesn't make sense in this context.
KeyboardSide
getModifierSide
(
ModifierKey
key
);
KeyboardSide
?
getModifierSide
(
ModifierKey
key
);
/// Returns true if a CTRL modifier key was pressed at the time of this event,
/// Returns true if a CTRL modifier key was pressed at the time of this event,
/// regardless of which side of the keyboard it is on.
/// regardless of which side of the keyboard it is on.
...
@@ -166,8 +165,8 @@ abstract class RawKeyEventData {
...
@@ -166,8 +165,8 @@ abstract class RawKeyEventData {
/// Returns a map of modifier keys that were pressed at the time of this
/// Returns a map of modifier keys that were pressed at the time of this
/// event, and the keyboard side or sides that the key was on.
/// event, and the keyboard side or sides that the key was on.
Map
<
ModifierKey
,
KeyboardSide
>
get
modifiersPressed
{
Map
<
ModifierKey
,
KeyboardSide
?
>
get
modifiersPressed
{
final
Map
<
ModifierKey
,
KeyboardSide
>
result
=
<
ModifierKey
,
KeyboardSide
>{};
final
Map
<
ModifierKey
,
KeyboardSide
?>
result
=
<
ModifierKey
,
KeyboardSide
?
>{};
for
(
final
ModifierKey
key
in
ModifierKey
.
values
)
{
for
(
final
ModifierKey
key
in
ModifierKey
.
values
)
{
if
(
isModifierPressed
(
key
))
{
if
(
isModifierPressed
(
key
))
{
result
[
key
]
=
getModifierSide
(
key
);
result
[
key
]
=
getModifierSide
(
key
);
...
@@ -212,7 +211,7 @@ abstract class RawKeyEventData {
...
@@ -212,7 +211,7 @@ abstract class RawKeyEventData {
/// complexities of managing keyboard input, like showing a soft keyboard or
/// complexities of managing keyboard input, like showing a soft keyboard or
/// interacting with an input method editor (IME).
/// interacting with an input method editor (IME).
/// {@endtemplate}
/// {@endtemplate}
String
get
keyLabel
;
String
?
get
keyLabel
;
}
}
/// Defines the interface for raw key events.
/// Defines the interface for raw key events.
...
@@ -243,7 +242,7 @@ abstract class RawKeyEvent with Diagnosticable {
...
@@ -243,7 +242,7 @@ abstract class RawKeyEvent with Diagnosticable {
/// Initializes fields for subclasses, and provides a const constructor for
/// Initializes fields for subclasses, and provides a const constructor for
/// const subclasses.
/// const subclasses.
const
RawKeyEvent
({
const
RawKeyEvent
({
@
required
this
.
data
,
required
this
.
data
,
this
.
character
,
this
.
character
,
});
});
...
@@ -256,40 +255,40 @@ abstract class RawKeyEvent with Diagnosticable {
...
@@ -256,40 +255,40 @@ abstract class RawKeyEvent with Diagnosticable {
switch
(
keymap
)
{
switch
(
keymap
)
{
case
'android'
:
case
'android'
:
data
=
RawKeyEventDataAndroid
(
data
=
RawKeyEventDataAndroid
(
flags:
message
[
'flags'
]
as
int
??
0
,
flags:
message
[
'flags'
]
as
int
?
??
0
,
codePoint:
message
[
'codePoint'
]
as
int
??
0
,
codePoint:
message
[
'codePoint'
]
as
int
?
??
0
,
keyCode:
message
[
'keyCode'
]
as
int
??
0
,
keyCode:
message
[
'keyCode'
]
as
int
?
??
0
,
plainCodePoint:
message
[
'plainCodePoint'
]
as
int
??
0
,
plainCodePoint:
message
[
'plainCodePoint'
]
as
int
?
??
0
,
scanCode:
message
[
'scanCode'
]
as
int
??
0
,
scanCode:
message
[
'scanCode'
]
as
int
?
??
0
,
metaState:
message
[
'metaState'
]
as
int
??
0
,
metaState:
message
[
'metaState'
]
as
int
?
??
0
,
eventSource:
message
[
'source'
]
as
int
??
0
,
eventSource:
message
[
'source'
]
as
int
?
??
0
,
vendorId:
message
[
'vendorId'
]
as
int
??
0
,
vendorId:
message
[
'vendorId'
]
as
int
?
??
0
,
productId:
message
[
'productId'
]
as
int
??
0
,
productId:
message
[
'productId'
]
as
int
?
??
0
,
deviceId:
message
[
'deviceId'
]
as
int
??
0
,
deviceId:
message
[
'deviceId'
]
as
int
?
??
0
,
repeatCount:
message
[
'repeatCount'
]
as
int
??
0
,
repeatCount:
message
[
'repeatCount'
]
as
int
?
??
0
,
);
);
break
;
break
;
case
'fuchsia'
:
case
'fuchsia'
:
data
=
RawKeyEventDataFuchsia
(
data
=
RawKeyEventDataFuchsia
(
hidUsage:
message
[
'hidUsage'
]
as
int
??
0
,
hidUsage:
message
[
'hidUsage'
]
as
int
?
??
0
,
codePoint:
message
[
'codePoint'
]
as
int
??
0
,
codePoint:
message
[
'codePoint'
]
as
int
?
??
0
,
modifiers:
message
[
'modifiers'
]
as
int
??
0
,
modifiers:
message
[
'modifiers'
]
as
int
?
??
0
,
);
);
break
;
break
;
case
'macos'
:
case
'macos'
:
data
=
RawKeyEventDataMacOs
(
data
=
RawKeyEventDataMacOs
(
characters:
message
[
'characters'
]
as
String
??
''
,
characters:
message
[
'characters'
]
as
String
?
??
''
,
charactersIgnoringModifiers:
message
[
'charactersIgnoringModifiers'
]
as
String
??
''
,
charactersIgnoringModifiers:
message
[
'charactersIgnoringModifiers'
]
as
String
?
??
''
,
keyCode:
message
[
'keyCode'
]
as
int
??
0
,
keyCode:
message
[
'keyCode'
]
as
int
?
??
0
,
modifiers:
message
[
'modifiers'
]
as
int
??
0
);
modifiers:
message
[
'modifiers'
]
as
int
?
??
0
);
break
;
break
;
case
'linux'
:
case
'linux'
:
data
=
RawKeyEventDataLinux
(
data
=
RawKeyEventDataLinux
(
keyHelper:
KeyHelper
(
message
[
'toolkit'
]
as
String
??
''
),
keyHelper:
KeyHelper
(
message
[
'toolkit'
]
as
String
?
??
''
),
unicodeScalarValues:
message
[
'unicodeScalarValues'
]
as
int
??
0
,
unicodeScalarValues:
message
[
'unicodeScalarValues'
]
as
int
?
??
0
,
keyCode:
message
[
'keyCode'
]
as
int
??
0
,
keyCode:
message
[
'keyCode'
]
as
int
?
??
0
,
scanCode:
message
[
'scanCode'
]
as
int
??
0
,
scanCode:
message
[
'scanCode'
]
as
int
?
??
0
,
modifiers:
message
[
'modifiers'
]
as
int
??
0
,
modifiers:
message
[
'modifiers'
]
as
int
?
??
0
,
isDown:
message
[
'type'
]
==
'keydown'
);
isDown:
message
[
'type'
]
==
'keydown'
);
break
;
break
;
case
'web'
:
case
'web'
:
...
@@ -428,7 +427,7 @@ abstract class RawKeyEvent with Diagnosticable {
...
@@ -428,7 +427,7 @@ abstract class RawKeyEvent with Diagnosticable {
/// composing text, use the [TextField] or [CupertinoTextField] widgets, since
/// composing text, use the [TextField] or [CupertinoTextField] widgets, since
/// those automatically handle many of the complexities of managing keyboard
/// those automatically handle many of the complexities of managing keyboard
/// input.
/// input.
final
String
character
;
final
String
?
character
;
/// Platform-specific information about the key event.
/// Platform-specific information about the key event.
final
RawKeyEventData
data
;
final
RawKeyEventData
data
;
...
@@ -449,8 +448,8 @@ abstract class RawKeyEvent with Diagnosticable {
...
@@ -449,8 +448,8 @@ abstract class RawKeyEvent with Diagnosticable {
class
RawKeyDownEvent
extends
RawKeyEvent
{
class
RawKeyDownEvent
extends
RawKeyEvent
{
/// Creates a key event that represents the user pressing a key.
/// Creates a key event that represents the user pressing a key.
const
RawKeyDownEvent
({
const
RawKeyDownEvent
({
@
required
RawKeyEventData
data
,
required
RawKeyEventData
data
,
String
character
,
String
?
character
,
})
:
super
(
data:
data
,
character:
character
);
})
:
super
(
data:
data
,
character:
character
);
}
}
...
@@ -462,8 +461,8 @@ class RawKeyDownEvent extends RawKeyEvent {
...
@@ -462,8 +461,8 @@ class RawKeyDownEvent extends RawKeyEvent {
class
RawKeyUpEvent
extends
RawKeyEvent
{
class
RawKeyUpEvent
extends
RawKeyEvent
{
/// Creates a key event that represents the user releasing a key.
/// Creates a key event that represents the user releasing a key.
const
RawKeyUpEvent
({
const
RawKeyUpEvent
({
@
required
RawKeyEventData
data
,
required
RawKeyEventData
data
,
String
character
,
String
?
character
,
})
:
super
(
data:
data
,
character:
character
);
})
:
super
(
data:
data
,
character:
character
);
}
}
...
@@ -557,13 +556,10 @@ class RawKeyboard {
...
@@ -557,13 +556,10 @@ class RawKeyboard {
/// focus.
/// focus.
/// * [addListener], to add passive key event listeners that do not stop event
/// * [addListener], to add passive key event listeners that do not stop event
/// propagation.
/// propagation.
RawKeyEventHandler
keyEventHandler
;
RawKeyEventHandler
?
keyEventHandler
;
Future
<
dynamic
>
_handleKeyEvent
(
dynamic
message
)
async
{
Future
<
dynamic
>
_handleKeyEvent
(
dynamic
message
)
async
{
final
RawKeyEvent
event
=
RawKeyEvent
.
fromMessage
(
message
as
Map
<
String
,
dynamic
>);
final
RawKeyEvent
event
=
RawKeyEvent
.
fromMessage
(
message
as
Map
<
String
,
dynamic
>);
if
(
event
==
null
)
{
return
;
}
if
(
event
.
data
is
RawKeyEventDataMacOs
&&
event
.
logicalKey
==
LogicalKeyboardKey
.
fn
)
{
if
(
event
.
data
is
RawKeyEventDataMacOs
&&
event
.
logicalKey
==
LogicalKeyboardKey
.
fn
)
{
// On macOS laptop keyboards, the fn key is used to generate home/end and
// On macOS laptop keyboards, the fn key is used to generate home/end and
// f1-f12, but it ALSO generates a separate down/up event for the fn key
// f1-f12, but it ALSO generates a separate down/up event for the fn key
...
@@ -595,7 +591,7 @@ class RawKeyboard {
...
@@ -595,7 +591,7 @@ class RawKeyboard {
// Send the key event to the keyEventHandler, then send the appropriate
// Send the key event to the keyEventHandler, then send the appropriate
// response to the platform so that it can resolve the event's handling.
// response to the platform so that it can resolve the event's handling.
// Defaults to false if keyEventHandler is null.
// Defaults to false if keyEventHandler is null.
final
bool
handled
=
keyEventHandler
!=
null
&&
keyEventHandler
(
event
);
final
bool
handled
=
keyEventHandler
!=
null
&&
keyEventHandler
!
(
event
);
assert
(
handled
!=
null
,
'keyEventHandler returned null, which is not allowed'
);
assert
(
handled
!=
null
,
'keyEventHandler returned null, which is not allowed'
);
return
<
String
,
dynamic
>{
'handled'
:
handled
};
return
<
String
,
dynamic
>{
'handled'
:
handled
};
}
}
...
@@ -656,15 +652,15 @@ class RawKeyboard {
...
@@ -656,15 +652,15 @@ class RawKeyboard {
// pressed/released while the app doesn't have focus, to make sure that
// pressed/released while the app doesn't have focus, to make sure that
// _keysPressed reflects reality at all times.
// _keysPressed reflects reality at all times.
final
Map
<
ModifierKey
,
KeyboardSide
>
modifiersPressed
=
event
.
data
.
modifiersPressed
;
final
Map
<
ModifierKey
,
KeyboardSide
?
>
modifiersPressed
=
event
.
data
.
modifiersPressed
;
final
Map
<
PhysicalKeyboardKey
,
LogicalKeyboardKey
>
modifierKeys
=
<
PhysicalKeyboardKey
,
LogicalKeyboardKey
>{};
final
Map
<
PhysicalKeyboardKey
,
LogicalKeyboardKey
>
modifierKeys
=
<
PhysicalKeyboardKey
,
LogicalKeyboardKey
>{};
for
(
final
ModifierKey
key
in
modifiersPressed
.
keys
)
{
for
(
final
ModifierKey
key
in
modifiersPressed
.
keys
)
{
final
Set
<
PhysicalKeyboardKey
>
mappedKeys
=
_modifierKeyMap
[
_ModifierSidePair
(
key
,
modifiersPressed
[
key
])];
final
Set
<
PhysicalKeyboardKey
>
mappedKeys
=
_modifierKeyMap
[
_ModifierSidePair
(
key
,
modifiersPressed
[
key
])]
!
;
assert
(
mappedKeys
!=
null
,
assert
(
mappedKeys
!=
null
,
'Platform key support for
${Platform.operatingSystem}
is '
'Platform key support for
${Platform.operatingSystem}
is '
'producing unsupported modifier combinations.'
);
'producing unsupported modifier combinations.'
);
for
(
final
PhysicalKeyboardKey
physicalModifier
in
mappedKeys
)
{
for
(
final
PhysicalKeyboardKey
physicalModifier
in
mappedKeys
)
{
modifierKeys
[
physicalModifier
]
=
_allModifiers
[
physicalModifier
];
modifierKeys
[
physicalModifier
]
=
_allModifiers
[
physicalModifier
]
!
;
}
}
}
}
_allModifiersExceptFn
.
keys
.
forEach
(
_keysPressed
.
remove
);
_allModifiersExceptFn
.
keys
.
forEach
(
_keysPressed
.
remove
);
...
@@ -695,7 +691,7 @@ class _ModifierSidePair extends Object {
...
@@ -695,7 +691,7 @@ class _ModifierSidePair extends Object {
const
_ModifierSidePair
(
this
.
modifier
,
this
.
side
);
const
_ModifierSidePair
(
this
.
modifier
,
this
.
side
);
final
ModifierKey
modifier
;
final
ModifierKey
modifier
;
final
KeyboardSide
side
;
final
KeyboardSide
?
side
;
@override
@override
bool
operator
==(
Object
other
)
{
bool
operator
==(
Object
other
)
{
...
...
packages/flutter/lib/src/services/raw_keyboard_android.dart
View file @
7884420a
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter/foundation.dart'
;
import
'package:flutter/foundation.dart'
;
...
@@ -148,7 +147,7 @@ class RawKeyEventDataAndroid extends RawKeyEventData {
...
@@ -148,7 +147,7 @@ class RawKeyEventDataAndroid extends RawKeyEventData {
// Android only reports a single code point for the key label.
// Android only reports a single code point for the key label.
@override
@override
String
get
keyLabel
=>
plainCodePoint
==
0
?
null
:
String
.
fromCharCode
(
plainCodePoint
&
_kCombiningCharacterMask
);
String
?
get
keyLabel
=>
plainCodePoint
==
0
?
null
:
String
.
fromCharCode
(
plainCodePoint
&
_kCombiningCharacterMask
);
@override
@override
PhysicalKeyboardKey
get
physicalKey
{
PhysicalKeyboardKey
get
physicalKey
{
...
@@ -161,7 +160,7 @@ class RawKeyEventDataAndroid extends RawKeyEventData {
...
@@ -161,7 +160,7 @@ class RawKeyEventDataAndroid extends RawKeyEventData {
// our own DPAD physical keys. The logical key will still match "arrowUp",
// our own DPAD physical keys. The logical key will still match "arrowUp",
// etc.
// etc.
if
(
eventSource
&
_sourceJoystick
==
_sourceJoystick
)
{
if
(
eventSource
&
_sourceJoystick
==
_sourceJoystick
)
{
final
LogicalKeyboardKey
foundKey
=
kAndroidToLogicalKey
[
keyCode
];
final
LogicalKeyboardKey
?
foundKey
=
kAndroidToLogicalKey
[
keyCode
];
if
(
foundKey
==
LogicalKeyboardKey
.
arrowUp
)
{
if
(
foundKey
==
LogicalKeyboardKey
.
arrowUp
)
{
return
PhysicalKeyboardKey
.
arrowUp
;
return
PhysicalKeyboardKey
.
arrowUp
;
}
}
...
@@ -183,7 +182,7 @@ class RawKeyEventDataAndroid extends RawKeyEventData {
...
@@ -183,7 +182,7 @@ class RawKeyEventDataAndroid extends RawKeyEventData {
// Look to see if the keyCode is a printable number pad key, so that a
// Look to see if the keyCode is a printable number pad key, so that a
// difference between regular keys (e.g. "=") and the number pad version
// difference between regular keys (e.g. "=") and the number pad version
// (e.g. the "=" on the number pad) can be determined.
// (e.g. the "=" on the number pad) can be determined.
final
LogicalKeyboardKey
numPadKey
=
kAndroidNumPadMap
[
keyCode
];
final
LogicalKeyboardKey
?
numPadKey
=
kAndroidNumPadMap
[
keyCode
];
if
(
numPadKey
!=
null
)
{
if
(
numPadKey
!=
null
)
{
return
numPadKey
;
return
numPadKey
;
}
}
...
@@ -192,18 +191,18 @@ class RawKeyEventDataAndroid extends RawKeyEventData {
...
@@ -192,18 +191,18 @@ class RawKeyEventDataAndroid extends RawKeyEventData {
// constant, or construct a new Unicode-based key from it. Don't mark it as
// constant, or construct a new Unicode-based key from it. Don't mark it as
// autogenerated, since the label uniquely identifies an ID from the Unicode
// autogenerated, since the label uniquely identifies an ID from the Unicode
// plane.
// plane.
if
(
keyLabel
!=
null
&&
keyLabel
.
isNotEmpty
&&
!
LogicalKeyboardKey
.
isControlCharacter
(
keyLabel
))
{
if
(
keyLabel
!=
null
&&
keyLabel
!.
isNotEmpty
&&
!
LogicalKeyboardKey
.
isControlCharacter
(
keyLabel
!
))
{
final
int
combinedCodePoint
=
plainCodePoint
&
_kCombiningCharacterMask
;
final
int
combinedCodePoint
=
plainCodePoint
&
_kCombiningCharacterMask
;
final
int
keyId
=
LogicalKeyboardKey
.
unicodePlane
|
(
combinedCodePoint
&
LogicalKeyboardKey
.
valueMask
);
final
int
keyId
=
LogicalKeyboardKey
.
unicodePlane
|
(
combinedCodePoint
&
LogicalKeyboardKey
.
valueMask
);
return
LogicalKeyboardKey
.
findKeyByKeyId
(
keyId
)
??
LogicalKeyboardKey
(
return
LogicalKeyboardKey
.
findKeyByKeyId
(
keyId
)
??
LogicalKeyboardKey
(
keyId
,
keyId
,
keyLabel:
keyLabel
,
keyLabel:
keyLabel
,
debugName:
kReleaseMode
?
null
:
'Key
${keyLabel.toUpperCase()}
'
,
debugName:
kReleaseMode
?
null
:
'Key
${keyLabel
!
.toUpperCase()}
'
,
);
);
}
}
// Look to see if the keyCode is one we know about and have a mapping for.
// Look to see if the keyCode is one we know about and have a mapping for.
LogicalKeyboardKey
newKey
=
kAndroidToLogicalKey
[
keyCode
];
LogicalKeyboardKey
?
newKey
=
kAndroidToLogicalKey
[
keyCode
];
if
(
newKey
!=
null
)
{
if
(
newKey
!=
null
)
{
return
newKey
;
return
newKey
;
}
}
...
@@ -232,7 +231,6 @@ class RawKeyEventDataAndroid extends RawKeyEventData {
...
@@ -232,7 +231,6 @@ class RawKeyEventDataAndroid extends RawKeyEventData {
case
KeyboardSide
.
right
:
case
KeyboardSide
.
right
:
return
metaState
&
rightMask
!=
0
;
return
metaState
&
rightMask
!=
0
;
}
}
return
false
;
}
}
@override
@override
...
@@ -258,12 +256,11 @@ class RawKeyEventDataAndroid extends RawKeyEventData {
...
@@ -258,12 +256,11 @@ class RawKeyEventDataAndroid extends RawKeyEventData {
case
ModifierKey
.
symbolModifier
:
case
ModifierKey
.
symbolModifier
:
return
metaState
&
modifierSym
!=
0
;
return
metaState
&
modifierSym
!=
0
;
}
}
return
false
;
}
}
@override
@override
KeyboardSide
getModifierSide
(
ModifierKey
key
)
{
KeyboardSide
?
getModifierSide
(
ModifierKey
key
)
{
KeyboardSide
findSide
(
int
leftMask
,
int
rightMask
)
{
KeyboardSide
?
findSide
(
int
leftMask
,
int
rightMask
)
{
final
int
combinedMask
=
leftMask
|
rightMask
;
final
int
combinedMask
=
leftMask
|
rightMask
;
final
int
combined
=
metaState
&
combinedMask
;
final
int
combined
=
metaState
&
combinedMask
;
if
(
combined
==
leftMask
)
{
if
(
combined
==
leftMask
)
{
...
@@ -292,9 +289,6 @@ class RawKeyEventDataAndroid extends RawKeyEventData {
...
@@ -292,9 +289,6 @@ class RawKeyEventDataAndroid extends RawKeyEventData {
case
ModifierKey
.
symbolModifier
:
case
ModifierKey
.
symbolModifier
:
return
KeyboardSide
.
all
;
return
KeyboardSide
.
all
;
}
}
assert
(
false
,
'Not handling
$key
type properly.'
);
return
null
;
}
}
// Modifier key masks.
// Modifier key masks.
...
...
packages/flutter/lib/src/services/raw_keyboard_fuchsia.dart
View file @
7884420a
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter/foundation.dart'
;
import
'package:flutter/foundation.dart'
;
...
@@ -62,7 +61,7 @@ class RawKeyEventDataFuchsia extends RawKeyEventData {
...
@@ -62,7 +61,7 @@ class RawKeyEventDataFuchsia extends RawKeyEventData {
// Fuchsia only reports a single code point for the key label.
// Fuchsia only reports a single code point for the key label.
@override
@override
String
get
keyLabel
=>
codePoint
==
0
?
null
:
String
.
fromCharCode
(
codePoint
);
String
?
get
keyLabel
=>
codePoint
==
0
?
null
:
String
.
fromCharCode
(
codePoint
);
@override
@override
LogicalKeyboardKey
get
logicalKey
{
LogicalKeyboardKey
get
logicalKey
{
...
@@ -77,7 +76,7 @@ class RawKeyEventDataFuchsia extends RawKeyEventData {
...
@@ -77,7 +76,7 @@ class RawKeyEventDataFuchsia extends RawKeyEventData {
}
}
// Look to see if the hidUsage is one we know about and have a mapping for.
// Look to see if the hidUsage is one we know about and have a mapping for.
LogicalKeyboardKey
newKey
=
kFuchsiaToLogicalKey
[
hidUsage
|
LogicalKeyboardKey
.
hidPlane
];
LogicalKeyboardKey
?
newKey
=
kFuchsiaToLogicalKey
[
hidUsage
|
LogicalKeyboardKey
.
hidPlane
];
if
(
newKey
!=
null
)
{
if
(
newKey
!=
null
)
{
return
newKey
;
return
newKey
;
}
}
...
@@ -109,7 +108,6 @@ class RawKeyEventDataFuchsia extends RawKeyEventData {
...
@@ -109,7 +108,6 @@ class RawKeyEventDataFuchsia extends RawKeyEventData {
case
KeyboardSide
.
right
:
case
KeyboardSide
.
right
:
return
modifiers
&
rightMask
!=
0
;
return
modifiers
&
rightMask
!=
0
;
}
}
return
false
;
}
}
@override
@override
...
@@ -133,12 +131,11 @@ class RawKeyEventDataFuchsia extends RawKeyEventData {
...
@@ -133,12 +131,11 @@ class RawKeyEventDataFuchsia extends RawKeyEventData {
// Fuchsia doesn't have masks for these keys (yet).
// Fuchsia doesn't have masks for these keys (yet).
return
false
;
return
false
;
}
}
return
false
;
}
}
@override
@override
KeyboardSide
getModifierSide
(
ModifierKey
key
)
{
KeyboardSide
?
getModifierSide
(
ModifierKey
key
)
{
KeyboardSide
findSide
(
int
leftMask
,
int
rightMask
,
int
combinedMask
)
{
KeyboardSide
?
findSide
(
int
leftMask
,
int
rightMask
,
int
combinedMask
)
{
final
int
combined
=
modifiers
&
combinedMask
;
final
int
combined
=
modifiers
&
combinedMask
;
if
(
combined
==
leftMask
)
{
if
(
combined
==
leftMask
)
{
return
KeyboardSide
.
left
;
return
KeyboardSide
.
left
;
...
@@ -168,9 +165,6 @@ class RawKeyEventDataFuchsia extends RawKeyEventData {
...
@@ -168,9 +165,6 @@ class RawKeyEventDataFuchsia extends RawKeyEventData {
// Fuchsia doesn't support these modifiers, so they can't be pressed.
// Fuchsia doesn't support these modifiers, so they can't be pressed.
return
null
;
return
null
;
}
}
assert
(
false
,
'Not handling
$key
type properly.'
);
return
null
;
}
}
// Keyboard modifier masks for Fuchsia modifiers.
// Keyboard modifier masks for Fuchsia modifiers.
...
...
packages/flutter/lib/src/services/raw_keyboard_linux.dart
View file @
7884420a
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter/foundation.dart'
;
import
'package:flutter/foundation.dart'
;
...
@@ -24,12 +23,12 @@ class RawKeyEventDataLinux extends RawKeyEventData {
...
@@ -24,12 +23,12 @@ class RawKeyEventDataLinux extends RawKeyEventData {
/// The [keyHelper], [scanCode], [unicodeScalarValues], [keyCode], and [modifiers],
/// The [keyHelper], [scanCode], [unicodeScalarValues], [keyCode], and [modifiers],
/// arguments must not be null.
/// arguments must not be null.
const
RawKeyEventDataLinux
({
const
RawKeyEventDataLinux
({
@
required
this
.
keyHelper
,
required
this
.
keyHelper
,
this
.
unicodeScalarValues
=
0
,
this
.
unicodeScalarValues
=
0
,
this
.
scanCode
=
0
,
this
.
scanCode
=
0
,
this
.
keyCode
=
0
,
this
.
keyCode
=
0
,
this
.
modifiers
=
0
,
this
.
modifiers
=
0
,
@
required
this
.
isDown
,
required
this
.
isDown
,
})
:
assert
(
scanCode
!=
null
),
})
:
assert
(
scanCode
!=
null
),
assert
(
unicodeScalarValues
!=
null
),
assert
(
unicodeScalarValues
!=
null
),
assert
((
unicodeScalarValues
&
~
LogicalKeyboardKey
.
valueMask
)
==
0
),
assert
((
unicodeScalarValues
&
~
LogicalKeyboardKey
.
valueMask
)
==
0
),
...
@@ -71,7 +70,7 @@ class RawKeyEventDataLinux extends RawKeyEventData {
...
@@ -71,7 +70,7 @@ class RawKeyEventDataLinux extends RawKeyEventData {
final
bool
isDown
;
final
bool
isDown
;
@override
@override
String
get
keyLabel
=>
unicodeScalarValues
==
0
?
null
:
String
.
fromCharCode
(
unicodeScalarValues
);
String
?
get
keyLabel
=>
unicodeScalarValues
==
0
?
null
:
String
.
fromCharCode
(
unicodeScalarValues
);
@override
@override
PhysicalKeyboardKey
get
physicalKey
=>
kLinuxToPhysicalKey
[
scanCode
]
??
PhysicalKeyboardKey
.
none
;
PhysicalKeyboardKey
get
physicalKey
=>
kLinuxToPhysicalKey
[
scanCode
]
??
PhysicalKeyboardKey
.
none
;
...
@@ -81,7 +80,7 @@ class RawKeyEventDataLinux extends RawKeyEventData {
...
@@ -81,7 +80,7 @@ class RawKeyEventDataLinux extends RawKeyEventData {
// Look to see if the keyCode is a printable number pad key, so that a
// Look to see if the keyCode is a printable number pad key, so that a
// difference between regular keys (e.g. "=") and the number pad version
// difference between regular keys (e.g. "=") and the number pad version
// (e.g. the "=" on the number pad) can be determined.
// (e.g. the "=" on the number pad) can be determined.
final
LogicalKeyboardKey
numPadKey
=
keyHelper
.
numpadKey
(
keyCode
);
final
LogicalKeyboardKey
?
numPadKey
=
keyHelper
.
numpadKey
(
keyCode
);
if
(
numPadKey
!=
null
)
{
if
(
numPadKey
!=
null
)
{
return
numPadKey
;
return
numPadKey
;
}
}
...
@@ -91,17 +90,17 @@ class RawKeyEventDataLinux extends RawKeyEventData {
...
@@ -91,17 +90,17 @@ class RawKeyEventDataLinux extends RawKeyEventData {
// autogenerated, since the label uniquely identifies an ID from the Unicode
// autogenerated, since the label uniquely identifies an ID from the Unicode
// plane.
// plane.
if
(
keyLabel
!=
null
&&
if
(
keyLabel
!=
null
&&
!
LogicalKeyboardKey
.
isControlCharacter
(
keyLabel
))
{
!
LogicalKeyboardKey
.
isControlCharacter
(
keyLabel
!
))
{
final
int
keyId
=
LogicalKeyboardKey
.
unicodePlane
|
(
unicodeScalarValues
&
LogicalKeyboardKey
.
valueMask
);
final
int
keyId
=
LogicalKeyboardKey
.
unicodePlane
|
(
unicodeScalarValues
&
LogicalKeyboardKey
.
valueMask
);
return
LogicalKeyboardKey
.
findKeyByKeyId
(
keyId
)
??
LogicalKeyboardKey
(
return
LogicalKeyboardKey
.
findKeyByKeyId
(
keyId
)
??
LogicalKeyboardKey
(
keyId
,
keyId
,
keyLabel:
keyLabel
,
keyLabel:
keyLabel
,
debugName:
kReleaseMode
?
null
:
'Key
${keyLabel.toUpperCase()}
'
,
debugName:
kReleaseMode
?
null
:
'Key
${keyLabel
!
.toUpperCase()}
'
,
);
);
}
}
// Look to see if the keyCode is one we know about and have a mapping for.
// Look to see if the keyCode is one we know about and have a mapping for.
LogicalKeyboardKey
newKey
=
keyHelper
.
logicalKey
(
keyCode
);
LogicalKeyboardKey
?
newKey
=
keyHelper
.
logicalKey
(
keyCode
);
if
(
newKey
!=
null
)
{
if
(
newKey
!=
null
)
{
return
newKey
;
return
newKey
;
}
}
...
@@ -158,13 +157,13 @@ abstract class KeyHelper {
...
@@ -158,13 +157,13 @@ abstract class KeyHelper {
/// Returns true if the given [ModifierKey] was pressed at the time of this
/// Returns true if the given [ModifierKey] was pressed at the time of this
/// event.
/// event.
bool
isModifierPressed
(
ModifierKey
key
,
int
modifiers
,
{
KeyboardSide
side
=
KeyboardSide
.
any
,
int
keyCode
,
bool
isDown
});
bool
isModifierPressed
(
ModifierKey
key
,
int
modifiers
,
{
KeyboardSide
side
=
KeyboardSide
.
any
,
required
int
keyCode
,
required
bool
isDown
});
/// The numpad key from the specific key code mapping.
/// The numpad key from the specific key code mapping.
LogicalKeyboardKey
numpadKey
(
int
keyCode
);
LogicalKeyboardKey
?
numpadKey
(
int
keyCode
);
/// The logical key key from the specific key code mapping.
/// The logical key key from the specific key code mapping.
LogicalKeyboardKey
logicalKey
(
int
keyCode
);
LogicalKeyboardKey
?
logicalKey
(
int
keyCode
);
}
}
/// Helper class that uses GLFW-specific key mappings.
/// Helper class that uses GLFW-specific key mappings.
...
@@ -212,7 +211,7 @@ class GLFWKeyHelper with KeyHelper {
...
@@ -212,7 +211,7 @@ class GLFWKeyHelper with KeyHelper {
/// {@macro flutter.services.glfwKeyHelper.modifiers}
/// {@macro flutter.services.glfwKeyHelper.modifiers}
static
const
int
modifierNumericPad
=
0x0020
;
static
const
int
modifierNumericPad
=
0x0020
;
int
_mergeModifiers
({
int
modifiers
,
int
keyCode
,
bool
isDown
})
{
int
_mergeModifiers
({
required
int
modifiers
,
required
int
keyCode
,
required
bool
isDown
})
{
// GLFW Key codes for modifier keys.
// GLFW Key codes for modifier keys.
const
int
shiftLeftKeyCode
=
340
;
const
int
shiftLeftKeyCode
=
340
;
const
int
shiftRightKeyCode
=
344
;
const
int
shiftRightKeyCode
=
344
;
...
@@ -262,7 +261,7 @@ class GLFWKeyHelper with KeyHelper {
...
@@ -262,7 +261,7 @@ class GLFWKeyHelper with KeyHelper {
}
}
@override
@override
bool
isModifierPressed
(
ModifierKey
key
,
int
modifiers
,
{
KeyboardSide
side
=
KeyboardSide
.
any
,
int
keyCode
,
bool
isDown
})
{
bool
isModifierPressed
(
ModifierKey
key
,
int
modifiers
,
{
KeyboardSide
side
=
KeyboardSide
.
any
,
required
int
keyCode
,
required
bool
isDown
})
{
modifiers
=
_mergeModifiers
(
modifiers:
modifiers
,
keyCode:
keyCode
,
isDown:
isDown
);
modifiers
=
_mergeModifiers
(
modifiers:
modifiers
,
keyCode:
keyCode
,
isDown:
isDown
);
switch
(
key
)
{
switch
(
key
)
{
case
ModifierKey
.
controlModifier
:
case
ModifierKey
.
controlModifier
:
...
@@ -283,7 +282,6 @@ class GLFWKeyHelper with KeyHelper {
...
@@ -283,7 +282,6 @@ class GLFWKeyHelper with KeyHelper {
// These are not used in GLFW keyboards.
// These are not used in GLFW keyboards.
return
false
;
return
false
;
}
}
return
false
;
}
}
@override
@override
...
@@ -303,17 +301,15 @@ class GLFWKeyHelper with KeyHelper {
...
@@ -303,17 +301,15 @@ class GLFWKeyHelper with KeyHelper {
case
ModifierKey
.
scrollLockModifier
:
case
ModifierKey
.
scrollLockModifier
:
return
KeyboardSide
.
all
;
return
KeyboardSide
.
all
;
}
}
assert
(
false
,
'Not handling
$key
type properly.'
);
return
null
;
}
}
@override
@override
LogicalKeyboardKey
numpadKey
(
int
keyCode
)
{
LogicalKeyboardKey
?
numpadKey
(
int
keyCode
)
{
return
kGlfwNumpadMap
[
keyCode
];
return
kGlfwNumpadMap
[
keyCode
];
}
}
@override
@override
LogicalKeyboardKey
logicalKey
(
int
keyCode
)
{
LogicalKeyboardKey
?
logicalKey
(
int
keyCode
)
{
return
kGlfwToLogicalKey
[
keyCode
];
return
kGlfwToLogicalKey
[
keyCode
];
}
}
}
}
...
@@ -362,7 +358,7 @@ class GtkKeyHelper with KeyHelper {
...
@@ -362,7 +358,7 @@ class GtkKeyHelper with KeyHelper {
/// {@macro flutter.services.gtkKeyHelper.modifiers}
/// {@macro flutter.services.gtkKeyHelper.modifiers}
static
const
int
modifierMeta
=
1
<<
28
;
static
const
int
modifierMeta
=
1
<<
28
;
int
_mergeModifiers
({
int
modifiers
,
int
keyCode
,
bool
isDown
})
{
int
_mergeModifiers
({
required
int
modifiers
,
required
int
keyCode
,
required
bool
isDown
})
{
// GTK Key codes for modifier keys.
// GTK Key codes for modifier keys.
const
int
shiftLeftKeyCode
=
0xffe1
;
const
int
shiftLeftKeyCode
=
0xffe1
;
const
int
shiftRightKeyCode
=
0xffe2
;
const
int
shiftRightKeyCode
=
0xffe2
;
...
@@ -414,7 +410,7 @@ class GtkKeyHelper with KeyHelper {
...
@@ -414,7 +410,7 @@ class GtkKeyHelper with KeyHelper {
}
}
@override
@override
bool
isModifierPressed
(
ModifierKey
key
,
int
modifiers
,
{
KeyboardSide
side
=
KeyboardSide
.
any
,
int
keyCode
,
bool
isDown
})
{
bool
isModifierPressed
(
ModifierKey
key
,
int
modifiers
,
{
KeyboardSide
side
=
KeyboardSide
.
any
,
required
int
keyCode
,
required
bool
isDown
})
{
modifiers
=
_mergeModifiers
(
modifiers:
modifiers
,
keyCode:
keyCode
,
isDown:
isDown
);
modifiers
=
_mergeModifiers
(
modifiers:
modifiers
,
keyCode:
keyCode
,
isDown:
isDown
);
switch
(
key
)
{
switch
(
key
)
{
case
ModifierKey
.
controlModifier
:
case
ModifierKey
.
controlModifier
:
...
@@ -435,7 +431,6 @@ class GtkKeyHelper with KeyHelper {
...
@@ -435,7 +431,6 @@ class GtkKeyHelper with KeyHelper {
// These are not used in GTK keyboards.
// These are not used in GTK keyboards.
return
false
;
return
false
;
}
}
return
false
;
}
}
@override
@override
...
@@ -455,17 +450,15 @@ class GtkKeyHelper with KeyHelper {
...
@@ -455,17 +450,15 @@ class GtkKeyHelper with KeyHelper {
case
ModifierKey
.
scrollLockModifier
:
case
ModifierKey
.
scrollLockModifier
:
return
KeyboardSide
.
all
;
return
KeyboardSide
.
all
;
}
}
assert
(
false
,
'Not handling
$key
type properly.'
);
return
null
;
}
}
@override
@override
LogicalKeyboardKey
numpadKey
(
int
keyCode
)
{
LogicalKeyboardKey
?
numpadKey
(
int
keyCode
)
{
return
kGtkNumpadMap
[
keyCode
];
return
kGtkNumpadMap
[
keyCode
];
}
}
@override
@override
LogicalKeyboardKey
logicalKey
(
int
keyCode
)
{
LogicalKeyboardKey
?
logicalKey
(
int
keyCode
)
{
return
kGtkToLogicalKey
[
keyCode
];
return
kGtkToLogicalKey
[
keyCode
];
}
}
}
}
packages/flutter/lib/src/services/raw_keyboard_macos.dart
View file @
7884420a
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter/foundation.dart'
;
import
'package:flutter/foundation.dart'
;
...
@@ -63,7 +62,7 @@ class RawKeyEventDataMacOs extends RawKeyEventData {
...
@@ -63,7 +62,7 @@ class RawKeyEventDataMacOs extends RawKeyEventData {
final
int
modifiers
;
final
int
modifiers
;
@override
@override
String
get
keyLabel
=>
charactersIgnoringModifiers
.
isEmpty
?
null
:
charactersIgnoringModifiers
;
String
?
get
keyLabel
=>
charactersIgnoringModifiers
.
isEmpty
?
null
:
charactersIgnoringModifiers
;
@override
@override
PhysicalKeyboardKey
get
physicalKey
=>
kMacOsToPhysicalKey
[
keyCode
]
??
PhysicalKeyboardKey
.
none
;
PhysicalKeyboardKey
get
physicalKey
=>
kMacOsToPhysicalKey
[
keyCode
]
??
PhysicalKeyboardKey
.
none
;
...
@@ -73,7 +72,7 @@ class RawKeyEventDataMacOs extends RawKeyEventData {
...
@@ -73,7 +72,7 @@ class RawKeyEventDataMacOs extends RawKeyEventData {
// Look to see if the keyCode is a printable number pad key, so that a
// Look to see if the keyCode is a printable number pad key, so that a
// difference between regular keys (e.g. "=") and the number pad version
// difference between regular keys (e.g. "=") and the number pad version
// (e.g. the "=" on the number pad) can be determined.
// (e.g. the "=" on the number pad) can be determined.
final
LogicalKeyboardKey
numPadKey
=
kMacOsNumPadMap
[
keyCode
];
final
LogicalKeyboardKey
?
numPadKey
=
kMacOsNumPadMap
[
keyCode
];
if
(
numPadKey
!=
null
)
{
if
(
numPadKey
!=
null
)
{
return
numPadKey
;
return
numPadKey
;
}
}
...
@@ -81,8 +80,8 @@ class RawKeyEventDataMacOs extends RawKeyEventData {
...
@@ -81,8 +80,8 @@ class RawKeyEventDataMacOs extends RawKeyEventData {
// Control keys such as ESC, CRTL, and SHIFT are not printable. HOME, DEL, arrow keys, and function
// Control keys such as ESC, CRTL, and SHIFT are not printable. HOME, DEL, arrow keys, and function
// keys are considered modifier function keys, which generate invalid Unicode scalar values.
// keys are considered modifier function keys, which generate invalid Unicode scalar values.
if
(
keyLabel
!=
null
&&
if
(
keyLabel
!=
null
&&
!
LogicalKeyboardKey
.
isControlCharacter
(
keyLabel
)
&&
!
LogicalKeyboardKey
.
isControlCharacter
(
keyLabel
!
)
&&
!
_isUnprintableKey
(
keyLabel
))
{
!
_isUnprintableKey
(
keyLabel
!
))
{
// Given that charactersIgnoringModifiers can contain a String of arbitrary length,
// Given that charactersIgnoringModifiers can contain a String of arbitrary length,
// limit to a maximum of two Unicode scalar values. It is unlikely that a keyboard would produce a code point
// limit to a maximum of two Unicode scalar values. It is unlikely that a keyboard would produce a code point
// bigger than 32 bits, but it is still worth defending against this case.
// bigger than 32 bits, but it is still worth defending against this case.
...
@@ -97,7 +96,7 @@ class RawKeyEventDataMacOs extends RawKeyEventData {
...
@@ -97,7 +96,7 @@ class RawKeyEventDataMacOs extends RawKeyEventData {
return
LogicalKeyboardKey
.
findKeyByKeyId
(
keyId
)
??
LogicalKeyboardKey
(
return
LogicalKeyboardKey
.
findKeyByKeyId
(
keyId
)
??
LogicalKeyboardKey
(
keyId
,
keyId
,
keyLabel:
keyLabel
,
keyLabel:
keyLabel
,
debugName:
kReleaseMode
?
null
:
'Key
${keyLabel.toUpperCase()}
'
,
debugName:
kReleaseMode
?
null
:
'Key
${keyLabel
!
.toUpperCase()}
'
,
);
);
}
}
...
@@ -145,7 +144,6 @@ class RawKeyEventDataMacOs extends RawKeyEventData {
...
@@ -145,7 +144,6 @@ class RawKeyEventDataMacOs extends RawKeyEventData {
case
KeyboardSide
.
right
:
case
KeyboardSide
.
right
:
return
modifiers
&
rightMask
!=
0
||
anyOnly
;
return
modifiers
&
rightMask
!=
0
||
anyOnly
;
}
}
return
false
;
}
}
@override
@override
...
@@ -185,8 +183,8 @@ class RawKeyEventDataMacOs extends RawKeyEventData {
...
@@ -185,8 +183,8 @@ class RawKeyEventDataMacOs extends RawKeyEventData {
}
}
@override
@override
KeyboardSide
getModifierSide
(
ModifierKey
key
)
{
KeyboardSide
?
getModifierSide
(
ModifierKey
key
)
{
KeyboardSide
findSide
(
int
leftMask
,
int
rightMask
,
int
anyMask
)
{
KeyboardSide
?
findSide
(
int
leftMask
,
int
rightMask
,
int
anyMask
)
{
final
int
combinedMask
=
leftMask
|
rightMask
;
final
int
combinedMask
=
leftMask
|
rightMask
;
final
int
combined
=
modifiers
&
combinedMask
;
final
int
combined
=
modifiers
&
combinedMask
;
if
(
combined
==
leftMask
)
{
if
(
combined
==
leftMask
)
{
...
@@ -218,9 +216,6 @@ class RawKeyEventDataMacOs extends RawKeyEventData {
...
@@ -218,9 +216,6 @@ class RawKeyEventDataMacOs extends RawKeyEventData {
case
ModifierKey
.
symbolModifier
:
case
ModifierKey
.
symbolModifier
:
return
KeyboardSide
.
all
;
return
KeyboardSide
.
all
;
}
}
assert
(
false
,
'Not handling
$key
type properly.'
);
return
null
;
}
}
/// Returns true if the given label represents an unprintable key.
/// Returns true if the given label represents an unprintable key.
...
...
packages/flutter/lib/src/services/raw_keyboard_web.dart
View file @
7884420a
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter/foundation.dart'
;
import
'package:flutter/foundation.dart'
;
...
@@ -21,8 +20,8 @@ class RawKeyEventDataWeb extends RawKeyEventData {
...
@@ -21,8 +20,8 @@ class RawKeyEventDataWeb extends RawKeyEventData {
///
///
/// The [code] and [metaState] arguments must not be null.
/// The [code] and [metaState] arguments must not be null.
const
RawKeyEventDataWeb
({
const
RawKeyEventDataWeb
({
@
required
this
.
code
,
required
this
.
code
,
@
required
this
.
key
,
required
this
.
key
,
this
.
metaState
=
modifierNone
,
this
.
metaState
=
modifierNone
,
})
:
assert
(
code
!=
null
),
})
:
assert
(
code
!=
null
),
assert
(
metaState
!=
null
);
assert
(
metaState
!=
null
);
...
@@ -69,13 +68,13 @@ class RawKeyEventDataWeb extends RawKeyEventData {
...
@@ -69,13 +68,13 @@ class RawKeyEventDataWeb extends RawKeyEventData {
// Look to see if the keyCode is a printable number pad key, so that a
// Look to see if the keyCode is a printable number pad key, so that a
// difference between regular keys (e.g. ".") and the number pad version
// difference between regular keys (e.g. ".") and the number pad version
// (e.g. the "." on the number pad) can be determined.
// (e.g. the "." on the number pad) can be determined.
final
LogicalKeyboardKey
numPadKey
=
kWebNumPadMap
[
code
];
final
LogicalKeyboardKey
?
numPadKey
=
kWebNumPadMap
[
code
];
if
(
numPadKey
!=
null
)
{
if
(
numPadKey
!=
null
)
{
return
numPadKey
;
return
numPadKey
;
}
}
// Look to see if the [code] is one we know about and have a mapping for.
// Look to see if the [code] is one we know about and have a mapping for.
final
LogicalKeyboardKey
newKey
=
kWebToLogicalKey
[
code
];
final
LogicalKeyboardKey
?
newKey
=
kWebToLogicalKey
[
code
];
if
(
newKey
!=
null
)
{
if
(
newKey
!=
null
)
{
return
newKey
;
return
newKey
;
}
}
...
...
packages/flutter/lib/src/services/raw_keyboard_windows.dart
View file @
7884420a
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter/foundation.dart'
;
import
'package:flutter/foundation.dart'
;
...
@@ -55,7 +54,7 @@ class RawKeyEventDataWindows extends RawKeyEventData {
...
@@ -55,7 +54,7 @@ class RawKeyEventDataWindows extends RawKeyEventData {
final
int
modifiers
;
final
int
modifiers
;
@override
@override
String
get
keyLabel
=>
characterCodePoint
==
0
?
null
:
String
.
fromCharCode
(
characterCodePoint
);
String
?
get
keyLabel
=>
characterCodePoint
==
0
?
null
:
String
.
fromCharCode
(
characterCodePoint
);
@override
@override
PhysicalKeyboardKey
get
physicalKey
=>
kWindowsToPhysicalKey
[
scanCode
]
??
PhysicalKeyboardKey
.
none
;
PhysicalKeyboardKey
get
physicalKey
=>
kWindowsToPhysicalKey
[
scanCode
]
??
PhysicalKeyboardKey
.
none
;
...
@@ -65,7 +64,7 @@ class RawKeyEventDataWindows extends RawKeyEventData {
...
@@ -65,7 +64,7 @@ class RawKeyEventDataWindows extends RawKeyEventData {
// Look to see if the keyCode is a printable number pad key, so that a
// Look to see if the keyCode is a printable number pad key, so that a
// difference between regular keys (e.g. "=") and the number pad version
// difference between regular keys (e.g. "=") and the number pad version
// (e.g. the "=" on the number pad) can be determined.
// (e.g. the "=" on the number pad) can be determined.
final
LogicalKeyboardKey
numPadKey
=
kWindowsNumPadMap
[
keyCode
];
final
LogicalKeyboardKey
?
numPadKey
=
kWindowsNumPadMap
[
keyCode
];
if
(
numPadKey
!=
null
)
{
if
(
numPadKey
!=
null
)
{
return
numPadKey
;
return
numPadKey
;
}
}
...
@@ -74,16 +73,16 @@ class RawKeyEventDataWindows extends RawKeyEventData {
...
@@ -74,16 +73,16 @@ class RawKeyEventDataWindows extends RawKeyEventData {
// constant, or construct a new Unicode-based key from it. Don't mark it as
// constant, or construct a new Unicode-based key from it. Don't mark it as
// autogenerated, since the label uniquely identifies an ID from the Unicode
// autogenerated, since the label uniquely identifies an ID from the Unicode
// plane.
// plane.
if
(
keyLabel
!=
null
&&
keyLabel
.
isNotEmpty
&&
!
LogicalKeyboardKey
.
isControlCharacter
(
keyLabel
))
{
if
(
keyLabel
!=
null
&&
keyLabel
!.
isNotEmpty
&&
!
LogicalKeyboardKey
.
isControlCharacter
(
keyLabel
!
))
{
final
int
keyId
=
LogicalKeyboardKey
.
unicodePlane
|
(
characterCodePoint
&
LogicalKeyboardKey
.
valueMask
);
final
int
keyId
=
LogicalKeyboardKey
.
unicodePlane
|
(
characterCodePoint
&
LogicalKeyboardKey
.
valueMask
);
return
LogicalKeyboardKey
.
findKeyByKeyId
(
keyId
)
??
LogicalKeyboardKey
(
return
LogicalKeyboardKey
.
findKeyByKeyId
(
keyId
)
??
LogicalKeyboardKey
(
keyId
,
keyId
,
keyLabel:
keyLabel
,
keyLabel:
keyLabel
,
debugName:
kReleaseMode
?
null
:
'Key
${keyLabel.toUpperCase()}
'
,
debugName:
kReleaseMode
?
null
:
'Key
${keyLabel
!
.toUpperCase()}
'
,
);
);
}
}
// Look to see if the keyCode is one we know about and have a mapping for.
// Look to see if the keyCode is one we know about and have a mapping for.
LogicalKeyboardKey
newKey
=
kWindowsToLogicalKey
[
keyCode
];
LogicalKeyboardKey
?
newKey
=
kWindowsToLogicalKey
[
keyCode
];
if
(
newKey
!=
null
)
{
if
(
newKey
!=
null
)
{
return
newKey
;
return
newKey
;
}
}
...
@@ -120,7 +119,6 @@ class RawKeyEventDataWindows extends RawKeyEventData {
...
@@ -120,7 +119,6 @@ class RawKeyEventDataWindows extends RawKeyEventData {
case
KeyboardSide
.
right
:
case
KeyboardSide
.
right
:
return
modifiers
&
rightMask
!=
0
||
anyOnly
;
return
modifiers
&
rightMask
!=
0
||
anyOnly
;
}
}
return
false
;
}
}
@override
@override
...
@@ -162,8 +160,8 @@ class RawKeyEventDataWindows extends RawKeyEventData {
...
@@ -162,8 +160,8 @@ class RawKeyEventDataWindows extends RawKeyEventData {
@override
@override
KeyboardSide
getModifierSide
(
ModifierKey
key
)
{
KeyboardSide
?
getModifierSide
(
ModifierKey
key
)
{
KeyboardSide
findSide
(
int
leftMask
,
int
rightMask
,
int
anyMask
)
{
KeyboardSide
?
findSide
(
int
leftMask
,
int
rightMask
,
int
anyMask
)
{
final
int
combinedMask
=
leftMask
|
rightMask
;
final
int
combinedMask
=
leftMask
|
rightMask
;
final
int
combined
=
modifiers
&
combinedMask
;
final
int
combined
=
modifiers
&
combinedMask
;
if
(
combined
==
leftMask
)
{
if
(
combined
==
leftMask
)
{
...
@@ -197,9 +195,6 @@ class RawKeyEventDataWindows extends RawKeyEventData {
...
@@ -197,9 +195,6 @@ class RawKeyEventDataWindows extends RawKeyEventData {
case
ModifierKey
.
symbolModifier
:
case
ModifierKey
.
symbolModifier
:
return
KeyboardSide
.
all
;
return
KeyboardSide
.
all
;
}
}
assert
(
false
,
'Not handling
$key
type properly.'
);
return
null
;
}
}
// These are not the values defined by the Windows header for each modifier. Since they
// These are not the values defined by the Windows header for each modifier. Since they
...
...
packages/flutter/lib/src/services/restoration.dart
View file @
7884420a
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'dart:async'
;
import
'dart:async'
;
import
'dart:typed_data'
;
import
'dart:typed_data'
;
...
@@ -132,25 +130,25 @@ class RestorationManager extends ChangeNotifier {
...
@@ -132,25 +130,25 @@ class RestorationManager extends ChangeNotifier {
///
///
/// * [RootRestorationScope], which makes the root bucket available in the
/// * [RootRestorationScope], which makes the root bucket available in the
/// [Widget] tree.
/// [Widget] tree.
Future
<
RestorationBucket
>
get
rootBucket
{
Future
<
RestorationBucket
?
>
get
rootBucket
{
if
(!
SystemChannels
.
restoration
.
checkMethodCallHandler
(
_methodHandler
))
{
if
(!
SystemChannels
.
restoration
.
checkMethodCallHandler
(
_methodHandler
))
{
SystemChannels
.
restoration
.
setMethodCallHandler
(
_methodHandler
);
SystemChannels
.
restoration
.
setMethodCallHandler
(
_methodHandler
);
}
}
if
(
_rootBucketIsValid
)
{
if
(
_rootBucketIsValid
)
{
return
SynchronousFuture
<
RestorationBucket
>(
_rootBucket
);
return
SynchronousFuture
<
RestorationBucket
?
>(
_rootBucket
);
}
}
if
(
_pendingRootBucket
==
null
)
{
if
(
_pendingRootBucket
==
null
)
{
_pendingRootBucket
=
Completer
<
RestorationBucket
>();
_pendingRootBucket
=
Completer
<
RestorationBucket
>();
_getRootBucketFromEngine
();
_getRootBucketFromEngine
();
}
}
return
_pendingRootBucket
.
future
;
return
_pendingRootBucket
!
.
future
;
}
}
RestorationBucket
_rootBucket
;
// May be null to indicate that restoration is turned off.
RestorationBucket
?
_rootBucket
;
// May be null to indicate that restoration is turned off.
Completer
<
RestorationBucket
>
_pendingRootBucket
;
Completer
<
RestorationBucket
>
?
_pendingRootBucket
;
bool
_rootBucketIsValid
=
false
;
bool
_rootBucketIsValid
=
false
;
Future
<
void
>
_getRootBucketFromEngine
()
async
{
Future
<
void
>
_getRootBucketFromEngine
()
async
{
final
Map
<
dynamic
,
dynamic
>
config
=
await
SystemChannels
.
restoration
.
invokeMethod
<
Map
<
dynamic
,
dynamic
>>(
'get'
);
final
Map
<
dynamic
,
dynamic
>
?
config
=
await
SystemChannels
.
restoration
.
invokeMethod
<
Map
<
dynamic
,
dynamic
>>(
'get'
);
if
(
_pendingRootBucket
==
null
)
{
if
(
_pendingRootBucket
==
null
)
{
// The restoration data was obtained via other means (e.g. by calling
// The restoration data was obtained via other means (e.g. by calling
// [handleRestorationDataUpdate] while the request to the engine was
// [handleRestorationDataUpdate] while the request to the engine was
...
@@ -161,7 +159,7 @@ class RestorationManager extends ChangeNotifier {
...
@@ -161,7 +159,7 @@ class RestorationManager extends ChangeNotifier {
_parseAndHandleRestorationUpdateFromEngine
(
config
);
_parseAndHandleRestorationUpdateFromEngine
(
config
);
}
}
void
_parseAndHandleRestorationUpdateFromEngine
(
Map
<
dynamic
,
dynamic
>
update
)
{
void
_parseAndHandleRestorationUpdateFromEngine
(
Map
<
dynamic
,
dynamic
>
?
update
)
{
handleRestorationUpdateFromEngine
(
handleRestorationUpdateFromEngine
(
enabled:
update
!=
null
&&
update
[
'enabled'
]
as
bool
,
enabled:
update
!=
null
&&
update
[
'enabled'
]
as
bool
,
data:
update
==
null
?
null
:
update
[
'data'
]
as
Uint8List
,
data:
update
==
null
?
null
:
update
[
'data'
]
as
Uint8List
,
...
@@ -185,16 +183,16 @@ class RestorationManager extends ChangeNotifier {
...
@@ -185,16 +183,16 @@ class RestorationManager extends ChangeNotifier {
/// accessed, [rootBucket] will complete synchronously the next time it is
/// accessed, [rootBucket] will complete synchronously the next time it is
/// called.
/// called.
@protected
@protected
void
handleRestorationUpdateFromEngine
({
@required
bool
enabled
,
@required
Uint8List
data
})
{
void
handleRestorationUpdateFromEngine
({
required
bool
enabled
,
required
Uint8List
?
data
})
{
assert
(
enabled
!=
null
);
assert
(
enabled
!=
null
);
final
RestorationBucket
oldRoot
=
_rootBucket
;
final
RestorationBucket
?
oldRoot
=
_rootBucket
;
_rootBucket
=
enabled
_rootBucket
=
enabled
?
RestorationBucket
.
root
(
manager:
this
,
rawData:
_decodeRestorationData
(
data
))
?
RestorationBucket
.
root
(
manager:
this
,
rawData:
_decodeRestorationData
(
data
))
:
null
;
:
null
;
_rootBucketIsValid
=
true
;
_rootBucketIsValid
=
true
;
assert
(
_pendingRootBucket
==
null
||
!
_pendingRootBucket
.
isCompleted
);
assert
(
_pendingRootBucket
==
null
||
!
_pendingRootBucket
!
.
isCompleted
);
_pendingRootBucket
?.
complete
(
_rootBucket
);
_pendingRootBucket
?.
complete
(
_rootBucket
);
_pendingRootBucket
=
null
;
_pendingRootBucket
=
null
;
...
@@ -228,7 +226,7 @@ class RestorationManager extends ChangeNotifier {
...
@@ -228,7 +226,7 @@ class RestorationManager extends ChangeNotifier {
);
);
}
}
Future
<
dynamic
>
_methodHandler
(
MethodCall
call
)
{
Future
<
dynamic
>
_methodHandler
(
MethodCall
call
)
async
{
switch
(
call
.
method
)
{
switch
(
call
.
method
)
{
case
'push'
:
case
'push'
:
_parseAndHandleRestorationUpdateFromEngine
(
call
.
arguments
as
Map
<
dynamic
,
dynamic
>);
_parseAndHandleRestorationUpdateFromEngine
(
call
.
arguments
as
Map
<
dynamic
,
dynamic
>);
...
@@ -236,10 +234,9 @@ class RestorationManager extends ChangeNotifier {
...
@@ -236,10 +234,9 @@ class RestorationManager extends ChangeNotifier {
default
:
default
:
throw
UnimplementedError
(
"
${call.method}
was invoked but isn't implemented by
$runtimeType
"
);
throw
UnimplementedError
(
"
${call.method}
was invoked but isn't implemented by
$runtimeType
"
);
}
}
return
null
;
}
}
Map
<
dynamic
,
dynamic
>
_decodeRestorationData
(
Uint8List
data
)
{
Map
<
dynamic
,
dynamic
>
?
_decodeRestorationData
(
Uint8List
?
data
)
{
if
(
data
==
null
)
{
if
(
data
==
null
)
{
return
null
;
return
null
;
}
}
...
@@ -248,7 +245,7 @@ class RestorationManager extends ChangeNotifier {
...
@@ -248,7 +245,7 @@ class RestorationManager extends ChangeNotifier {
}
}
Uint8List
_encodeRestorationData
(
Map
<
dynamic
,
dynamic
>
data
)
{
Uint8List
_encodeRestorationData
(
Map
<
dynamic
,
dynamic
>
data
)
{
final
ByteData
encoded
=
const
StandardMessageCodec
().
encodeMessage
(
data
);
final
ByteData
encoded
=
const
StandardMessageCodec
().
encodeMessage
(
data
)
!
;
return
encoded
.
buffer
.
asUint8List
(
encoded
.
offsetInBytes
,
encoded
.
lengthInBytes
);
return
encoded
.
buffer
.
asUint8List
(
encoded
.
offsetInBytes
,
encoded
.
lengthInBytes
);
}
}
...
@@ -275,7 +272,7 @@ class RestorationManager extends ChangeNotifier {
...
@@ -275,7 +272,7 @@ class RestorationManager extends ChangeNotifier {
_bucketsNeedingSerialization
.
add
(
bucket
);
_bucketsNeedingSerialization
.
add
(
bucket
);
if
(!
_postFrameScheduled
)
{
if
(!
_postFrameScheduled
)
{
_postFrameScheduled
=
true
;
_postFrameScheduled
=
true
;
SchedulerBinding
.
instance
.
addPostFrameCallback
((
Duration
_
)
=>
_doSerialization
());
SchedulerBinding
.
instance
!
.
addPostFrameCallback
((
Duration
_
)
=>
_doSerialization
());
}
}
}
}
...
@@ -308,7 +305,7 @@ class RestorationManager extends ChangeNotifier {
...
@@ -308,7 +305,7 @@ class RestorationManager extends ChangeNotifier {
bucket
.
finalize
();
bucket
.
finalize
();
}
}
_bucketsNeedingSerialization
.
clear
();
_bucketsNeedingSerialization
.
clear
();
sendToEngine
(
_encodeRestorationData
(
_rootBucket
.
_rawData
));
sendToEngine
(
_encodeRestorationData
(
_rootBucket
!
.
_rawData
));
assert
(()
{
assert
(()
{
_debugDoingUpdate
=
false
;
_debugDoingUpdate
=
false
;
...
@@ -410,8 +407,8 @@ class RestorationBucket extends ChangeNotifier {
...
@@ -410,8 +407,8 @@ class RestorationBucket extends ChangeNotifier {
///
///
/// The `restorationId` must not be null.
/// The `restorationId` must not be null.
RestorationBucket
.
empty
({
RestorationBucket
.
empty
({
@
required
String
restorationId
,
required
String
restorationId
,
@required
Object
debugOwner
,
required
Object
?
debugOwner
,
})
:
assert
(
restorationId
!=
null
),
})
:
assert
(
restorationId
!=
null
),
_restorationId
=
restorationId
,
_restorationId
=
restorationId
,
_rawData
=
<
String
,
dynamic
>{}
{
_rawData
=
<
String
,
dynamic
>{}
{
...
@@ -445,8 +442,8 @@ class RestorationBucket extends ChangeNotifier {
...
@@ -445,8 +442,8 @@ class RestorationBucket extends ChangeNotifier {
///
///
/// The `manager` argument must not be null.
/// The `manager` argument must not be null.
RestorationBucket
.
root
({
RestorationBucket
.
root
({
@
required
RestorationManager
manager
,
required
RestorationManager
manager
,
@required
Map
<
dynamic
,
dynamic
>
rawData
,
required
Map
<
dynamic
,
dynamic
>?
rawData
,
})
:
assert
(
manager
!=
null
),
})
:
assert
(
manager
!=
null
),
_manager
=
manager
,
_manager
=
manager
,
_rawData
=
rawData
??
<
dynamic
,
dynamic
>{},
_rawData
=
rawData
??
<
dynamic
,
dynamic
>{},
...
@@ -468,9 +465,9 @@ class RestorationBucket extends ChangeNotifier {
...
@@ -468,9 +465,9 @@ class RestorationBucket extends ChangeNotifier {
///
///
/// The `restorationId` and `parent` argument must not be null.
/// The `restorationId` and `parent` argument must not be null.
RestorationBucket
.
child
({
RestorationBucket
.
child
({
@
required
String
restorationId
,
required
String
restorationId
,
@
required
RestorationBucket
parent
,
required
RestorationBucket
parent
,
@required
Object
debugOwner
,
required
Object
?
debugOwner
,
})
:
assert
(
restorationId
!=
null
),
})
:
assert
(
restorationId
!=
null
),
assert
(
parent
!=
null
),
assert
(
parent
!=
null
),
assert
(
parent
.
_rawChildren
[
restorationId
]
!=
null
),
assert
(
parent
.
_rawChildren
[
restorationId
]
!=
null
),
...
@@ -494,14 +491,14 @@ class RestorationBucket extends ChangeNotifier {
...
@@ -494,14 +491,14 @@ class RestorationBucket extends ChangeNotifier {
///
///
/// The value is used in error messages. Accessing the value is only valid
/// The value is used in error messages. Accessing the value is only valid
/// in debug mode, otherwise it will return null.
/// in debug mode, otherwise it will return null.
Object
get
debugOwner
{
Object
?
get
debugOwner
{
assert
(
_debugAssertNotDisposed
());
assert
(
_debugAssertNotDisposed
());
return
_debugOwner
;
return
_debugOwner
;
}
}
Object
_debugOwner
;
Object
?
_debugOwner
;
RestorationManager
_manager
;
RestorationManager
?
_manager
;
RestorationBucket
_parent
;
RestorationBucket
?
_parent
;
/// The restoration ID under which the bucket is currently stored in the
/// The restoration ID under which the bucket is currently stored in the
/// parent of this bucket (or wants to be stored if it is currently
/// parent of this bucket (or wants to be stored if it is currently
...
@@ -545,7 +542,7 @@ class RestorationBucket extends ChangeNotifier {
...
@@ -545,7 +542,7 @@ class RestorationBucket extends ChangeNotifier {
void
decommission
()
{
void
decommission
()
{
assert
(
_debugAssertNotDisposed
());
assert
(
_debugAssertNotDisposed
());
if
(
_parent
!=
null
)
{
if
(
_parent
!=
null
)
{
_parent
.
_dropChild
(
this
);
_parent
!
.
_dropChild
(
this
);
_parent
=
null
;
_parent
=
null
;
}
}
_performDecommission
();
_performDecommission
();
...
@@ -678,7 +675,7 @@ class RestorationBucket extends ChangeNotifier {
...
@@ -678,7 +675,7 @@ class RestorationBucket extends ChangeNotifier {
///
///
/// When the returned bucket is no longer needed, it must be [dispose]d to
/// When the returned bucket is no longer needed, it must be [dispose]d to
/// delete the information stored in it from the app's restoration data.
/// delete the information stored in it from the app's restoration data.
RestorationBucket
claimChild
(
String
restorationId
,
{
@required
Object
debugOwner
})
{
RestorationBucket
claimChild
(
String
restorationId
,
{
required
Object
?
debugOwner
})
{
assert
(
_debugAssertNotDisposed
());
assert
(
_debugAssertNotDisposed
());
assert
(
restorationId
!=
null
);
assert
(
restorationId
!=
null
);
// There are three cases to consider:
// There are three cases to consider:
...
@@ -780,7 +777,7 @@ class RestorationBucket extends ChangeNotifier {
...
@@ -780,7 +777,7 @@ class RestorationBucket extends ChangeNotifier {
bucket
.
_visitChildren
(
_recursivelyUpdateManager
);
bucket
.
_visitChildren
(
_recursivelyUpdateManager
);
}
}
void
_updateManager
(
RestorationManager
newManager
)
{
void
_updateManager
(
RestorationManager
?
newManager
)
{
if
(
_manager
==
newManager
)
{
if
(
_manager
==
newManager
)
{
return
;
return
;
}
}
...
@@ -811,7 +808,7 @@ class RestorationBucket extends ChangeNotifier {
...
@@ -811,7 +808,7 @@ class RestorationBucket extends ChangeNotifier {
error
.
addAll
(<
DiagnosticsNode
>[
error
.
addAll
(<
DiagnosticsNode
>[
ErrorDescription
(
' * "
$id
" was claimed by:'
),
ErrorDescription
(
' * "
$id
" was claimed by:'
),
...
buckets
.
map
((
RestorationBucket
bucket
)
=>
ErrorDescription
(
' *
${bucket.debugOwner}
'
)),
...
buckets
.
map
((
RestorationBucket
bucket
)
=>
ErrorDescription
(
' *
${bucket.debugOwner}
'
)),
ErrorDescription
(
' *
${_claimedChildren[id].debugOwner}
(current owner)'
),
ErrorDescription
(
' *
${_claimedChildren[id]
!
.debugOwner}
(current owner)'
),
]);
]);
}
}
throw
FlutterError
.
fromParts
(
error
);
throw
FlutterError
.
fromParts
(
error
);
...
@@ -824,7 +821,7 @@ class RestorationBucket extends ChangeNotifier {
...
@@ -824,7 +821,7 @@ class RestorationBucket extends ChangeNotifier {
assert
(
child
.
_parent
==
this
);
assert
(
child
.
_parent
==
this
);
if
(
_claimedChildren
.
remove
(
child
.
restorationId
)
==
child
)
{
if
(
_claimedChildren
.
remove
(
child
.
restorationId
)
==
child
)
{
_rawChildren
.
remove
(
child
.
restorationId
);
_rawChildren
.
remove
(
child
.
restorationId
);
final
List
<
RestorationBucket
>
pendingChildren
=
_childrenToAdd
[
child
.
restorationId
];
final
List
<
RestorationBucket
>
?
pendingChildren
=
_childrenToAdd
[
child
.
restorationId
];
if
(
pendingChildren
!=
null
)
{
if
(
pendingChildren
!=
null
)
{
final
RestorationBucket
toAdd
=
pendingChildren
.
removeLast
();
final
RestorationBucket
toAdd
=
pendingChildren
.
removeLast
();
_finalizeAddChildData
(
toAdd
);
_finalizeAddChildData
(
toAdd
);
...
@@ -893,9 +890,9 @@ class RestorationBucket extends ChangeNotifier {
...
@@ -893,9 +890,9 @@ class RestorationBucket extends ChangeNotifier {
if
(
newRestorationId
==
restorationId
)
{
if
(
newRestorationId
==
restorationId
)
{
return
;
return
;
}
}
_parent
.
_removeChildData
(
this
);
_parent
!
.
_removeChildData
(
this
);
_restorationId
=
newRestorationId
;
_restorationId
=
newRestorationId
;
_parent
.
_addChildData
(
this
);
_parent
!
.
_addChildData
(
this
);
}
}
/// Deletes the bucket and all the data stored in it from the bucket
/// Deletes the bucket and all the data stored in it from the bucket
...
@@ -946,7 +943,7 @@ class RestorationBucket extends ChangeNotifier {
...
@@ -946,7 +943,7 @@ class RestorationBucket extends ChangeNotifier {
///
///
/// Should only be called from within asserts. Always returns false outside
/// Should only be called from within asserts. Always returns false outside
/// of debug builds.
/// of debug builds.
bool
debugIsSerializableForRestoration
(
Object
object
)
{
bool
debugIsSerializableForRestoration
(
Object
?
object
)
{
bool
result
=
false
;
bool
result
=
false
;
assert
(()
{
assert
(()
{
...
...
packages/flutter/lib/src/services/system_channels.dart
View file @
7884420a
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'dart:ui'
;
import
'dart:ui'
;
...
@@ -218,7 +217,7 @@ class SystemChannels {
...
@@ -218,7 +217,7 @@ class SystemChannels {
///
///
/// * [WidgetsBindingObserver.didChangeAppLifecycleState], which triggers
/// * [WidgetsBindingObserver.didChangeAppLifecycleState], which triggers
/// whenever a message is received on this channel.
/// whenever a message is received on this channel.
static
const
BasicMessageChannel
<
String
>
lifecycle
=
BasicMessageChannel
<
String
>(
static
const
BasicMessageChannel
<
String
?>
lifecycle
=
BasicMessageChannel
<
String
?
>(
'flutter/lifecycle'
,
'flutter/lifecycle'
,
StringCodec
(),
StringCodec
(),
);
);
...
...
packages/flutter/lib/src/services/system_chrome.dart
View file @
7884420a
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'dart:async'
;
import
'dart:async'
;
import
'dart:ui'
;
import
'dart:ui'
;
...
@@ -60,13 +59,13 @@ class ApplicationSwitcherDescription {
...
@@ -60,13 +59,13 @@ class ApplicationSwitcherDescription {
const
ApplicationSwitcherDescription
({
this
.
label
,
this
.
primaryColor
});
const
ApplicationSwitcherDescription
({
this
.
label
,
this
.
primaryColor
});
/// A label and description of the current state of the application.
/// A label and description of the current state of the application.
final
String
label
;
final
String
?
label
;
/// The application's primary color.
/// The application's primary color.
///
///
/// This may influence the color that the operating system uses to represent
/// This may influence the color that the operating system uses to represent
/// the application.
/// the application.
final
int
primaryColor
;
final
int
?
primaryColor
;
}
}
/// Specifies a system overlay at a particular location.
/// Specifies a system overlay at a particular location.
...
@@ -100,32 +99,32 @@ class SystemUiOverlayStyle {
...
@@ -100,32 +99,32 @@ class SystemUiOverlayStyle {
/// The color of the system bottom navigation bar.
/// The color of the system bottom navigation bar.
///
///
/// Only honored in Android versions O and greater.
/// Only honored in Android versions O and greater.
final
Color
systemNavigationBarColor
;
final
Color
?
systemNavigationBarColor
;
/// The color of the divider between the system's bottom navigation bar and the app's content.
/// The color of the divider between the system's bottom navigation bar and the app's content.
///
///
/// Only honored in Android versions P and greater.
/// Only honored in Android versions P and greater.
final
Color
systemNavigationBarDividerColor
;
final
Color
?
systemNavigationBarDividerColor
;
/// The brightness of the system navigation bar icons.
/// The brightness of the system navigation bar icons.
///
///
/// Only honored in Android versions O and greater.
/// Only honored in Android versions O and greater.
final
Brightness
systemNavigationBarIconBrightness
;
final
Brightness
?
systemNavigationBarIconBrightness
;
/// The color of top status bar.
/// The color of top status bar.
///
///
/// Only honored in Android version M and greater.
/// Only honored in Android version M and greater.
final
Color
statusBarColor
;
final
Color
?
statusBarColor
;
/// The brightness of top status bar.
/// The brightness of top status bar.
///
///
/// Only honored in iOS.
/// Only honored in iOS.
final
Brightness
statusBarBrightness
;
final
Brightness
?
statusBarBrightness
;
/// The brightness of the top status bar icons.
/// The brightness of the top status bar icons.
///
///
/// Only honored in Android version M and greater.
/// Only honored in Android version M and greater.
final
Brightness
statusBarIconBrightness
;
final
Brightness
?
statusBarIconBrightness
;
/// System overlays should be drawn with a light color. Intended for
/// System overlays should be drawn with a light color. Intended for
/// applications with a dark background.
/// applications with a dark background.
...
@@ -166,12 +165,12 @@ class SystemUiOverlayStyle {
...
@@ -166,12 +165,12 @@ class SystemUiOverlayStyle {
/// Creates a copy of this theme with the given fields replaced with new values.
/// Creates a copy of this theme with the given fields replaced with new values.
SystemUiOverlayStyle
copyWith
({
SystemUiOverlayStyle
copyWith
({
Color
systemNavigationBarColor
,
Color
?
systemNavigationBarColor
,
Color
systemNavigationBarDividerColor
,
Color
?
systemNavigationBarDividerColor
,
Color
statusBarColor
,
Color
?
statusBarColor
,
Brightness
statusBarBrightness
,
Brightness
?
statusBarBrightness
,
Brightness
statusBarIconBrightness
,
Brightness
?
statusBarIconBrightness
,
Brightness
systemNavigationBarIconBrightness
,
Brightness
?
systemNavigationBarIconBrightness
,
})
{
})
{
return
SystemUiOverlayStyle
(
return
SystemUiOverlayStyle
(
systemNavigationBarColor:
systemNavigationBarColor
??
this
.
systemNavigationBarColor
,
systemNavigationBarColor:
systemNavigationBarColor
??
this
.
systemNavigationBarColor
,
...
@@ -406,7 +405,7 @@ class SystemChrome {
...
@@ -406,7 +405,7 @@ class SystemChrome {
if
(
_pendingStyle
!=
_latestStyle
)
{
if
(
_pendingStyle
!=
_latestStyle
)
{
SystemChannels
.
platform
.
invokeMethod
<
void
>(
SystemChannels
.
platform
.
invokeMethod
<
void
>(
'SystemChrome.setSystemUIOverlayStyle'
,
'SystemChrome.setSystemUIOverlayStyle'
,
_pendingStyle
.
_toMap
(),
_pendingStyle
!
.
_toMap
(),
);
);
_latestStyle
=
_pendingStyle
;
_latestStyle
=
_pendingStyle
;
}
}
...
@@ -414,10 +413,10 @@ class SystemChrome {
...
@@ -414,10 +413,10 @@ class SystemChrome {
});
});
}
}
static
SystemUiOverlayStyle
_pendingStyle
;
static
SystemUiOverlayStyle
?
_pendingStyle
;
/// The last style that was set using [SystemChrome.setSystemUIOverlayStyle].
/// The last style that was set using [SystemChrome.setSystemUIOverlayStyle].
@visibleForTesting
@visibleForTesting
static
SystemUiOverlayStyle
get
latestStyle
=>
_latestStyle
;
static
SystemUiOverlayStyle
?
get
latestStyle
=>
_latestStyle
;
static
SystemUiOverlayStyle
_latestStyle
;
static
SystemUiOverlayStyle
?
_latestStyle
;
}
}
packages/flutter/lib/src/services/system_navigator.dart
View file @
7884420a
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'dart:async'
;
import
'dart:async'
;
...
@@ -33,7 +32,7 @@ class SystemNavigator {
...
@@ -33,7 +32,7 @@ class SystemNavigator {
/// This method should be preferred over calling `dart:io`'s [exit]
/// This method should be preferred over calling `dart:io`'s [exit]
/// method, as the latter may cause the underlying platform to act
/// method, as the latter may cause the underlying platform to act
/// as if the application had crashed.
/// as if the application had crashed.
static
Future
<
void
>
pop
({
bool
animated
})
async
{
static
Future
<
void
>
pop
({
bool
?
animated
})
async
{
await
SystemChannels
.
platform
.
invokeMethod
<
void
>(
'SystemNavigator.pop'
,
animated
);
await
SystemChannels
.
platform
.
invokeMethod
<
void
>(
'SystemNavigator.pop'
,
animated
);
}
}
}
}
packages/flutter/lib/src/services/system_sound.dart
View file @
7884420a
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'dart:async'
;
import
'dart:async'
;
...
...
packages/flutter/lib/src/services/text_editing.dart
View file @
7884420a
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'dart:ui'
show
hashValues
,
TextAffinity
,
TextPosition
,
TextRange
;
import
'dart:ui'
show
hashValues
,
TextAffinity
,
TextPosition
,
TextRange
;
...
@@ -17,8 +16,8 @@ class TextSelection extends TextRange {
...
@@ -17,8 +16,8 @@ class TextSelection extends TextRange {
///
///
/// The [baseOffset] and [extentOffset] arguments must not be null.
/// The [baseOffset] and [extentOffset] arguments must not be null.
const
TextSelection
({
const
TextSelection
({
@
required
this
.
baseOffset
,
required
this
.
baseOffset
,
@
required
this
.
extentOffset
,
required
this
.
extentOffset
,
this
.
affinity
=
TextAffinity
.
downstream
,
this
.
affinity
=
TextAffinity
.
downstream
,
this
.
isDirectional
=
false
,
this
.
isDirectional
=
false
,
})
:
super
(
})
:
super
(
...
@@ -34,7 +33,7 @@ class TextSelection extends TextRange {
...
@@ -34,7 +33,7 @@ class TextSelection extends TextRange {
///
///
/// The [offset] argument must not be null.
/// The [offset] argument must not be null.
const
TextSelection
.
collapsed
({
const
TextSelection
.
collapsed
({
@
required
int
offset
,
required
int
offset
,
this
.
affinity
=
TextAffinity
.
downstream
,
this
.
affinity
=
TextAffinity
.
downstream
,
})
:
baseOffset
=
offset
,
})
:
baseOffset
=
offset
,
extentOffset
=
offset
,
extentOffset
=
offset
,
...
@@ -121,10 +120,10 @@ class TextSelection extends TextRange {
...
@@ -121,10 +120,10 @@ class TextSelection extends TextRange {
/// Creates a new [TextSelection] based on the current selection, with the
/// Creates a new [TextSelection] based on the current selection, with the
/// provided parameters overridden.
/// provided parameters overridden.
TextSelection
copyWith
({
TextSelection
copyWith
({
int
baseOffset
,
int
?
baseOffset
,
int
extentOffset
,
int
?
extentOffset
,
TextAffinity
affinity
,
TextAffinity
?
affinity
,
bool
isDirectional
,
bool
?
isDirectional
,
})
{
})
{
return
TextSelection
(
return
TextSelection
(
baseOffset:
baseOffset
??
this
.
baseOffset
,
baseOffset:
baseOffset
??
this
.
baseOffset
,
...
...
packages/flutter/lib/src/services/text_formatter.dart
View file @
7884420a
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'dart:math'
as
math
;
import
'dart:math'
as
math
;
...
@@ -103,7 +102,7 @@ class FilteringTextInputFormatter extends TextInputFormatter {
...
@@ -103,7 +102,7 @@ class FilteringTextInputFormatter extends TextInputFormatter {
/// must not be null.
/// must not be null.
FilteringTextInputFormatter
(
FilteringTextInputFormatter
(
this
.
filterPattern
,
{
this
.
filterPattern
,
{
@
required
this
.
allow
,
required
this
.
allow
,
this
.
replacementString
=
''
,
this
.
replacementString
=
''
,
})
:
assert
(
filterPattern
!=
null
),
})
:
assert
(
filterPattern
!=
null
),
assert
(
allow
!=
null
),
assert
(
allow
!=
null
),
...
@@ -342,7 +341,7 @@ class LengthLimitingTextInputFormatter extends TextInputFormatter {
...
@@ -342,7 +341,7 @@ class LengthLimitingTextInputFormatter extends TextInputFormatter {
/// counted as a single character, but because it is a combination of two
/// counted as a single character, but because it is a combination of two
/// Unicode scalar values, '\u{1F44D}\u{1F3FD}', it is counted as two
/// Unicode scalar values, '\u{1F44D}\u{1F3FD}', it is counted as two
/// characters.
/// characters.
final
int
maxLength
;
final
int
?
maxLength
;
/// Truncate the given TextEditingValue to maxLength characters.
/// Truncate the given TextEditingValue to maxLength characters.
///
///
...
@@ -371,13 +370,13 @@ class LengthLimitingTextInputFormatter extends TextInputFormatter {
...
@@ -371,13 +370,13 @@ class LengthLimitingTextInputFormatter extends TextInputFormatter {
TextEditingValue
oldValue
,
// unused.
TextEditingValue
oldValue
,
// unused.
TextEditingValue
newValue
,
TextEditingValue
newValue
,
)
{
)
{
if
(
maxLength
!=
null
&&
maxLength
>
0
&&
newValue
.
text
.
characters
.
length
>
maxLength
)
{
if
(
maxLength
!=
null
&&
maxLength
!
>
0
&&
newValue
.
text
.
characters
.
length
>
maxLength
!
)
{
// If already at the maximum and tried to enter even more, keep the old
// If already at the maximum and tried to enter even more, keep the old
// value.
// value.
if
(
oldValue
.
text
.
characters
.
length
==
maxLength
)
{
if
(
oldValue
.
text
.
characters
.
length
==
maxLength
)
{
return
oldValue
;
return
oldValue
;
}
}
return
truncate
(
newValue
,
maxLength
);
return
truncate
(
newValue
,
maxLength
!
);
}
}
return
newValue
;
return
newValue
;
}
}
...
@@ -390,7 +389,7 @@ TextEditingValue _selectionAwareTextManipulation(
...
@@ -390,7 +389,7 @@ TextEditingValue _selectionAwareTextManipulation(
final
int
selectionStartIndex
=
value
.
selection
.
start
;
final
int
selectionStartIndex
=
value
.
selection
.
start
;
final
int
selectionEndIndex
=
value
.
selection
.
end
;
final
int
selectionEndIndex
=
value
.
selection
.
end
;
String
manipulatedText
;
String
manipulatedText
;
TextSelection
manipulatedSelection
;
TextSelection
?
manipulatedSelection
;
if
(
selectionStartIndex
<
0
||
selectionEndIndex
<
0
)
{
if
(
selectionStartIndex
<
0
||
selectionEndIndex
<
0
)
{
manipulatedText
=
substringManipulation
(
value
.
text
);
manipulatedText
=
substringManipulation
(
value
.
text
);
}
else
{
}
else
{
...
...
packages/flutter/lib/src/services/text_input.dart
View file @
7884420a
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'dart:async'
;
import
'dart:async'
;
import
'dart:io'
show
Platform
;
import
'dart:io'
show
Platform
;
...
@@ -101,13 +100,13 @@ class TextInputType {
...
@@ -101,13 +100,13 @@ class TextInputType {
///
///
/// This flag is only used for the [number] input type, otherwise `null`.
/// This flag is only used for the [number] input type, otherwise `null`.
/// Use `const TextInputType.numberWithOptions(signed: true)` to set this.
/// Use `const TextInputType.numberWithOptions(signed: true)` to set this.
final
bool
signed
;
final
bool
?
signed
;
/// The number is decimal, allowing a decimal point to provide fractional.
/// The number is decimal, allowing a decimal point to provide fractional.
///
///
/// This flag is only used for the [number] input type, otherwise `null`.
/// This flag is only used for the [number] input type, otherwise `null`.
/// Use `const TextInputType.numberWithOptions(decimal: true)` to set this.
/// Use `const TextInputType.numberWithOptions(decimal: true)` to set this.
final
bool
decimal
;
final
bool
?
decimal
;
/// Optimize for textual information.
/// Optimize for textual information.
///
///
...
@@ -450,8 +449,8 @@ class TextInputConfiguration {
...
@@ -450,8 +449,8 @@ class TextInputConfiguration {
this
.
inputType
=
TextInputType
.
text
,
this
.
inputType
=
TextInputType
.
text
,
this
.
obscureText
=
false
,
this
.
obscureText
=
false
,
this
.
autocorrect
=
true
,
this
.
autocorrect
=
true
,
SmartDashesType
smartDashesType
,
SmartDashesType
?
smartDashesType
,
SmartQuotesType
smartQuotesType
,
SmartQuotesType
?
smartQuotesType
,
this
.
enableSuggestions
=
true
,
this
.
enableSuggestions
=
true
,
this
.
actionLabel
,
this
.
actionLabel
,
this
.
inputAction
=
TextInputAction
.
done
,
this
.
inputAction
=
TextInputAction
.
done
,
...
@@ -487,7 +486,7 @@ class TextInputConfiguration {
...
@@ -487,7 +486,7 @@ class TextInputConfiguration {
/// to the platform. This will prevent the corresponding input field from
/// to the platform. This will prevent the corresponding input field from
/// participating in autofills triggered by other fields. Additionally, on
/// participating in autofills triggered by other fields. Additionally, on
/// Android and web, setting [autofillConfiguration] to null disables autofill.
/// Android and web, setting [autofillConfiguration] to null disables autofill.
final
AutofillConfiguration
autofillConfiguration
;
final
AutofillConfiguration
?
autofillConfiguration
;
/// {@template flutter.services.textInput.smartDashesType}
/// {@template flutter.services.textInput.smartDashesType}
/// Whether to allow the platform to automatically format dashes.
/// Whether to allow the platform to automatically format dashes.
...
@@ -555,7 +554,7 @@ class TextInputConfiguration {
...
@@ -555,7 +554,7 @@ class TextInputConfiguration {
final
bool
enableSuggestions
;
final
bool
enableSuggestions
;
/// What text to display in the text input control's action button.
/// What text to display in the text input control's action button.
final
String
actionLabel
;
final
String
?
actionLabel
;
/// What kind of action to request for the action button on the IME.
/// What kind of action to request for the action button on the IME.
final
TextInputAction
inputAction
;
final
TextInputAction
inputAction
;
...
@@ -590,12 +589,12 @@ class TextInputConfiguration {
...
@@ -590,12 +589,12 @@ class TextInputConfiguration {
'inputAction'
:
inputAction
.
toString
(),
'inputAction'
:
inputAction
.
toString
(),
'textCapitalization'
:
textCapitalization
.
toString
(),
'textCapitalization'
:
textCapitalization
.
toString
(),
'keyboardAppearance'
:
keyboardAppearance
.
toString
(),
'keyboardAppearance'
:
keyboardAppearance
.
toString
(),
if
(
autofillConfiguration
!=
null
)
'autofill'
:
autofillConfiguration
.
toJson
(),
if
(
autofillConfiguration
!=
null
)
'autofill'
:
autofillConfiguration
!
.
toJson
(),
};
};
}
}
}
}
TextAffinity
_toTextAffinity
(
String
affinity
)
{
TextAffinity
?
_toTextAffinity
(
String
affinity
)
{
switch
(
affinity
)
{
switch
(
affinity
)
{
case
'TextAffinity.downstream'
:
case
'TextAffinity.downstream'
:
return
TextAffinity
.
downstream
;
return
TextAffinity
.
downstream
;
...
@@ -628,12 +627,12 @@ class RawFloatingCursorPoint {
...
@@ -628,12 +627,12 @@ class RawFloatingCursorPoint {
/// [FloatingCursorDragState.Update].
/// [FloatingCursorDragState.Update].
RawFloatingCursorPoint
({
RawFloatingCursorPoint
({
this
.
offset
,
this
.
offset
,
@
required
this
.
state
,
required
this
.
state
,
})
:
assert
(
state
!=
null
),
})
:
assert
(
state
!=
null
),
assert
(
state
!=
FloatingCursorDragState
.
Update
||
offset
!=
null
);
assert
(
state
!=
FloatingCursorDragState
.
Update
||
offset
!=
null
);
/// The raw position of the floating cursor as determined by the iOS sdk.
/// The raw position of the floating cursor as determined by the iOS sdk.
final
Offset
offset
;
final
Offset
?
offset
;
/// The state of the floating cursor.
/// The state of the floating cursor.
final
FloatingCursorDragState
state
;
final
FloatingCursorDragState
state
;
...
@@ -661,14 +660,14 @@ class TextEditingValue {
...
@@ -661,14 +660,14 @@ class TextEditingValue {
return
TextEditingValue
(
return
TextEditingValue
(
text:
encoded
[
'text'
]
as
String
,
text:
encoded
[
'text'
]
as
String
,
selection:
TextSelection
(
selection:
TextSelection
(
baseOffset:
encoded
[
'selectionBase'
]
as
int
??
-
1
,
baseOffset:
encoded
[
'selectionBase'
]
as
int
?
??
-
1
,
extentOffset:
encoded
[
'selectionExtent'
]
as
int
??
-
1
,
extentOffset:
encoded
[
'selectionExtent'
]
as
int
?
??
-
1
,
affinity:
_toTextAffinity
(
encoded
[
'selectionAffinity'
]
as
String
)
??
TextAffinity
.
downstream
,
affinity:
_toTextAffinity
(
encoded
[
'selectionAffinity'
]
as
String
)
??
TextAffinity
.
downstream
,
isDirectional:
encoded
[
'selectionIsDirectional'
]
as
bool
??
false
,
isDirectional:
encoded
[
'selectionIsDirectional'
]
as
bool
?
??
false
,
),
),
composing:
TextRange
(
composing:
TextRange
(
start:
encoded
[
'composingBase'
]
as
int
??
-
1
,
start:
encoded
[
'composingBase'
]
as
int
?
??
-
1
,
end:
encoded
[
'composingExtent'
]
as
int
??
-
1
,
end:
encoded
[
'composingExtent'
]
as
int
?
??
-
1
,
),
),
);
);
}
}
...
@@ -700,9 +699,9 @@ class TextEditingValue {
...
@@ -700,9 +699,9 @@ class TextEditingValue {
/// Creates a copy of this value but with the given fields replaced with the new values.
/// Creates a copy of this value but with the given fields replaced with the new values.
TextEditingValue
copyWith
({
TextEditingValue
copyWith
({
String
text
,
String
?
text
,
TextSelection
selection
,
TextSelection
?
selection
,
TextRange
composing
,
TextRange
?
composing
,
})
{
})
{
return
TextEditingValue
(
return
TextEditingValue
(
text:
text
??
this
.
text
,
text:
text
??
this
.
text
,
...
@@ -795,7 +794,7 @@ abstract class TextInputClient {
...
@@ -795,7 +794,7 @@ abstract class TextInputClient {
///
///
/// * [AutofillGroup], a widget that creates an [AutofillScope] for its
/// * [AutofillGroup], a widget that creates an [AutofillScope] for its
/// descendent autofillable [TextInputClient]s.
/// descendent autofillable [TextInputClient]s.
AutofillScope
get
currentAutofillScope
;
AutofillScope
?
get
currentAutofillScope
;
/// Requests that this client update its editing state to the given value.
/// Requests that this client update its editing state to the given value.
void
updateEditingValue
(
TextEditingValue
value
);
void
updateEditingValue
(
TextEditingValue
value
);
...
@@ -828,8 +827,8 @@ class TextInputConnection {
...
@@ -828,8 +827,8 @@ class TextInputConnection {
:
assert
(
_client
!=
null
),
:
assert
(
_client
!=
null
),
_id
=
_nextId
++;
_id
=
_nextId
++;
Size
_cachedSize
;
Size
?
_cachedSize
;
Matrix4
_cachedTransform
;
Matrix4
?
_cachedTransform
;
static
int
_nextId
=
1
;
static
int
_nextId
=
1
;
final
int
_id
;
final
int
_id
;
...
@@ -906,11 +905,11 @@ class TextInputConnection {
...
@@ -906,11 +905,11 @@ class TextInputConnection {
/// of the hidden native input's content. Hence, the content size will match
/// of the hidden native input's content. Hence, the content size will match
/// to the size of the editable widget's content.
/// to the size of the editable widget's content.
void
setStyle
({
void
setStyle
({
@required
String
fontFamily
,
required
String
?
fontFamily
,
@required
double
fontSize
,
required
double
?
fontSize
,
@required
FontWeight
fontWeight
,
required
FontWeight
?
fontWeight
,
@
required
TextDirection
textDirection
,
required
TextDirection
textDirection
,
@
required
TextAlign
textAlign
,
required
TextAlign
textAlign
,
})
{
})
{
assert
(
attached
);
assert
(
attached
);
...
@@ -1108,10 +1107,10 @@ class TextInput {
...
@@ -1108,10 +1107,10 @@ class TextInput {
return
true
;
return
true
;
}
}
MethodChannel
_channel
;
late
MethodChannel
_channel
;
TextInputConnection
_currentConnection
;
TextInputConnection
?
_currentConnection
;
TextInputConfiguration
_currentConfiguration
;
late
TextInputConfiguration
_currentConfiguration
;
Future
<
dynamic
>
_handleTextInputInvocation
(
MethodCall
methodCall
)
async
{
Future
<
dynamic
>
_handleTextInputInvocation
(
MethodCall
methodCall
)
async
{
if
(
_currentConnection
==
null
)
if
(
_currentConnection
==
null
)
...
@@ -1121,9 +1120,9 @@ class TextInput {
...
@@ -1121,9 +1120,9 @@ class TextInput {
// The requestExistingInputState request needs to be handled regardless of
// The requestExistingInputState request needs to be handled regardless of
// the client ID, as long as we have a _currentConnection.
// the client ID, as long as we have a _currentConnection.
if
(
method
==
'TextInputClient.requestExistingInputState'
)
{
if
(
method
==
'TextInputClient.requestExistingInputState'
)
{
assert
(
_currentConnection
.
_client
!=
null
);
assert
(
_currentConnection
!
.
_client
!=
null
);
_attach
(
_currentConnection
,
_currentConfiguration
);
_attach
(
_currentConnection
!
,
_currentConfiguration
);
final
TextEditingValue
editingValue
=
_currentConnection
.
_client
.
currentTextEditingValue
;
final
TextEditingValue
editingValue
=
_currentConnection
!
.
_client
.
currentTextEditingValue
;
if
(
editingValue
!=
null
)
{
if
(
editingValue
!=
null
)
{
_setEditingState
(
editingValue
);
_setEditingState
(
editingValue
);
}
}
...
@@ -1133,9 +1132,9 @@ class TextInput {
...
@@ -1133,9 +1132,9 @@ class TextInput {
final
List
<
dynamic
>
args
=
methodCall
.
arguments
as
List
<
dynamic
>;
final
List
<
dynamic
>
args
=
methodCall
.
arguments
as
List
<
dynamic
>;
if
(
method
==
'TextInputClient.updateEditingStateWithTag'
)
{
if
(
method
==
'TextInputClient.updateEditingStateWithTag'
)
{
final
TextInputClient
client
=
_currentConnection
.
_client
;
final
TextInputClient
client
=
_currentConnection
!
.
_client
;
assert
(
client
!=
null
);
assert
(
client
!=
null
);
final
AutofillScope
scope
=
client
.
currentAutofillScope
;
final
AutofillScope
?
scope
=
client
.
currentAutofillScope
;
final
Map
<
String
,
dynamic
>
editingValue
=
args
[
1
]
as
Map
<
String
,
dynamic
>;
final
Map
<
String
,
dynamic
>
editingValue
=
args
[
1
]
as
Map
<
String
,
dynamic
>;
for
(
final
String
tag
in
editingValue
.
keys
)
{
for
(
final
String
tag
in
editingValue
.
keys
)
{
final
TextEditingValue
textEditingValue
=
TextEditingValue
.
fromJSON
(
final
TextEditingValue
textEditingValue
=
TextEditingValue
.
fromJSON
(
...
@@ -1149,26 +1148,26 @@ class TextInput {
...
@@ -1149,26 +1148,26 @@ class TextInput {
final
int
client
=
args
[
0
]
as
int
;
final
int
client
=
args
[
0
]
as
int
;
// The incoming message was for a different client.
// The incoming message was for a different client.
if
(
client
!=
_currentConnection
.
_id
)
if
(
client
!=
_currentConnection
!
.
_id
)
return
;
return
;
switch
(
method
)
{
switch
(
method
)
{
case
'TextInputClient.updateEditingState'
:
case
'TextInputClient.updateEditingState'
:
_currentConnection
.
_client
.
updateEditingValue
(
TextEditingValue
.
fromJSON
(
args
[
1
]
as
Map
<
String
,
dynamic
>));
_currentConnection
!
.
_client
.
updateEditingValue
(
TextEditingValue
.
fromJSON
(
args
[
1
]
as
Map
<
String
,
dynamic
>));
break
;
break
;
case
'TextInputClient.performAction'
:
case
'TextInputClient.performAction'
:
_currentConnection
.
_client
.
performAction
(
_toTextInputAction
(
args
[
1
]
as
String
));
_currentConnection
!
.
_client
.
performAction
(
_toTextInputAction
(
args
[
1
]
as
String
));
break
;
break
;
case
'TextInputClient.updateFloatingCursor'
:
case
'TextInputClient.updateFloatingCursor'
:
_currentConnection
.
_client
.
updateFloatingCursor
(
_toTextPoint
(
_currentConnection
!
.
_client
.
updateFloatingCursor
(
_toTextPoint
(
_toTextCursorAction
(
args
[
1
]
as
String
),
_toTextCursorAction
(
args
[
1
]
as
String
),
args
[
2
]
as
Map
<
String
,
dynamic
>,
args
[
2
]
as
Map
<
String
,
dynamic
>,
));
));
break
;
break
;
case
'TextInputClient.onConnectionClosed'
:
case
'TextInputClient.onConnectionClosed'
:
_currentConnection
.
_client
.
connectionClosed
();
_currentConnection
!
.
_client
.
connectionClosed
();
break
;
break
;
case
'TextInputClient.showAutocorrectionPromptRect'
:
case
'TextInputClient.showAutocorrectionPromptRect'
:
_currentConnection
.
_client
.
showAutocorrectionPromptRect
(
args
[
1
]
as
int
,
args
[
2
]
as
int
);
_currentConnection
!
.
_client
.
showAutocorrectionPromptRect
(
args
[
1
]
as
int
,
args
[
2
]
as
int
);
break
;
break
;
default
:
default
:
throw
MissingPluginException
();
throw
MissingPluginException
();
...
...
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