我在FlutterWeb中的HtmlView上堆叠了一些小部件,但是发现没有任何动作可用于放置在HtmlView上的小部件。 HtmlView消耗所有动作。根据Flutter文档,仅当其他小部件都不要求事件时,平台视图才应获取事件。
请参阅下面的最小复制代码。我尝试将ModalBottomSheet,SnackBar和Flatbutton放在HtmlView上,以显示youTube视频和Google地图。这些都不起作用。
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:html';
import 'package:flutter_web_ui/ui.dart' as ui;
import 'package:flutter_web/material.dart';
void main() {
runApp(new Center(child: new Directionality( textDirection: TextDirection.ltr,child:HtmlExample())));
}
class HtmlExample extends StatefulWidget {
@override
_HtmlExampleState createState() => new _HtmlExampleState();
}
class _HtmlExampleState extends State<HtmlExample> {
int count;
@override
void initState() {
count = 0;
ui.platformViewRegistry.registerViewFactory(
'hello-world-html',
(int viewId) => IFrameElement()
..width = '640'
..height = '360'
..src = 'https://www.youtube.com/embed/IyFZznAk69U'
..style.border = 'none');
super.initState();
// We use 3600 milliseconds instead of 1800 milliseconds because 0.0 -> 1.0
// represents an entire turn of the square whereas in the other examples
// we used 0.0 -> math.pi, which is only half a turn.
}
@override
Widget build(BuildContext context) {
return Stack(children: <Widget>[
SizedBox(
width: 640,
height: 360,
child: HtmlView(viewType: 'hello-world-html')), //Text("Count = $count")),
Text("Count = $count"),
Column (children: <Widget>[
FlatButton(child: Text("Count"), color: Colors.red, onPressed: () => setState((){count++;})),
Text("Count = $count"),
],)
],);
}
@override
void dispose() {
super.dispose();
}
}