我需要在webView中启用缩放,但每当我启用缩放时,滚动功能被禁用,尝试使用单个子滚动视图,不起作用,现在我的代码滚动,但不能放大或缩小!我试图通过交互式查看器 Package 它,但交互式查看器禁用滚动!我如何解决这个问题?
import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:webview_flutter/webview_flutter.dart';
import '../../widgets/headers/custom_app_bar.dart';
class InfoScreen extends StatefulWidget {
final String url;
final String title;
InfoScreen({Key key, @required this.title, @required this.url})
: super(key: key);
@override
State<StatefulWidget> createState() => _InfoScreenState();
}
class _InfoScreenState extends State<InfoScreen> {
bool isLoading = true;
final _key = UniqueKey();
@override
Widget build(BuildContext context) {
WebViewController controller;
return Scaffold(
appBar: CustomAppBar(title: widget.title),
body: Stack(
children: <Widget>[
WebView(
key: _key,
initialUrl: widget.url,
javascriptMode: JavascriptMode.unrestricted,
onWebViewCreated: (WebViewController webViewController) {
controller = webViewController;
},
onPageFinished: (finish) {
setState(() {
isLoading = false;
});
},
gestureRecognizers: Set()
..add(Factory<ScaleGestureRecognizer>(
() => ScaleGestureRecognizer())),
),
isLoading
? Center(
child: CircularProgressIndicator(),
)
: Stack(),
],
),
);
}
}
1条答案
按热度按时间am46iovg1#
尝试为垂直和水平方向添加
gestureRecognizers
。以下是修改后的代码: