Flutter inappwebview 滚动在 NestedScrollView TabBarView 中不起作用
Flutter inappwebview scroll not working inside the NestedScrollView TabBarView
我是 flutter 的新手,我在 TabBarView 中添加了 webview(inappwebview),但是当我尝试向下滚动网页时,它没有向下滚动,下面我添加了我的代码和屏幕截图
import 'package:flutter/material.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Welcome to Flutter',
home: Scaffold(
body: DefaultTabController(
length: 5,
child: Scaffold(
body: NestedScrollView(
headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
return <Widget>[
new SliverAppBar(
title: Text('Tabs Demo'),
pinned: true,
floating: true,
bottom: TabBar(
isScrollable: true,
tabs: [
Tab(child: Text('Flight')),
Tab(child: Text('Train')),
Tab(child: Text('Car')),
Tab(child: Text('Cycle')),
Tab(child: Text('Boat')),
],
),
),
];
},
body: TabBarView(
children: <Widget>[
InAppWebView(initialUrlRequest: URLRequest(url: Uri.parse("https://flutter.dev/"))),
Icon(Icons.directions_transit, size: 350),
Icon(Icons.directions_car, size: 350),
Icon(Icons.directions_bike, size: 350),
Icon(Icons.directions_boat, size: 350),
],
),
)),
),
),
);
}
}
截图:
page
尝试添加手势检测器,如下所示:
InAppWebView(
gestureRecognizers: Set()..add(Factory<VerticalDragGestureRecognizer>(() => VerticalDragGestureRecognizer())),
initialUrlRequest: URLRequest(url: Uri.parse("https://flutter.dev/"))),
如果这不能解决您的问题,请查看手势检测器。
我是 flutter 的新手,我在 TabBarView 中添加了 webview(inappwebview),但是当我尝试向下滚动网页时,它没有向下滚动,下面我添加了我的代码和屏幕截图
import 'package:flutter/material.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Welcome to Flutter',
home: Scaffold(
body: DefaultTabController(
length: 5,
child: Scaffold(
body: NestedScrollView(
headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
return <Widget>[
new SliverAppBar(
title: Text('Tabs Demo'),
pinned: true,
floating: true,
bottom: TabBar(
isScrollable: true,
tabs: [
Tab(child: Text('Flight')),
Tab(child: Text('Train')),
Tab(child: Text('Car')),
Tab(child: Text('Cycle')),
Tab(child: Text('Boat')),
],
),
),
];
},
body: TabBarView(
children: <Widget>[
InAppWebView(initialUrlRequest: URLRequest(url: Uri.parse("https://flutter.dev/"))),
Icon(Icons.directions_transit, size: 350),
Icon(Icons.directions_car, size: 350),
Icon(Icons.directions_bike, size: 350),
Icon(Icons.directions_boat, size: 350),
],
),
)),
),
),
);
}
}
截图: page
尝试添加手势检测器,如下所示:
InAppWebView(
gestureRecognizers: Set()..add(Factory<VerticalDragGestureRecognizer>(() => VerticalDragGestureRecognizer())),
initialUrlRequest: URLRequest(url: Uri.parse("https://flutter.dev/"))),
如果这不能解决您的问题,请查看手势检测器。