相关疑难解决方法(0)

Flutter:如何允许内容与 SliverAppBar 重叠?

在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)

android dart flutter flutter-layout flutter-animation

8
推荐指数
1
解决办法
4295
查看次数

颤动-应用栏滚动,在灵活空间中重叠内容

我正在尝试使用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)

我到目前为止所创造的

编辑:我要创建的示例

flutter flutter-sliver flutter-layout flutter-animation

6
推荐指数
1
解决办法
4894
查看次数

如何在SliverAppBar上重叠SliverList

我正在尝试在上重叠SliverList几个像素SliverAppBar。类似于这个帖子。我希望其中的图片位于我的图片FlexibleSpaceBar下方SliverList。我正在尝试实现以下目标。

在此处输入图片说明

我只能这样获得半径。没有能力重叠SliverListSliverAppBar在此处输入图片说明

  @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)

任何方向将不胜感激,谢谢!

flutter flutter-layout

6
推荐指数
2
解决办法
525
查看次数