【问题标题】:Expandable row in table with flutter- is it possible?颤动的表格中的可扩展行 - 有可能吗?
【发布时间】:2022-01-01 09:16:53
【问题描述】:

我正在尝试一种方法来扩展表格中的行,但似乎没有任何效果。

我想点击表格中的某一行并使其可扩展以显示更多关于该 ROW 的数据,然后第二次按下会将其关闭回到表格中。

我尝试使用 Expanded 小部件,但它不起作用:

import 'package:flutter/material.dart';

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

  @override
  Widget build(BuildContext context) {
    return Container(
      child: Table(
          defaultColumnWidth: FixedColumnWidth(120.0),
          border: TableBorder.all(
              color: Colors.black,
              style: BorderStyle.solid,
              width: 2),
          children: [
      TableRow( children: [
      Column(children:[Text('Website', style: TextStyle(fontSize: 20.0))]),
    Column(children:[Text('Tutorial', style: TextStyle(fontSize: 20.0))]),
    Column(children:[Text('Review', style: TextStyle(fontSize: 20.0))]),
    Card(
    child: ExpansionTile(
    title: Text(
    'Website',
    style: TextStyle(fontSize: 20.0),
    ),
    children: <Widget>[
    Text('About Website'),
    Text('Add more data'),
    Text('add more more data'),
    // add more data that you want like this
    ],
    ),
    )],
      ),]
    )


    );
  }
}

任何帮助或建议都会很棒!谢谢!

这是我的代码的结果: 但我想打开没有线条和表格边框的所有行。

【问题讨论】:

    标签: flutter dart flutter-layout


    【解决方案1】:

    您可以为此使用 ExpansionPanelList 小部件或 expandable 依赖项。

    【讨论】:

    • 使用可扩展是我需要的!谢谢。
    【解决方案2】:

    使用 Card 包装您需要扩展的每个小部件, 并在Card 中添加ExpansionTile

    例子-

    Card(
        child: ExpansionTile(
          title: Text(
            'Website',
            style: TextStyle(fontSize: 20.0),
          ),
          children: <Widget>[
            Text('About Website'),
            Text('Add more data'),
            Text('add more more data'),
            // add more data that you want like this
          ],
        ),
      );
    

    【讨论】:

    • 谢谢,但我不确定如何扭曲每个小部件。我尝试使用您的代码,但它用所有行扩展了表格。我在主帖中添加了一张图片供您查看。
    • 很高兴为您提供帮助...欢迎和快乐编码:)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-02-23
    • 1970-01-01
    • 2019-09-06
    • 1970-01-01
    • 2011-07-05
    • 1970-01-01
    • 2021-03-04
    相关资源
    最近更新 更多