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
075991c2
Unverified
Commit
075991c2
authored
Jun 07, 2021
by
Michael Goderbauer
Committed by
GitHub
Jun 07, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate hybrid_android_views to null safety (#84140)
parent
64bf4ed4
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
33 additions
and
33 deletions
+33
-33
android_platform_view.dart
...tests/hybrid_android_views/lib/android_platform_view.dart
+4
-4
future_data_handler.dart
...n_tests/hybrid_android_views/lib/future_data_handler.dart
+3
-3
main.dart
dev/integration_tests/hybrid_android_views/lib/main.dart
+1
-1
motion_events_page.dart
...on_tests/hybrid_android_views/lib/motion_events_page.dart
+13
-13
nested_view_event_page.dart
...ests/hybrid_android_views/lib/nested_view_event_page.dart
+9
-9
page.dart
dev/integration_tests/hybrid_android_views/lib/page.dart
+1
-1
pubspec.yaml
dev/integration_tests/hybrid_android_views/pubspec.yaml
+1
-1
main_test.dart
...ion_tests/hybrid_android_views/test_driver/main_test.dart
+1
-1
No files found.
dev/integration_tests/hybrid_android_views/lib/android_platform_view.dart
View file @
075991c2
...
...
@@ -15,9 +15,9 @@ class AndroidPlatformView extends StatelessWidget {
/// native view.
/// `viewType` identifies the type of Android view to create.
const
AndroidPlatformView
({
Key
key
,
Key
?
key
,
this
.
onPlatformViewCreated
,
@
required
this
.
viewType
,
required
this
.
viewType
,
})
:
assert
(
viewType
!=
null
),
super
(
key:
key
);
...
...
@@ -29,7 +29,7 @@ class AndroidPlatformView extends StatelessWidget {
/// Callback to invoke after the platform view has been created.
///
/// May be null.
final
PlatformViewCreatedCallback
onPlatformViewCreated
;
final
PlatformViewCreatedCallback
?
onPlatformViewCreated
;
@override
Widget
build
(
BuildContext
context
)
{
...
...
@@ -52,7 +52,7 @@ class AndroidPlatformView extends StatelessWidget {
)
..
addOnPlatformViewCreatedListener
(
params
.
onPlatformViewCreated
);
if
(
onPlatformViewCreated
!=
null
)
{
controller
.
addOnPlatformViewCreatedListener
(
onPlatformViewCreated
);
controller
.
addOnPlatformViewCreatedListener
(
onPlatformViewCreated
!
);
}
return
controller
..
create
();
},
...
...
dev/integration_tests/hybrid_android_views/lib/future_data_handler.dart
View file @
075991c2
...
...
@@ -19,15 +19,15 @@ class FutureDataHandler {
/// Registers a lazy handler that will be invoked on the next message from the driver.
Completer
<
DriverHandler
>
registerHandler
(
String
key
)
{
_handlers
[
key
]
=
Completer
<
DriverHandler
>();
return
_handlers
[
key
];
return
_handlers
[
key
]
!
;
}
Future
<
String
>
handleMessage
(
String
message
)
async
{
Future
<
String
>
handleMessage
(
String
?
message
)
async
{
if
(
_handlers
[
message
]
==
null
)
{
return
'Unsupported driver message:
$message
.
\n
'
'Supported messages are:
${_handlers.keys}
.'
;
}
final
DriverHandler
handler
=
await
_handlers
[
message
].
future
;
final
DriverHandler
handler
=
await
_handlers
[
message
]
!
.
future
;
return
handler
();
}
}
...
...
dev/integration_tests/hybrid_android_views/lib/main.dart
View file @
075991c2
...
...
@@ -21,7 +21,7 @@ void main() {
}
class
Home
extends
StatelessWidget
{
const
Home
({
Key
key
})
:
super
(
key:
key
);
const
Home
({
Key
?
key
})
:
super
(
key:
key
);
@override
Widget
build
(
BuildContext
context
)
{
...
...
dev/integration_tests/hybrid_android_views/lib/motion_events_page.dart
View file @
075991c2
...
...
@@ -17,7 +17,7 @@ import 'page.dart';
const
String
kEventsFileName
=
'touchEvents'
;
class
MotionEventsPage
extends
PageWidget
{
const
MotionEventsPage
({
Key
key
})
const
MotionEventsPage
({
Key
?
key
})
:
super
(
'Motion Event Tests'
,
const
ValueKey
<
String
>(
'MotionEventsListTile'
),
key:
key
);
@override
...
...
@@ -27,7 +27,7 @@ class MotionEventsPage extends PageWidget {
}
class
MotionEventsBody
extends
StatefulWidget
{
const
MotionEventsBody
({
Key
key
})
:
super
(
key:
key
);
const
MotionEventsBody
({
Key
?
key
})
:
super
(
key:
key
);
@override
State
createState
()
=>
MotionEventsBodyState
();
...
...
@@ -36,7 +36,7 @@ class MotionEventsBody extends StatefulWidget {
class
MotionEventsBodyState
extends
State
<
MotionEventsBody
>
{
static
const
int
kEventsBufferSize
=
1000
;
MethodChannel
viewChannel
;
MethodChannel
?
viewChannel
;
/// The list of motion events that were passed to the FlutterView.
List
<
Map
<
String
,
dynamic
>>
flutterViewEvents
=
<
Map
<
String
,
dynamic
>>[];
...
...
@@ -87,7 +87,7 @@ class MotionEventsBodyState extends State<MotionEventsBody> {
onPressed:
()
{
const
StandardMessageCodec
codec
=
StandardMessageCodec
();
saveRecordedEvents
(
codec
.
encodeMessage
(
flutterViewEvents
),
context
);
codec
.
encodeMessage
(
flutterViewEvents
)
!
,
context
);
},
),
),
...
...
@@ -120,13 +120,13 @@ class MotionEventsBodyState extends State<MotionEventsBody> {
.
cast
<
Map
<
dynamic
,
dynamic
>>()
.
map
<
Map
<
String
,
dynamic
>>((
Map
<
dynamic
,
dynamic
>
e
)
=>
e
.
cast
<
String
,
dynamic
>())
.
toList
();
await
viewChannel
.
invokeMethod
<
void
>(
'pipeTouchEvents'
);
await
viewChannel
!
.
invokeMethod
<
void
>(
'pipeTouchEvents'
);
print
(
'replaying
${recordedEvents.length}
motion events'
);
for
(
final
Map
<
String
,
dynamic
>
event
in
recordedEvents
.
reversed
)
{
await
channel
.
invokeMethod
<
void
>(
'synthesizeEvent'
,
event
);
}
await
viewChannel
.
invokeMethod
<
void
>(
'stopTouchEvents'
);
await
viewChannel
!
.
invokeMethod
<
void
>(
'stopTouchEvents'
);
if
(
flutterViewEvents
.
length
!=
embeddedViewEvents
.
length
)
return
'Synthesized
${flutterViewEvents.length}
events but the embedded view received
${embeddedViewEvents.length}
events'
;
...
...
@@ -153,13 +153,13 @@ class MotionEventsBodyState extends State<MotionEventsBody> {
}
Future
<
void
>
saveRecordedEvents
(
ByteData
data
,
BuildContext
context
)
async
{
if
(
!
await
channel
.
invokeMethod
<
bool
>(
'getStoragePermission'
)
)
{
if
(
await
channel
.
invokeMethod
<
bool
>(
'getStoragePermission'
)
!=
true
)
{
showMessage
(
context
,
'External storage permissions are required to save events'
);
return
;
}
try
{
final
Directory
outDir
=
await
getExternalStorageDirectory
()
;
final
Directory
outDir
=
(
await
getExternalStorageDirectory
())!
;
// This test only runs on Android so we can assume path separator is '/'.
final
File
file
=
File
(
'
${outDir.path}
/
$kEventsFileName
'
);
await
file
.
writeAsBytes
(
data
.
buffer
.
asUint8List
(
0
,
data
.
lengthInBytes
),
flush:
true
);
...
...
@@ -177,15 +177,15 @@ class MotionEventsBodyState extends State<MotionEventsBody> {
}
void
onPlatformViewCreated
(
int
id
)
{
viewChannel
=
MethodChannel
(
'simple_view/
$id
'
)
;
viewChannel
.
setMethodCallHandler
(
onViewMethodChannelCall
);
viewChannel
=
MethodChannel
(
'simple_view/
$id
'
)
.
.
setMethodCallHandler
(
onViewMethodChannelCall
);
driverDataHandler
.
registerHandler
(
'run test'
).
complete
(
playEventsFile
);
}
void
listenToFlutterViewEvents
()
{
viewChannel
.
invokeMethod
<
void
>(
'pipeTouchEvents'
);
viewChannel
!
.
invokeMethod
<
void
>(
'pipeTouchEvents'
);
Timer
(
const
Duration
(
seconds:
3
),
()
{
viewChannel
.
invokeMethod
<
void
>(
'stopTouchEvents'
);
viewChannel
!
.
invokeMethod
<
void
>(
'stopTouchEvents'
);
});
}
...
...
@@ -225,7 +225,7 @@ class MotionEventsBodyState extends State<MotionEventsBody> {
}
class
TouchEventDiff
extends
StatelessWidget
{
const
TouchEventDiff
(
this
.
originalEvent
,
this
.
synthesizedEvent
,
{
Key
key
})
:
super
(
key:
key
);
const
TouchEventDiff
(
this
.
originalEvent
,
this
.
synthesizedEvent
,
{
Key
?
key
})
:
super
(
key:
key
);
final
Map
<
String
,
dynamic
>
originalEvent
;
final
Map
<
String
,
dynamic
>
synthesizedEvent
;
...
...
dev/integration_tests/hybrid_android_views/lib/nested_view_event_page.dart
View file @
075991c2
...
...
@@ -12,7 +12,7 @@ import 'future_data_handler.dart';
import
'page.dart'
;
class
NestedViewEventPage
extends
PageWidget
{
const
NestedViewEventPage
({
Key
key
})
const
NestedViewEventPage
({
Key
?
key
})
:
super
(
'Nested View Event Tests'
,
const
ValueKey
<
String
>(
'NestedViewEventTile'
),
key:
key
);
@override
...
...
@@ -20,7 +20,7 @@ class NestedViewEventPage extends PageWidget {
}
class
NestedViewEventBody
extends
StatefulWidget
{
const
NestedViewEventBody
({
Key
key
})
:
super
(
key:
key
);
const
NestedViewEventBody
({
Key
?
key
})
:
super
(
key:
key
);
@override
State
<
NestedViewEventBody
>
createState
()
=>
NestedViewEventBodyState
();
...
...
@@ -33,10 +33,10 @@ enum _LastTestStatus {
}
class
NestedViewEventBodyState
extends
State
<
NestedViewEventBody
>
{
MethodChannel
viewChannel
;
MethodChannel
?
viewChannel
;
_LastTestStatus
_lastTestStatus
=
_LastTestStatus
.
pending
;
String
lastError
;
int
id
;
String
?
lastError
;
int
?
id
;
int
nestedViewClickCount
=
0
;
bool
showPlatformView
=
true
;
...
...
@@ -96,7 +96,7 @@ class NestedViewEventBodyState extends State<NestedViewEventBody> {
Widget
_statusWidget
()
{
assert
(
_lastTestStatus
!=
_LastTestStatus
.
pending
);
final
String
message
=
_lastTestStatus
==
_LastTestStatus
.
success
?
'Success'
:
lastError
;
final
String
message
=
_lastTestStatus
==
_LastTestStatus
.
success
?
'Success'
:
lastError
!
;
return
Container
(
color:
_lastTestStatus
==
_LastTestStatus
.
success
?
Colors
.
green
:
Colors
.
red
,
child:
Text
(
...
...
@@ -116,7 +116,7 @@ class NestedViewEventBodyState extends State<NestedViewEventBody> {
});
}
try
{
await
viewChannel
.
invokeMethod
<
void
>(
'showAndHideAlertDialog'
);
await
viewChannel
!
.
invokeMethod
<
void
>(
'showAndHideAlertDialog'
);
setState
(()
{
_lastTestStatus
=
_LastTestStatus
.
success
;
});
...
...
@@ -136,7 +136,7 @@ class NestedViewEventBodyState extends State<NestedViewEventBody> {
Future
<
void
>
onChildViewPressed
()
async
{
try
{
await
viewChannel
.
invokeMethod
<
void
>(
'addChildViewAndWaitForClick'
);
await
viewChannel
!
.
invokeMethod
<
void
>(
'addChildViewAndWaitForClick'
);
setState
(()
{
nestedViewClickCount
++;
});
...
...
@@ -167,6 +167,6 @@ class NestedViewEventBodyState extends State<NestedViewEventBody> {
viewChannel
=
MethodChannel
(
'simple_view/
$id
'
);
});
driverDataHandler
.
registerHandler
(
'hierarchy'
)
.
complete
(()
=>
channel
.
invokeMethod
<
String
>(
'getViewHierarchy'
)
);
.
complete
(()
async
=>
(
await
channel
.
invokeMethod
<
String
>(
'getViewHierarchy'
))!
);
}
}
dev/integration_tests/hybrid_android_views/lib/page.dart
View file @
075991c2
...
...
@@ -8,7 +8,7 @@ import 'package:flutter/material.dart';
//
/// A testing page has to override this in order to be put as one of the items in the main page.
abstract
class
PageWidget
extends
StatelessWidget
{
const
PageWidget
(
this
.
title
,
this
.
tileKey
,
{
Key
key
})
:
super
(
key:
key
);
const
PageWidget
(
this
.
title
,
this
.
tileKey
,
{
Key
?
key
})
:
super
(
key:
key
);
/// The title of the testing page
///
...
...
dev/integration_tests/hybrid_android_views/pubspec.yaml
View file @
075991c2
...
...
@@ -4,7 +4,7 @@ publish_to: none
description
:
An integration test for hybrid composition on Android
version
:
1.0.0+1
environment
:
sdk
:
'
>=2.
9
.0
<3.0.0'
sdk
:
'
>=2.
12
.0
<3.0.0'
dependencies
:
flutter
:
...
...
dev/integration_tests/hybrid_android_views/test_driver/main_test.dart
View file @
075991c2
...
...
@@ -6,7 +6,7 @@ import 'package:flutter_driver/flutter_driver.dart';
import
'package:test/test.dart'
hide
TypeMatcher
,
isInstanceOf
;
Future
<
void
>
main
()
async
{
FlutterDriver
driver
;
late
FlutterDriver
driver
;
setUpAll
(()
async
{
driver
=
await
FlutterDriver
.
connect
();
...
...
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