gpt4 book ai didi

flutter - 当 CustomScrollView 在 flutter 中滚动时如何隐藏应用栏

转载 作者:行者123 更新时间:2023-12-04 08:39:18 24 4
gpt4 key购买 nike

我正在使用 flutter 来显示一些 html 页面,是否可以在 CustomScrollView 向上滚动时隐藏 appBar?然后我可以有更多的屏幕区域来显示 html 内容。这是我当前的代码片段:

import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:flutter_icons/flutter_icons.dart';
import 'package:Cruise/src/component/comment_list.dart';
import 'package:Cruise/src/component/story_information.dart';
import 'package:Cruise/src/models/Item.dart';
import 'package:Cruise/src/common/Repo.dart';

class StoryPage extends HookWidget {
const StoryPage({
Key key,
@required this.item,
}) : super(key: key);

final Item item;

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Cruise'),
actions: [
if (item.parent != null)
IconButton(
icon: Icon(Feather.corner_left_up),
onPressed: () async {
Item parent = await Repo.fetchItem(item.parent);
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => StoryPage(item: parent)),
);
},
),
],
),
body: CustomScrollView(
slivers: [
SliverToBoxAdapter(child: StoryInformation(item: item)),
CommentList(item: item)
],
),
);
}
}

最佳答案

您可以使用 SliverChildBuilderDelegate 为达到这个,
SliverChildBuilderDelegate class

Scaffold(
body: CustomScrollView(
slivers: <Widget>[
SliverAppBar(
title: Text('data'),
),
SliverList(
delegate: SliverChildBuilderDelegate(
(context, index) => Text(
index.toString(),
),
childCount: 300),
),
],
),
);

关于flutter - 当 CustomScrollView 在 flutter 中滚动时如何隐藏应用栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64640011/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com