为什么我不能在 Flutter ModalBottomSheet 中滚动自定义 WebView
Why can't I scroll custom WebView in Flutter ModalBottomSheet
大家好,有人知道为什么我不能垂直滚动 ModalBottomSheet 中的 WebView 吗?这是我的代码,如果有什么不对请告诉我或者给我一些建议。
showModalBottomSheet(
context: context,
isScrollControlled: true,
backgroundColor: Colors.transparent,
builder: (context) => Container(
height: MediaQuery.of(context).size.height * 0.75,
decoration: new BoxDecoration(
color: Colors.white,
borderRadius: new BorderRadius.only(
topLeft: const Radius.circular(25.0),
topRight: const Radius.circular(25.0),
),
),
child: Padding(
padding: EdgeInsets.fromLTRB(0, 23, 0, 0),
child: WebView(
initialUrl: 'https://www.sicepat.com/checkAwb/',
javascriptMode: JavascriptMode.unrestricted,
onWebViewCreated: (controller) {
_myController = controller;
},
onPageFinished: (initialUrl) {
_myController.evaluateJavascript("document.getElementsByClassName('ws-header-container')[0].style.display='none';");
_myController.evaluateJavascript("document.getElementsByClassName('ws-footer-page')[0].style.display='none';");
},
)
),
),
);
尝试使用gestureRecognizers
并设置WebView
键
旧版本:
final Set<Factory> gestureRecognizers = [Factory(() => EagerGestureRecognizer())].toSet();
UniqueKey _key = UniqueKey();
...
新版本:
final Set<Factory<OneSequenceGestureRecognizer>> gestureRecognizers = {
Factory(() => EagerGestureRecognizer())
};
UniqueKey _key = UniqueKey();
WebView(
key: _key,
initialUrl: 'https://www.sicepat.com/checkAwb/',
javascriptMode: JavascriptMode.unrestricted,
gestureRecognizers: gestureRecognizers,
onWebViewCreated: (controller) {
_myController = controller;
},
onPageFinished: (initialUrl) {
_myController.evaluateJavascript("document.getElementsByClassName('ws-header-container')[0].style.display='none';");
_myController.evaluateJavascript("document.getElementsByClassName('ws-footer-page')[0].style.display='none';");
},
)
对于较新版本的 Flutter;
final Set<Factory<OneSequenceGestureRecognizer>> gestureRecognizers = {
Factory(() => EagerGestureRecognizer())
};
大家好,有人知道为什么我不能垂直滚动 ModalBottomSheet 中的 WebView 吗?这是我的代码,如果有什么不对请告诉我或者给我一些建议。
showModalBottomSheet(
context: context,
isScrollControlled: true,
backgroundColor: Colors.transparent,
builder: (context) => Container(
height: MediaQuery.of(context).size.height * 0.75,
decoration: new BoxDecoration(
color: Colors.white,
borderRadius: new BorderRadius.only(
topLeft: const Radius.circular(25.0),
topRight: const Radius.circular(25.0),
),
),
child: Padding(
padding: EdgeInsets.fromLTRB(0, 23, 0, 0),
child: WebView(
initialUrl: 'https://www.sicepat.com/checkAwb/',
javascriptMode: JavascriptMode.unrestricted,
onWebViewCreated: (controller) {
_myController = controller;
},
onPageFinished: (initialUrl) {
_myController.evaluateJavascript("document.getElementsByClassName('ws-header-container')[0].style.display='none';");
_myController.evaluateJavascript("document.getElementsByClassName('ws-footer-page')[0].style.display='none';");
},
)
),
),
);
尝试使用gestureRecognizers
并设置WebView
键
旧版本:
final Set<Factory> gestureRecognizers = [Factory(() => EagerGestureRecognizer())].toSet();
UniqueKey _key = UniqueKey();
...
新版本:
final Set<Factory<OneSequenceGestureRecognizer>> gestureRecognizers = {
Factory(() => EagerGestureRecognizer())
};
UniqueKey _key = UniqueKey();
WebView(
key: _key,
initialUrl: 'https://www.sicepat.com/checkAwb/',
javascriptMode: JavascriptMode.unrestricted,
gestureRecognizers: gestureRecognizers,
onWebViewCreated: (controller) {
_myController = controller;
},
onPageFinished: (initialUrl) {
_myController.evaluateJavascript("document.getElementsByClassName('ws-header-container')[0].style.display='none';");
_myController.evaluateJavascript("document.getElementsByClassName('ws-footer-page')[0].style.display='none';");
},
)
对于较新版本的 Flutter;
final Set<Factory<OneSequenceGestureRecognizer>> gestureRecognizers = {
Factory(() => EagerGestureRecognizer())
};