Flutter DraggableScrollableSheet 可滚动对象的容器

Posted ajanuw

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Flutter DraggableScrollableSheet 可滚动对象的容器相关的知识,希望对你有一定的参考价值。

Example

技术图片

import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: HomePage(),
    );
  }
}

class HomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Stack(
        children: [
          Align(
            alignment: Alignment.topCenter,
            child: Image.network(
                "https://i.loli.net/2019/11/30/auRxklc9f6TLgdE.jpg"),
          ),
          DraggableScrollableSheet(
            initialChildSize:
                1.0, // 设置父容器的高度 1 ~ 0, initialChildSize必须 <= maxChildSize
            minChildSize:
                0.6, // 限制child最小高度, minChildSize必须 <= initialChildSize
            maxChildSize: 1.0, // 限制child最大高度,
            builder: (context, scrollController) {
              return Container(
                color: Colors.blue[100],
                child: SingleChildScrollView(
                  controller: scrollController,
                  child: Column(
                    children: <Widget>[
                      Padding(
                        padding: const EdgeInsets.all(8.0),
                        child: Image.network(
                          "https://i.loli.net/2019/11/30/DVJGdj3eNpakXY4.jpg",
                          fit: BoxFit.cover,
                        ),
                      ),
                      for (var i = 0; i < 25; i++)
                        ListTile(title: Text('Item $i'))
                    ],
                  ),
                ),
              );
            },
          ),
        ],
      ),
    );
  }
}

以上是关于Flutter DraggableScrollableSheet 可滚动对象的容器的主要内容,如果未能解决你的问题,请参考以下文章

[Flutter] flutter项目一直卡在 Running Gradle task 'assembleDebug'...

flutter 日志输出,Flutter打印日志,flutter log,flutter 真机日志

Flutter开发 Flutter 包和插件 ( Flutter 包和插件简介 | 创建 Flutter 插件 | 创建 Dart 包 )

flutter与原生混编(iOS)

Flutter-布局

如何解决flutter gradle build error?C:\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 991