在android中,我们app:behavior_overlapTop="64dp"用来实现这一目标
我希望在颤动中与上面的 GIF 相同的重叠内容
我的代码
class DetailsPage extends StatefulWidget {
@override
_DetailsPage createState() => _DetailsPage();
}
class _DetailsPage extends State<DetailsPage> {
@override
void initState() {
super.initState();
SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
DeviceOrientation.portraitDown,
]);
_scrollController = ScrollController();
_scrollController.addListener(_scrollListener);
}
ScrollController _scrollController;
bool lastStatus = true;
_scrollListener() {
if (isShrink != lastStatus) {
setState(() {
lastStatus = isShrink;
});
}
}
bool get isShrink {
return _scrollController.hasClients &&
_scrollController.offset > (250 - kToolbarHeight);
}
@override
void dispose() {
_scrollController.removeListener(_scrollListener);
super.dispose();
}
@override
Widget …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Flutter重新创建在弹性空间中具有重叠内容的应用栏滚动。
该行为在此处演示:
http://karthikraj.net/2016/12/24/scrolling-behavior-for-appbars-in-android/
我已经使用SliverAppBar创建了折叠的AppBar,使用我在此处粘贴的代码,我正在尝试创建此
我无法使用Stack,因为我找不到任何onScroll回调,到目前为止,我已使用flexibleSpace创建了应用栏,该应用栏在滚动时折叠:
Scaffold(
body: NestedScrollView(
headerSliverBuilder:
(BuildContext context, bool innerBoxIsScrolled) => <Widget>[
SliverAppBar(
forceElevated: innerBoxIsScrolled,
pinned: true,
expandedHeight: 180.0,
),
],
body: ListView.builder(
itemCount: 30,
itemBuilder: (context, index) => Text(
"Item $index",
style: Theme.of(context).textTheme.display1,
),
),
),
);
Run Code Online (Sandbox Code Playgroud)
编辑:我要创建的示例
我正在尝试在上重叠SliverList几个像素SliverAppBar。类似于这个帖子。我希望其中的图片位于我的图片FlexibleSpaceBar下方SliverList。我正在尝试实现以下目标。
我只能这样获得半径。没有能力重叠SliverList他SliverAppBar。

@override
Widget build(BuildContext context) {
return Scaffold(
body: CustomScrollView(
slivers: <Widget>[
SliverAppBar(
floating: false,
expandedHeight: MediaQuery.of(context).size.height * 0.50,
flexibleSpace: FlexibleSpaceBar(
background: Image.network(pet.photos.first)
),
),
SliverList(
delegate: SliverChildListDelegate([
Container(
height: 40,
decoration: BoxDecoration(
color: Colors.red,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(30),
topRight: Radius.circular(30),
),
),
),
]),
)
],
),
);
}
Run Code Online (Sandbox Code Playgroud)
任何方向将不胜感激,谢谢!