0

我正在尝试使用 SingleChildScrollView 使主屏幕可滚动,但在阅读 Stackoverflow 上的其他问题时,似乎 Expanded 会导致问题。我是 Flutter 的新手,所以我在这里问你是否知道我该如何解决这个问题。我注意到,如果我将 Column 包装在 SingleChildScrollView 小部件中,它可以在没有 Expanded 小部件的情况下工作,所以这肯定是问题所在。你知道我怎样才能替换扩展小部件吗?我不知道它会有多高,因为我可能会添加更多按钮。

这里有代码:

return Scaffold(
  body: Stack(
  children: [

    Container(
      margin: EdgeInsets.symmetric(horizontal: size.width * 0.10),
      child: Column(children: [

        SizedBox(height: statusBarHeight), // spazio per statusbar

        Align(
          alignment: Alignment.topLeft,
          child: Container(
            margin: EdgeInsets.only(top: size.height * 0.04),
            height: 20,
            // color: Colors.orange,
            child: Row(
              mainAxisAlignment: MainAxisAlignment.start,
              children: [

              Icon(Icons.wb_sunny_sharp, size: 20, color: Color(0xff8276f4)),

              SizedBox(width: 8), //  Spazio laterale da icona
              
              Text("MER 18 AGO", style: TextStyle(
                fontWeight: FontWeight.bold,
                fontSize: 18,
                color: Color(0xff8276f4),
              ),),
              
            ],)
          ),
        ),

        Container(
          margin: EdgeInsets.only(top: 15, bottom: 20),
          width: size.width * 0.80,
          decoration: BoxDecoration(
            // color: Color(0xffaf8eff),
            borderRadius: BorderRadius.circular(29.5)
            ),
          child: Text("Ciao, Andrea!", style: TextStyle(
            fontWeight: FontWeight.w700,
            fontSize: 30,
            color: Color(0xff2e3760),
          ),),
          alignment: Alignment.centerLeft,
          


        ),

      
      
        Container(
          height: size.height * 0.30,
          width: size.width * 0.80,
          decoration: BoxDecoration(
          color: Color(0xffdee0e3),
          image: DecorationImage(
            scale: 0.5,
            image: AssetImage('assets/images/standing.png')
            ),
          borderRadius: BorderRadius.circular(29.5)
          ),
          
        ),

        SizedBox(height: 20),

        Align(
          alignment: Alignment.topLeft,
          child: Container(
              child: Text("Cosa vuoi fare oggi?", style: TextStyle(
                fontWeight: FontWeight.bold,
                fontSize: 20,
                color: Color(0xff2e3760),
              ),),
            ),
        ),

        Expanded(
          
          
          child: Container(
            // color: Colors.orange,
            margin: EdgeInsets.only(top: 20),
            child: GridView.count(
              padding: EdgeInsets.all(0),
              childAspectRatio: 0.8,
              crossAxisSpacing: 20,
              mainAxisSpacing: 20,
              children: <Widget>[

              CategoryCard(
                title: "Profilo",
                numeroicona: 60307,
                numerocolore: 0xFF8c7ffd,
              ),
              CategoryCard(
                title: "Università",
                numeroicona: 58713,
                numerocolore: 0xffb08dff,
              ),
              CategoryCard(
                title: "Idee",
                numeroicona: 58235,
                numerocolore: 0xFF1a88ff,
              ),
              CategoryCard(
                title: "Progetti",
                numeroicona: 61080,
                numerocolore: 0xFF4b5982,
              ),

              

              ],
              crossAxisCount: 2),
          ),
            
        ),
          
          
      ],),
    ),
4

1 回答 1

0

现在它会像这样滚动

输出

我用过SliverToBoxAdapter,然后Column换成GridViewSliverGrid.count我正在对回购进行公关。检查后告诉我这是你想要的吗?

于 2021-08-18T22:01:57.733 回答