首页 > 解决方案 > 如何在颤动中制作不可滚动的标题和可滚动的正文?

问题描述

我正在尝试构建一个没有可滚动标题和可滚动正文的项目。SliverAppbar 是首选,但如果我移动身体而不是失去标题。我也可以使用 Slidabele Tile。SliverPersistentHeader 是我的第二选择,但我可以使用 Slidabele Tile。我的问题如下图所示。main.dart Header 不能滚动,body 必须包含硬编码的 Slidable Tile。如何在颤动中制作不可滚动的标题和可滚动的正文?

在此处输入图像描述

标签: flutter

解决方案


你应该appBar: AppBar(...在你的内部使用脚手架。所以 MaterialApp->Scaffold->(AppBar 和 listview)。

示例代码:

import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text("This is the title"),
        ),
        body: ListView(
          children: <Widget>[
            Text("This is text 1"),
            Text("This is text 2"),
            Text("This is text 3"),
            Text("This is text 4"),
            Text("This is text 5"),
            Text("This is text 6"),
            Text("This is text 7"),
            Text("This is text 8"),
            Text("This is text 9"),
            Text("This is text 10"),
            Text("This is text 11"),
            Text("This is text 12"),
            Text("This is text 13"),
            Text("This is text 14"),
            Text("This is text 15"),
            Text("This is text 15"),
            Text("This is text 15"),
            Text("This is text 15"),
            Text("This is text 15"),
            Text("This is text 15"),
            Text("This is text 15"),
            Text("This is text 15"),
            Text("This is text 15"),
            Text("This is text 15"),
            Text("This is text 15"),
            Text("This is text 15"),
            Text("This is text 15"),
            Text("This is text 15"),
            Text("This is text 15"),
            Text("This is text 15"),
            Text("This is text 15"),
            Text("This is text 15"),
            Text("This is text 15"),
            Text("This is text 15"),
            Text("This is text 15"),
            Text("This is text 15"),
            Text("This is text 15"),
            Text("This is text 15"),
            Text("This is text 15"),
          ],
        ),
      ),
    );
  }
}

推荐阅读