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
37658428
Unverified
Commit
37658428
authored
Jul 20, 2021
by
Arthas
Committed by
GitHub
Jul 20, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add onPlatformViewCreated to HtmlElementView (#84095)
parent
89c8616f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
1 deletion
+44
-1
platform_view.dart
packages/flutter/lib/src/widgets/platform_view.dart
+10
-1
html_element_view_test.dart
packages/flutter/test/widgets/html_element_view_test.dart
+34
-0
No files found.
packages/flutter/lib/src/widgets/platform_view.dart
View file @
37658428
...
...
@@ -345,6 +345,7 @@ class HtmlElementView extends StatelessWidget {
const
HtmlElementView
({
Key
?
key
,
required
this
.
viewType
,
this
.
onPlatformViewCreated
,
})
:
assert
(
viewType
!=
null
),
assert
(
kIsWeb
,
'HtmlElementView is only available on Flutter Web.'
),
super
(
key:
key
);
...
...
@@ -354,6 +355,11 @@ class HtmlElementView extends StatelessWidget {
/// A PlatformViewFactory for this type must have been registered.
final
String
viewType
;
/// Callback to invoke after the platform view has been created.
///
/// May be null.
final
PlatformViewCreatedCallback
?
onPlatformViewCreated
;
@override
Widget
build
(
BuildContext
context
)
{
return
PlatformViewLink
(
...
...
@@ -372,7 +378,10 @@ class HtmlElementView extends StatelessWidget {
/// Creates the controller and kicks off its initialization.
_HtmlElementViewController
_createHtmlElementView
(
PlatformViewCreationParams
params
)
{
final
_HtmlElementViewController
controller
=
_HtmlElementViewController
(
params
.
id
,
viewType
);
controller
.
_initialize
().
then
((
_
)
{
params
.
onPlatformViewCreated
(
params
.
id
);
});
controller
.
_initialize
().
then
((
_
)
{
params
.
onPlatformViewCreated
(
params
.
id
);
onPlatformViewCreated
?.
call
(
params
.
id
);
});
return
controller
;
}
}
...
...
packages/flutter/test/widgets/html_element_view_test.dart
View file @
37658428
...
...
@@ -37,6 +37,40 @@ void main() {
);
});
testWidgets
(
'Create HTML view with PlatformViewCreatedCallback'
,
(
WidgetTester
tester
)
async
{
final
int
currentViewId
=
platformViewsRegistry
.
getNextPlatformViewId
();
final
FakeHtmlPlatformViewsController
viewsController
=
FakeHtmlPlatformViewsController
();
viewsController
.
registerViewType
(
'webview'
);
bool
hasPlatformViewCreated
=
false
;
void
onPlatformViewCreatedCallBack
(
int
id
)
{
hasPlatformViewCreated
=
true
;
}
await
tester
.
pumpWidget
(
Center
(
child:
SizedBox
(
width:
200.0
,
height:
100.0
,
child:
HtmlElementView
(
viewType:
'webview'
,
onPlatformViewCreated:
onPlatformViewCreatedCallBack
,
),
),
),
);
// Check the onPlatformViewCreatedCallBack has been called.
expect
(
hasPlatformViewCreated
,
true
);
expect
(
viewsController
.
views
,
unorderedEquals
(<
FakeHtmlPlatformView
>[
FakeHtmlPlatformView
(
currentViewId
+
1
,
'webview'
),
]),
);
});
testWidgets
(
'Resize HTML view'
,
(
WidgetTester
tester
)
async
{
final
int
currentViewId
=
platformViewsRegistry
.
getNextPlatformViewId
();
final
FakeHtmlPlatformViewsController
viewsController
=
FakeHtmlPlatformViewsController
();
...
...
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