我正在尝试创建一个具有WebView的屏幕(来自webview_flutter:^ 0.3.5 + 3),AppBar并且我想在用户滚动时在屏幕外滚动。
我偶然发现了该指南,并尝试实现类似但没有骰子的方法。
是否可以WebView在CustomScrollViewwith 中使用,Slivers还是尚不支持?
我可以滚动应用栏来工作,如果我在创建常规小工具SliverChildListDelegate(我试过Row,Text,Container等),但没有运气了WebView。
@override
Widget build(BuildContext context) {
return Scaffold(
body: CustomScrollView(
slivers: <Widget>[
SliverAppBar(
title: const Text("Heading"),
floating: true,
),
SliverList(
delegate: SliverChildListDelegate([
Container(
child: WebView(
initialUrl: url,
javascriptMode: JavascriptMode.unrestricted,
),
)
]
),
)
],
)
);
}
Run Code Online (Sandbox Code Playgroud)
欢迎任何指针/建议/ RTFM。
编辑赏金
jordan-davies提供的解决方案有效,但是非常不稳定。每当将SliverAppBar滚动离开时,都会WebView尝试自行调整大小以填充剩余的视口。这使得波动非常缓慢。
@override
Widget build(BuildContext context) { …Run Code Online (Sandbox Code Playgroud)