我使用时NestedScrollView可以很好地自动隐藏AppBar(我想要的一个功能)SliverAppBar。在遇到问题的地方,我将其ListView.Builder用作身体下游组件之一,我需要将其应用于自身ScrollController(或似乎需要在此处应用)。这与NestedScrollView和冲突,我失去了由NestedScrollView和方便处理的appbar的自动隐藏SliverAppBar。
如果我将附加在ScrollController上,NestedScrollView则它将仅跟踪滚动位置直到偏移量80.0,之后,使用更长的ListView,我无法像直接将ScrollController附加到那样正确地设置animateTo ListView.Builder。
这是我的实现的代码片段/ sudo代码:
new Scaffold(
drawer: ...,
body: new NestedScrollView(
headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
return [
new SliverAppBar(
title: new Text('Title'),
floating: true,
snap: true
)
]
}
body: new Stack(
children: <Widget>[
new PageView(
children: <Widget>[
new PageView1(implements ListViewBuilder),
new PageView2(implements ListView),
new PageView3(implements ListView),
]
controller: _pageController,
),
new FloatingActionButton
]
)
)
)
class …Run Code Online (Sandbox Code Playgroud) 我正在寻找将一个URL /路径反向代理到端点上代表不同服务器托管其自己的Web应用程序的不同端口的方法。
我可以使用proxy_pass,但是静态文件失败,因为资源是相对于其实例的。
我有例如-server_name = myproxy.com:
location /app1/{
proxy_pass: http://192.168.1.1:8080/;
proxy_set_header Host 192.168.1.1;
}
location /app2/{
proxy_pass: http://192.168.1.1:8081/;
proxy_set_header Host 192.168.1.2;
}
location /{
proxy_pass: http://192.168.1.1:8080/;
proxy_set_header Host 192.168.1.1;
}
Run Code Online (Sandbox Code Playgroud)
如上所述,反向代理的工作原理非常好,除了与app2相关联的静态文件外。App1静态文件可以正常工作,但App2静态文件会生成404。这很有意义,因为App1资源文件位于/assets/app1.css此文件中,因为我有/适当的位置重定向,可以解析回App1但App2资源文件,这完全是/assets/app2.css404中的结果不同。
因此,有没有办法将App2静态请求从重写/assets/app2.css为它们各自的代理位置?就像是:
location /app1/{
proxy_pass: http://192.168.1.1:8080/;
proxy_set_header Host 192.168.1.1;
}
location /app2/{
proxy_pass: http://192.168.1.1:8081/;
proxy_set_header Host 192.168.1.2;
*rewrite app2 static urls frome /assets/* to /app2/assets/*
}
location /{
proxy_pass: http://192.168.1.1:8080/;
proxy_set_header Host 192.168.1.1;
}
Run Code Online (Sandbox Code Playgroud) 我正在使用ListView.buildler将Widget分层为垂直滚动。这种方法的唯一问题是,当滚动到达我内容的结尾时。它会自动回到顶部。目前我有这个:
new ListView.builder(
scrollDirection: Axis.vertical,
key: new Key(randomString(20)),
reverse: false,
primary: true,
itemBuilder: (BuildContext context, int index) {
return new Column(
children: <Widget>[
new Padding(
padding: _bookPadding,
child: new Container(
width: 106.0,
height: 162.0,
child: new FadeInImage(
placeholder: new AssetImage('assets/loading.gif'),
image: this.book.cover)
),
),
const Divider(),
new Padding(
padding: _bookPadding,
child: new Text(
this.book.bookName,
style: getTextStyle())),
const Divider(),
new Padding(
padding: _bookPadding,
child: new Text(
'By ' + this.book.author,
style: getTextStyle(), ),
),
....
Run Code Online (Sandbox Code Playgroud)
到达终点时,是否可以将ListView.builder设置为no-wrap?