展开的小部件占据屏幕的整个高度,无论其 children

Expanded widget takes full height of the screen irrespective of its children

我正在使用动态底部 sheet,其中有一列作为 child。此栏的最后 child 是网格视图。对于一些小屏幕设备,底部 sheet 的内容会溢出,所以我将网格视图包装在一个展开的小部件中。现在它的内容在溢出时可以滚动。

但这里的问题是,即使网格视图的内容没有溢出(屏幕尺寸足够大),它仍然扩展到全屏,底部留空 space。我试图在过去 3 天解决这个问题,但没有结果。我尝试了 parent 和 child 小部件的各种组合,但没有给出令人满意的结果。

我期望的结果是当内容溢出时网格视图应该滚动,如果没有,那么它应该只占用所需的 space 而不是整个屏幕。

这是我的全部代码,有问题的网格视图在最后:

showModalBottomSheet<dynamic>(
      isScrollControlled: true,
      context: context,
      builder: (BuildContext context) {
        return StatefulBuilder(
            builder: (context, setState) {
              return Container(
                color: Colors.white,
                child: Column(
                  mainAxisSize: MainAxisSize.min,
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Container(
                      width: double.infinity,
                      decoration: BoxDecoration(
                        border: Border(
                          bottom: BorderSide(color: Color.fromARGB(255, 225, 225, 225)),
                        ),
                        //color: Color.fromARGB(255, 255, 255, 255),
                      ),
                      child: Row(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: [
                          Padding(
                            padding: const EdgeInsets.fromLTRB(15, 15, 10, 15),
                            child: Icon(
                              Icons.save,
                              color: Color.fromARGB(255, 2, 136, 209),
                              size: 28.0,
                            ),
                          ),
                          Expanded(
                            child: Material(
                              color: Colors.transparent,
                              child: InkWell(
                                onTap: (){},
                                child: Padding(
                                  padding: const EdgeInsets.fromLTRB(8.0, 13.0, 10.0, 10.0),
                                  child: Column(
                                    crossAxisAlignment: CrossAxisAlignment.start,
                                    children: [
                                      Row(
                                        mainAxisSize: MainAxisSize.min,
                                        crossAxisAlignment: CrossAxisAlignment.start,
                                        children: [
                                          Container(
                                            constraints: BoxConstraints(minWidth: 0, maxWidth: MediaQuery.of(context).size.width*(2/3)),
                                            child: Text(
                                              'PDF Name',
                                              overflow: TextOverflow.ellipsis,
                                              maxLines: 2,
                                              softWrap: true,
                                              style: TextStyle(
                                                fontSize: 16.0,
                                                fontWeight: FontWeight.bold,
                                                color: Color.fromARGB(255, 117, 117, 117),
                                              ),
                                            ),
                                          ),
                                          Padding(
                                            padding: EdgeInsets.fromLTRB(5.0, 0.0, 0.0, 0.0),
                                            child: Icon(
                                              Icons.edit,
                                              color: Color.fromARGB(255, 2, 136, 209),
                                              size: 16.0,
                                            ),
                                          ),
                                        ],
                                      ),
                                      Padding(
                                        padding: const EdgeInsets.fromLTRB(0.0, 5.0, 0.0, 0.0),
                                        child: Text(
                                          "PDF Size",
                                          style: TextStyle(
                                            fontSize: 12.0,
                                            color: Color.fromARGB(255, 117, 117, 117),
                                          ),
                                        ),
                                      ),
                                    ],
                                  ),
                                ),
                              ),
                            ),
                          ),
                        ],
                      ),
                    ),
                    Row(
                        children: <Widget>[
                          Expanded(
                              child: Padding(
                                padding: const EdgeInsets.fromLTRB(0, 10, 0, 4),
                                child: Divider(
                                  color: Color.fromARGB(255, 220, 220, 220),
                                  thickness: 1.1,
                                ),
                              )
                          ),
                          Padding(
                            padding: const EdgeInsets.fromLTRB(10, 10, 10, 4),
                            child: Text(
                              "Share/Save File to",
                              style: TextStyle(
                                color: Color.fromARGB(255, 117, 117, 117),
                                fontSize: 15.0,
                              ),
                            ),
                          ),
                          Expanded(
                              child: Padding(
                                padding: const EdgeInsets.fromLTRB(0, 10, 0, 4),
                                child: Divider(
                                  color: Color.fromARGB(255, 220, 220, 220),
                                  thickness: 1.1,
                                ),
                              )
                          ),
                        ]
                    ),
                    Expanded(
                      child: GridView.count(
                        padding: EdgeInsets.fromLTRB(0, 0, 0, 15),
                        crossAxisCount: 3,
                        shrinkWrap: true,
                        childAspectRatio: 1.25,
                        children: <Widget>[
                          FileSaveCard(icon: Icons.phone_android, color: Colors.pink, title: 'Internal Storage', press: (){}),
                          FileSaveCard(icon: Icons.folder, color: Colors.blueAccent, title: 'My Documents', press: (){}),
                          FileSaveCard(icon: Icons.add_to_drive_rounded, color: Color.fromARGB(255, 254, 150, 0), title: 'Google Drive', press: (){}),
                          FileSaveCard(icon: Icons.mail, color: Colors.lightBlue, title: 'Send to Email', press: (){}),
                          FileSaveCard(icon: Icons.share, color: Colors.green, title: 'Share', press: (){}),
                        ],
                      ),
                    ),
                  ],
                ),
              );
            }
        );
      },
    );

这是输出图像:

它甚至滑到 phone 顶部的状态栏下方。我怎样才能避免这种情况。

这是我期待的结果:

案例 1:当它溢出时,这工作正常,因为我将网格视图包装在展开的小部件中,它变得可滚动 -

情况2:当屏幕尺寸足够children时,下图应该是输出,但我在底部得到空space-

好吧,我终于明白了。对于提供安全区域的状态栏重叠部分,所有部分都不起作用,正如 Sagar Acharya 所建议的那样,使用 FractionallySizedBox 确实阻止了它,但它迫使底部 sheet 占据全屏,而不管其内容高度为空 space 在它的最后一项之后。相反,我使用了 constraints: BoxConstraints(maxHeight: (MediaQuery.of(context).size.height)*0.95) 它没有强制 sheet 占据全高,也防止它重叠状态栏。

对于另一个问题,我首先从网格视图的顶部删除了扩展,并用 SingleChildScrollView 包裹了我的整个列(包含底部 sheet 的所有项目)。现在它会一直包裹内容,直到 sheet 达到全屏高度,当达到全屏高度时它就可以滚动了。

但是还有一件事我想改变,在我的输出中我底部的全部内容 sheet 是可滚动的但我只希望网格视图 children 是可滚动的,最上面的 'PDF Name' 和 'Share/Save File to' 不应随之滚动。任何想法我如何做到这一点。我尝试在网格视图上使用 SingleChildScrollView 而不是 Column 但它不起作用(当 sheet 达到全高时元素溢出)

这是我的代码:

showModalBottomSheet<dynamic>(
      isScrollControlled: true,
      context: context,
      builder: (BuildContext context) {
        return StatefulBuilder(
            builder: (context, setState) {
              return Container(
                //height: 900,
                constraints: BoxConstraints(maxHeight: (MediaQuery.of(context).size.height)*0.95),
                color: Colors.white,
                child: SingleChildScrollView(
                  child: Column(
                    mainAxisSize: MainAxisSize.min,
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      Container(
                        width: double.infinity,
                        decoration: BoxDecoration(
                          border: Border(
                            bottom: BorderSide(color: Color.fromARGB(255, 225, 225, 225)),
                          ),
                          //color: Color.fromARGB(255, 255, 255, 255),
                        ),
                        child: Row(
                          crossAxisAlignment: CrossAxisAlignment.start,
                          children: [
                            Padding(
                              padding: const EdgeInsets.fromLTRB(15, 15, 10, 15),
                              child: Icon(
                                Icons.save,
                                color: Color.fromARGB(255, 2, 136, 209),
                                size: 28.0,
                              ),
                            ),
                            Expanded(
                              child: Material(
                                color: Colors.transparent,
                                child: InkWell(
                                  onTap: (){},
                                  child: Padding(
                                    padding: const EdgeInsets.fromLTRB(8.0, 13.0, 10.0, 10.0),
                                    child: Column(
                                      crossAxisAlignment: CrossAxisAlignment.start,
                                      children: [
                                        Row(
                                          mainAxisSize: MainAxisSize.min,
                                          crossAxisAlignment: CrossAxisAlignment.start,
                                          children: [
                                            Container(
                                              constraints: BoxConstraints(minWidth: 0, maxWidth: MediaQuery.of(context).size.width*(2/3)),
                                              child: Text(
                                                'PDF Name',
                                                overflow: TextOverflow.ellipsis,
                                                maxLines: 2,
                                                softWrap: true,
                                                style: TextStyle(
                                                  fontSize: 16.0,
                                                  fontWeight: FontWeight.bold,
                                                  color: Color.fromARGB(255, 117, 117, 117),
                                                ),
                                              ),
                                            ),
                                            Padding(
                                              padding: EdgeInsets.fromLTRB(5.0, 0.0, 0.0, 0.0),
                                              child: Icon(
                                                Icons.edit,
                                                color: Color.fromARGB(255, 2, 136, 209),
                                                size: 16.0,
                                              ),
                                            ),
                                          ],
                                        ),
                                        Padding(
                                          padding: const EdgeInsets.fromLTRB(0.0, 5.0, 0.0, 0.0),
                                          child: Text(
                                            "PDF Size",
                                            style: TextStyle(
                                              fontSize: 12.0,
                                              color: Color.fromARGB(255, 117, 117, 117),
                                            ),
                                          ),
                                        ),
                                      ],
                                    ),
                                  ),
                                ),
                              ),
                            ),
                          ],
                        ),
                      ),
                      Row(
                          children: <Widget>[
                            Expanded(
                                child: Padding(
                                  padding: const EdgeInsets.fromLTRB(0, 10, 0, 4),
                                  child: Divider(
                                    color: Color.fromARGB(255, 220, 220, 220),
                                    thickness: 1.1,
                                  ),
                                )
                            ),
                            Padding(
                              padding: const EdgeInsets.fromLTRB(10, 10, 10, 4),
                              child: Text(
                                "Share/Save File to",
                                style: TextStyle(
                                  color: Color.fromARGB(255, 117, 117, 117),
                                  fontSize: 15.0,
                                ),
                              ),
                            ),
                            Expanded(
                                child: Padding(
                                  padding: const EdgeInsets.fromLTRB(0, 10, 0, 4),
                                  child: Divider(
                                    color: Color.fromARGB(255, 220, 220, 220),
                                    thickness: 1.1,
                                  ),
                                )
                            ),
                          ]
                      ),
                      GridView.count(
                        padding: EdgeInsets.fromLTRB(0, 0, 0, 15),
                        crossAxisCount: 3,
                        shrinkWrap: true,
                        //physics: NeverScrollableScrollPhysics(),
                        physics: const ScrollPhysics(),
                        childAspectRatio: 1.25,
                        children: <Widget>[
                          FileSaveCard(icon: Icons.phone_android, color: Colors.pink, title: 'Internal Storage', press: (){}),
                          FileSaveCard(icon: Icons.folder, color: Colors.blueAccent, title: 'My Documents', press: (){}),
                          FileSaveCard(icon: Icons.add_to_drive_rounded, color: Color.fromARGB(255, 254, 150, 0), title: 'Google Drive', press: (){}),
                          FileSaveCard(icon: Icons.mail, color: Colors.lightBlue, title: 'Send to Email', press: (){}),
                          FileSaveCard(icon: Icons.share, color: Colors.green, title: 'Share', press: (){}),

                          /*FileSaveCard(icon: Icons.share, color: Colors.green, title: 'Share', press: (){}),
                          FileSaveCard(icon: Icons.share, color: Colors.green, title: 'Share', press: (){}),
                          FileSaveCard(icon: Icons.share, color: Colors.green, title: 'Share', press: (){}),
                          FileSaveCard(icon: Icons.share, color: Colors.green, title: 'Share', press: (){}),
                          FileSaveCard(icon: Icons.share, color: Colors.green, title: 'Share', press: (){}),
                          FileSaveCard(icon: Icons.share, color: Colors.green, title: 'Share', press: (){}),
                          FileSaveCard(icon: Icons.share, color: Colors.green, title: 'Share', press: (){}),
                          FileSaveCard(icon: Icons.share, color: Colors.green, title: 'Share', press: (){}),
                          FileSaveCard(icon: Icons.share, color: Colors.green, title: 'Share', press: (){}),
                          FileSaveCard(icon: Icons.share, color: Colors.green, title: 'Share', press: (){}),
                          FileSaveCard(icon: Icons.share, color: Colors.green, title: 'Share', press: (){}),
                          FileSaveCard(icon: Icons.share, color: Colors.green, title: 'Share', press: (){}),
                          FileSaveCard(icon: Icons.share, color: Colors.green, title: 'Share', press: (){}),
                          FileSaveCard(icon: Icons.share, color: Colors.green, title: 'Share', press: (){}),
                          FileSaveCard(icon: Icons.share, color: Colors.green, title: 'Share', press: (){}),*/
                        ],
                      ),
                    ],
                  ),
                ),
              );
            }
        );
      },
    );

非常感谢任何帮助。 谢谢。

  1. 我想这就是你想要的答案
import 'package:flutter/material.dart';
import 'package:test11111/test1.dart';
import 'package:get/get.dart';



class MyStatelessWidget extends StatelessWidget {
  const MyStatelessWidget({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Center(
      child: ElevatedButton(
        child: const Text('showModalBottomSheet'),
        onPressed: () {
          showModalBottomSheet<void>(
            context: context,
            builder: (BuildContext context) {
              return SingleChildScrollView(
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.start,
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Container(
                      height: Get.height* 0.4,
                      color: Colors.white,
                      child: Column(
                        children: [
                          Container(
                            width: double.infinity,
                            decoration: BoxDecoration(
                              border: Border(
                                bottom: BorderSide(color: Color.fromARGB(255, 225, 225, 225)),
                              ),
                            ),
                            child: Row(
                              crossAxisAlignment: CrossAxisAlignment.start,
                              children: [
                                Padding(
                                  padding: const EdgeInsets.fromLTRB(15, 15, 10, 15),
                                  child: Icon(
                                    Icons.save,
                                    color: Color.fromARGB(255, 2, 136, 209),
                                    size: 28.0,
                                  ),
                                ),
                                Expanded(
                                  child: Material(
                                    color: Colors.transparent,
                                    child: InkWell(
                                      onTap: (){},
                                      child: Padding(
                                        padding: const EdgeInsets.fromLTRB(8.0, 13.0, 10.0, 10.0),
                                        child: Column(
                                          crossAxisAlignment: CrossAxisAlignment.start,
                                          children: [
                                            Row(
                                              mainAxisSize: MainAxisSize.min,
                                              crossAxisAlignment: CrossAxisAlignment.start,
                                              children: [
                                                Container(
                                                  constraints: BoxConstraints(minWidth: 0, maxWidth: MediaQuery.of(context).size.width*(2/3)),
                                                  child: Text(
                                                    'PDF Name',
                                                    overflow: TextOverflow.ellipsis,
                                                    maxLines: 2,
                                                    softWrap: true,
                                                    style: TextStyle(
                                                      fontSize: 16.0,
                                                      fontWeight: FontWeight.bold,
                                                      color: Color.fromARGB(255, 117, 117, 117),
                                                    ),
                                                  ),
                                                ),
                                                Padding(
                                                  padding: EdgeInsets.fromLTRB(5.0, 0.0, 0.0, 0.0),
                                                  child: Icon(
                                                    Icons.edit,
                                                    color: Color.fromARGB(255, 2, 136, 209),
                                                    size: 16.0,
                                                  ),
                                                ),
                                              ],
                                            ),
                                            Padding(
                                              padding: const EdgeInsets.fromLTRB(0.0, 5.0, 0.0, 0.0),
                                              child: Text(
                                                "PDF Size",
                                                style: TextStyle(
                                                  fontSize: 12.0,
                                                  color: Color.fromARGB(255, 117, 117, 117),
                                                ),
                                              ),
                                            ),
                                          ],
                                        ),
                                      ),
                                    ),
                                  ),
                                ),
                              ],
                            ),
                          ),
                          Row(
                              children: <Widget>[
                                Expanded(
                                    child: Padding(
                                      padding: const EdgeInsets.fromLTRB(0, 10, 0, 4),
                                      child: Divider(
                                        color: Color.fromARGB(255, 220, 220, 220),
                                        thickness: 1.1,
                                      ),
                                    )
                                ),
                                Padding(
                                  padding: const EdgeInsets.fromLTRB(10, 10, 10, 4),
                                  child: Text(
                                    "Share/Save File to",
                                    style: TextStyle(
                                      color: Color.fromARGB(255, 117, 117, 117),
                                      fontSize: 15.0,
                                    ),
                                  ),
                                ),
                                Expanded(
                                    child: Padding(
                                      padding: const EdgeInsets.fromLTRB(0, 10, 0, 4),
                                      child: Divider(
                                        color: Color.fromARGB(255, 220, 220, 220),
                                        thickness: 1.1,
                                      ),
                                    )
                                ),
                              ]
                          ),
                          Expanded(
                            child: GridView.count(
                              padding: EdgeInsets.fromLTRB(0, 0, 0, 15),
                              crossAxisCount: 3,
                              shrinkWrap: true,
                              childAspectRatio: 1.25,
                              children: <Widget>[
                                FileSaveCard(icon: Icons.phone_android, color: Colors.pink, title: 'Internal Storage', press: (){}),
                                FileSaveCard(icon: Icons.folder, color: Colors.blueAccent, title: 'My Documents', press: (){}),
                                FileSaveCard(icon: Icons.add_to_drive_rounded, color: Color.fromARGB(255, 254, 150, 0), title: 'Google Drive', press: (){}),
                                FileSaveCard(icon: Icons.mail, color: Colors.lightBlue, title: 'Send to Email', press: (){}),
                                FileSaveCard(icon: Icons.share, color: Colors.green, title: 'Share', press: (){}),
                              ],
                            ),
                          ),
                        ],
                      ),
                    ),
                  ],
                ),
              );
            },
          );
        },
      ),
    );
  }
}

class FileSaveCard extends StatelessWidget {
  FileSaveCard(
      {Key? key,
      required this.icon,
      required this.color,
      required this.title,
      required this.press})
      : super(key: key);
  IconData icon;
  Color color;
  String title;
  VoidCallback press;

  @override
  Widget build(BuildContext context) {
    return Container(
      child: Column(
        children: [
          IconButton(icon: Icon(icon), color: color, onPressed: press),
          Text(title)
        ],
      ),
    );
  }
}

好的所以从代码中我看到你使用的方式不对。

  1. 如果您使用的是 isScrollControlled =true 它将使用设备的完整高度,因为您已将展开的和列小部件用作其中子级的父级。

  2. 接下来,如果您不想要完整的高度,那么您必须使用 Wrap 小部件而不是列,并从 gridview 中删除展开的部分,它将采用子项的高度。

  3. 如果您想要填充模型表和顶部的 space,因为它与状态栏重叠,您可以使用 FractionallySizedBox 小部件

FractionallySizedBox(
   heightFactor: 0.95,// This will take 0.05 percent height from the top and show the status bar 
)

注意:isScrolled为true时才能使用

所以我根据您提供的代码创建了示例,我还添加了我的图标集,因此请根据您的需要进行更改。

import 'package:flutter/material.dart';

void main() {
  runApp(const MaterialApp(home: MyApp()));
}

class MyApp extends StatefulWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  final items = <Widget>[
    //1
    const Icon(
      Icons.phone_android,
      color: Colors.pink,
      semanticLabel: 'Internal Storage',
    ),
    //2
    const Icon(
      Icons.phone_android,
      color: Colors.pink,
      semanticLabel: 'Internal Storage',
    ),
    //3
    const Icon(
      Icons.phone_android,
      color: Colors.pink,
      semanticLabel: 'Internal Storage',
    ),
    //4
    const Icon(
      Icons.phone_android,
      color: Colors.pink,
      semanticLabel: 'Internal Storage',
    ),
    //5
    const Icon(
      Icons.phone_android,
      color: Colors.pink,
      semanticLabel: 'Internal Storage',
    ),
    //6
    const Icon(
      Icons.phone_android,
      color: Colors.pink,
      semanticLabel: 'Internal Storage',
    ),
    
    //Add the same item below this to make it full screen and items below 7 will have the minimum model sheet height.
    //7
    // const Icon(
    //   Icons.phone_android,
    //   color: Colors.pink,
    //   semanticLabel: 'Internal Storage',
    // ),

    //
    // FileSaveCard(icon: Icons.folder, color: Colors.blueAccent, title: 'My Documents', press: (){}),
    // FileSaveCard(icon: Icons.add_to_drive_rounded, color: Color.fromARGB(255, 254, 150, 0), title: 'Google Drive', press: (){}),
    // FileSaveCard(icon: Icons.mail, color: Colors.lightBlue, title: 'Send to Email', press: (){}),
    // FileSaveCard(icon: Icons.share, color: Colors.green, title: 'Share', press: (){}),
  ];

  @override
  Widget build(BuildContext context) {
    return SafeArea(
      top: true,
      child: Scaffold(
        body: ElevatedButton(
          onPressed: () {
            showModalBottomSheet<dynamic>(
              // use only when you want to use the full height of the screen.
              isScrollControlled: items.length > 6 ? true : false,
              context: context,
              builder: (BuildContext context) {
                return StatefulBuilder(builder: (context, setState) {
                  return FractionallySizedBox(
                    heightFactor: items.length > 6
                        ? 0.95
                        : null, // This widget will add padding from top showing the status bar
                    child: Container(
                      color: Colors.white,
                      child: Column(
                        mainAxisSize: MainAxisSize.min,
                        children: [
                          Container(
                            width: double.infinity,
                            decoration: BoxDecoration(
                              border: Border(
                                bottom: BorderSide(
                                    color: Color.fromARGB(255, 225, 225, 225)),
                              ),
                              //color: Color.fromARGB(255, 255, 255, 255),
                            ),
                            child: Row(
                              crossAxisAlignment: CrossAxisAlignment.start,
                              children: [
                                Padding(
                                  padding:
                                      const EdgeInsets.fromLTRB(15, 15, 10, 15),
                                  child: Icon(
                                    Icons.save,
                                    color: Color.fromARGB(255, 2, 136, 209),
                                    size: 28.0,
                                  ),
                                ),
                                Expanded(
                                  child: Material(
                                    color: Colors.transparent,
                                    child: InkWell(
                                      onTap: () {},
                                      child: Padding(
                                        padding: const EdgeInsets.fromLTRB(
                                            8.0, 13.0, 10.0, 10.0),
                                        child: Column(
                                          crossAxisAlignment:
                                              CrossAxisAlignment.start,
                                          children: [
                                            Row(
                                              mainAxisSize: MainAxisSize.min,
                                              crossAxisAlignment:
                                                  CrossAxisAlignment.start,
                                              children: [
                                                Container(
                                                  constraints: BoxConstraints(
                                                      minWidth: 0,
                                                      maxWidth:
                                                          MediaQuery.of(context)
                                                                  .size
                                                                  .width *
                                                              (2 / 3)),
                                                  child: Text(
                                                    'PDF Name',
                                                    overflow:
                                                        TextOverflow.ellipsis,
                                                    maxLines: 2,
                                                    softWrap: true,
                                                    style: TextStyle(
                                                      fontSize: 16.0,
                                                      fontWeight:
                                                          FontWeight.bold,
                                                      color: Color.fromARGB(
                                                          255, 117, 117, 117),
                                                    ),
                                                  ),
                                                ),
                                                Padding(
                                                  padding: EdgeInsets.fromLTRB(
                                                      5.0, 0.0, 0.0, 0.0),
                                                  child: Icon(
                                                    Icons.edit,
                                                    color: Color.fromARGB(
                                                        255, 2, 136, 209),
                                                    size: 16.0,
                                                  ),
                                                ),
                                              ],
                                            ),
                                            Padding(
                                              padding:
                                                  const EdgeInsets.fromLTRB(
                                                      0.0, 5.0, 0.0, 0.0),
                                              child: Text(
                                                "PDF Size",
                                                style: TextStyle(
                                                  fontSize: 12.0,
                                                  color: Color.fromARGB(
                                                      255, 117, 117, 117),
                                                ),
                                              ),
                                            ),
                                          ],
                                        ),
                                      ),
                                    ),
                                  ),
                                ),
                              ],
                            ),
                          ),
                          Row(children: <Widget>[
                            Expanded(
                                child: Padding(
                              padding: const EdgeInsets.fromLTRB(0, 10, 0, 4),
                              child: Divider(
                                color: Color.fromARGB(255, 220, 220, 220),
                                thickness: 1.1,
                              ),
                            )),
                            Padding(
                              padding: const EdgeInsets.fromLTRB(10, 10, 10, 4),
                              child: Text(
                                "Share/Save File to",
                                style: TextStyle(
                                  color: Color.fromARGB(255, 117, 117, 117),
                                  fontSize: 15.0,
                                ),
                              ),
                            ),
                            Expanded(
                                child: Padding(
                              padding: const EdgeInsets.fromLTRB(0, 10, 0, 4),
                              child: Divider(
                                color: Color.fromARGB(255, 220, 220, 220),
                                thickness: 1.1,
                              ),
                            )),
                          ]),
                          Expanded(
                            flex: items.length > 6 ? 1 : 0,
                            child: GridView.count(
                                padding: EdgeInsets.fromLTRB(0, 0, 0, 15),
                                crossAxisCount: 3,
                                shrinkWrap: true,
                                childAspectRatio: 1.25,
                                physics: const ScrollPhysics(),
                                children: items),
                          ),
                        ],
                      ),
                    ),
                  );
                });
              },
            );
          },
          child: const Text("Press"),
        ),
      ),
    );
  }
}


运行 应用程序,让我知道它是否适合您。