【问题标题】:Flutter remove border expansion tileFlutter 移除边框扩展磁贴
【发布时间】:2021-01-15 07:33:07
【问题描述】:

我创建了一个扩展图块,但我找不到删除框的边框或阴影的方法。你们知道命令吗?

这是一张照片

https://gyazo.com/6dc133ca91071c0afeb65899688311aa

这是一张图片,你可以在角落边缘看到它 对不起,因为它很长,但这是完整的扩展

ExpansionTile(
trailing: Text(''),
leading: Container(
    margin: new EdgeInsets.only(left: 0, top: 10.0, right: 0.0, bottom: 0.0),
    child: Image.asset(
        'images/food.png'
    )),
title: Row(
    children: < Widget > [


        Padding(
            padding: const EdgeInsets.only(right: 0, left: 10, top: 15, bottom: 15),
                child: Column(textDirection: TextDirection.ltr, crossAxisAlignment: CrossAxisAlignment.start, children: < Widget > [



                    Container(
                        margin: new EdgeInsets.only(left: 0.0, top: 7.0, right: 0.0, bottom: 3.0),
                        child: Text(
                            'Food System', textAlign: TextAlign.left,
                            style: TextStyle(
                                color: Colors.white,
                                fontSize: 25,
                            ),
                        )),
                    Text(
                        'Customize the food system', textAlign: TextAlign.left,
                        style: TextStyle(

                            color: Colors.white,
                            fontSize: 15,
                        ),
                    )

                ])),

    ], ),
children: < Widget > [



    Container(
        width: 300,
        margin: new EdgeInsets.only(left: 10.0, top: 0.0, right: 10.0, bottom: 10.0),
        color: Colors.transparent,
        child: new Container(


            padding: new EdgeInsets.all(20),
            child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: < Widget > [
                Container(
                    margin: new EdgeInsets.only(left: 15.0, top: .0, right: 20.0, bottom: 5.0),
                    child: Text('Storage', style: TextStyle(color: Colors.white, fontSize: 20, fontWeight: FontWeight.bold)), ),
                Center(child: Column(children: < Widget > [
                    Container(
                        child: Column(children: < Widget > [
                            Text('2.4 KG left        -        7 Days', style: TextStyle(color: Colors.white, fontSize: 20)),
                            Text('200 G / Meal  - 600 G / Day', style: TextStyle(color: Colors.white, fontSize: 20)),
                        ], ),
                        margin: new EdgeInsets.only(left: 0, top: 0, right: 0, bottom: 10.0),
                    )

                ], )),
                Container(
                    margin: new EdgeInsets.only(left: 18.0, top: .0, right: 20.0, bottom: 5.0),
                    child: Text('Meal times', style: TextStyle(color: Colors.white, fontSize: 20, fontWeight: FontWeight.bold)), ),
                Center(child: Column(children: < Widget > [

                    Text('1.   Breakfast   -   8:30 AM', style: TextStyle(color: Colors.white, fontSize: 20)),
                    Text('2.   Lunch         -   2:00 PM', style: TextStyle(color: Colors.white, fontSize: 20)),
                    Text('3.   Dinner        -   9:15  PM', style: TextStyle(color: Colors.white, fontSize: 20)),
                ], ))
            ], ), )
    ),




    Container(
        height: 50.0,
        width: 300,

        margin: new EdgeInsets.only(left: 10.0, top: 10.0, right: 10.0, bottom: 10.0),
        color: Colors.transparent,
        child: new Container(
            decoration: new BoxDecoration(
                color: Colors.blue,
                gradient: LinearGradient(
                    begin: Alignment.topRight,
                    end: Alignment.bottomLeft,
                    colors: [Color(0xff37b9ff), Color(0xff5d3afd)]),
                borderRadius: new BorderRadius.only(
                    topLeft: const Radius.circular(40.0),
                        topRight: const Radius.circular(40.0),
                            bottomLeft: const Radius.circular(40.0),
                                bottomRight: const Radius.circular(40.0),

                )
            ),
            child: Center(child:

                Text('Edit', style: TextStyle(color: Colors.white, fontSize: 15))

                , )
        )
    ),
])

【问题讨论】:

  • 嗨,您能添加您的代码吗...我们一起更正..
  • 我贴出来了,很抱歉这么长..

标签: flutter flutter-layout


【解决方案1】:

您可以将其包装在 Theme 小部件中并执行以下操作:

Theme(
  data: ThemeData().copyWith(dividerColor: Colors.transparent),
  child: ExpansionTile(

或者如果您使用自定义主题设置,您可以使用Theme.of(context) 而不是ThemeData(),如下所示:

Theme(
  data: Theme.of(context).copyWith(dividerColor: Colors.transparent),
      child: ExpansionTile(

【讨论】:

    【解决方案2】:

    此颜色来自您的应用主题和dividerColor ... 现在您可以在您的主题中添加此代码

    theme: ThemeData(
        dividerColor: Colors.transparent
      ),
    

    编辑 - 第二种方式

    另一种方式...您可以通过这种方式更改所有内容(完全自定义) 将文件从flutter sdk复制到你的lib

    如何找到文件:

    在类名上单击 + ctrl

    点击此处的目标图标

    在资源管理器中右击显示

    那你应该

    1. 更改文件名并将其复制到您的库中。
    2. 修复导入
    3. 更改类名(非常重要)(通过右键单击和重构)
    4. 终于用上了!! :)

    【讨论】:

    • 非常感谢,非常感谢! :)
    • 您是否还知道如何删除扩展图块末尾的这个框?我认为这是尾随的东西。当我添加更多文本时,我收到此错误,我无法将容器中的项目居中。这是一张图片:gyazo.com/c29329106dc5dcb162b71b5f41951b67
    • 老实说我不确定......但我认为你可以使用 OverflowBox ..woolha.com/tutorials/flutter-using-overflowbox-widget-examples
    • 另一种方法是(我确信这一点)...您可以从您的 sdk 复制 ExpansionTile 文件并自定义它(这很容易)
    • 我不知道在哪里可以找到它
    猜你喜欢
    • 1970-01-01
    • 2022-10-24
    • 1970-01-01
    • 2020-01-03
    • 1970-01-01
    • 2021-02-18
    • 2019-11-24
    • 2020-01-25
    • 2011-07-16
    相关资源
    最近更新 更多