简体   繁体   English

我对 Flutter 上的空格有疑问

[英]I have a problem with the spaces on Flutter

I can't understand what I'm doing wrong.我不明白我做错了什么。 I have created a small detail page for an application that I am developing on vegan recipes.我为我在纯素食谱上开发的应用程序创建了一个小的详细信息页面。 I have a space that I can't take away and I don't understand what generated it.我有一个无法带走的空间,我不明白是什么产生了它。 Space is what you see circled in red.空间就是你看到的红色圆圈。 Can you help me?你能帮助我吗? Thank you, Vincenzo谢谢你,文森佐

我的详细信息页面


class _CookDetailState extends State<CookDetail> {

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        leading: IconButton(
          icon: Icon(Icons.arrow_back, color: Colors.white),
          onPressed: () => Navigator.of(context).pop(),
  ), 
        title: Text(this.widget.ricetta.title),
        backgroundColor: AppColors.darkModeBackgroundColor),
      body: Stack(
        children: <Widget>[
          Positioned(
            top: 0,
            left: 0,
            right: 0,
            bottom: 0,
            child: Hero(
              tag: this.widget.ricetta.title,
              child: Container(
                decoration:
                    BoxDecoration(image: DecorationImage(image: NetworkImage("https://cdn.pixabay.com/photo/2017/09/16/19/21/salad-2756467__340.jpg"),
                      fit: BoxFit.cover)),
              ),
            ),
          ),


          // white container
          Positioned(
            left: 24.0,
            right: 24.0,
            bottom: 16.0,
            child: Container(
              //height: MediaQuery.of(context).size.height * 0.75,
              //height: 650,
              child: ClipRect(
                child: BackdropFilter(
                  filter: ImageFilter.blur(sigmaX: 100, sigmaY: 200),
                  child: Container(
                       padding: EdgeInsets.all(16.0),
                       height: 500,
                       decoration: BoxDecoration(borderRadius: BorderRadius.circular(16.0), color: Colors.white.withOpacity(0.2)),
                      child: SingleChildScrollView(
                        child: Container(
                    padding: EdgeInsets.all(16.0),
                    height: 800,
                    decoration: BoxDecoration(borderRadius: BorderRadius.circular(16.0), color: Colors.white.withOpacity(0.2)),
                    child: Column(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: <Widget>[
                        Row(
                          children: <Widget>[
                            Text(
                              this.widget.ricetta.title, 
                              style: TextStyle(color: Colors.white, fontSize: 20.0, fontWeight: FontWeight.bold),
                            ),
                            Spacer(),
                            Icon(
                              Icons.favorite_border,
                              size: 24.0,
                              color: Colors.white,
                            ),
                          ],
                        ),
                        new Container(
                          child: ListView(
                            shrinkWrap: true,
                            children: <Widget>[
                              this._generateList(this.widget.ricetta.listIngredieti),
                              this._generateStep(this.widget.ricetta.listPassaggio),
                            ],
                          ),
                        ),
                      ],
                    ),
                  ),  
                        ),
                      ),
                ),
              ),
            ),
          ),
        ],
      ),
    );
  }


  Widget _generateList(List<Ingrediente> listIngrediente){

    return Column(
      children: <Widget>[
        for ( var myElement in listIngrediente ) Text(
            myElement.title + " " + myElement.quantita,
            style: TextStyle(color: Colors.white, fontSize: 12, fontWeight: FontWeight.w600))
      ],
    );
  }

  Widget _generateStep(List<StepRicetta> listStep){
    return Column(
      children: <Widget>[
        for (var myStep in listStep) CheckboxListTile(title: AutoSizeText(myStep.title),
          value: false, onChanged: (bool selected){
              print("Valore selected");
          },
          secondary: const Icon(Icons.hourglass_empty),
        )
      ],
    );
  }

}

My concept would be to leave the writing "Recipe 1", blocked, scrolling only and exclusively the list concerning the list of ingredients, such as "Put the bread", "Put 300 g of water"我的想法是留下文字“食谱 1”,被阻止,只滚动和排他的关于成分列表的列表,例如“放面包”,“放 300 克水”

I think your second EdgeInsets.all(16.0) create the space, do you have try this: EdgeInset.only(left: 16.0, right: 16.0) ?我认为您的第二个EdgeInsets.all(16.0)创建了空间,您是否尝试过: EdgeInset.only(left: 16.0, right: 16.0)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM