为什么这是一个失败的断言?

问题描述 投票:0回答:1

我试图在一个屏幕中使用一个垫子列表,所以我使用了 "SingleChildScrollView"。当我运行App时,我得到了以下错误。" The following assertion was thrown building Listener:Failed assertion: boolean expression must not be null" 。我在网上看到了一些解决这个问题的方法,但是没有一个对我有效。

我的代码基本上是这样的。

class example extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Container(
        child: SingleChildScrollView(
          child: Column(
            children: <Widget>[

                      Padding(
                        padding: const EdgeInsets.all(16.0),
                        child: Container(
                          child: new FittedBox(
                            child: Material(
                                color: Colors.white,
                                elevation: 4,
                                borderRadius: BorderRadius.circular(24.0),
                                shadowColor: Color(0x802196F3),
                                child: Row(
                                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                  children: <Widget>[
                                    Container(
                                      child: Padding(
                                        padding: const EdgeInsets.only(left: 16.0),
                                        child: myDetailsContainer1(),
                                      ),
                                    ),

                                    Container(
                                      width: 250,
                                      height: 150,
                                      child: ClipRRect(
                                        borderRadius: new BorderRadius.circular(24.0),
                                        child: Image(
                                            fit: BoxFit.contain,
                                            alignment: Alignment.topRight,
                                            image: AssetImage("imagens/fundo.jpg")
                                        ),
                                      ),),
                                  ],)
                            ),
                          ),
                        ),
                      ),
              Padding(), // Same as above
              Padding(),// Same as above
              Padding(),// Same as above
              Padding(),// Same as above

            ],
          ), 
        ),
      ),
    );
  }
}



Widget myDetailsContainer1() {
  return Column(
    mainAxisAlignment: MainAxisAlignment.spaceEvenly,
    children: <Widget>[
      Padding(
        padding: const EdgeInsets.only(left: 8.0),
        child: Container(child: Text("Chocolate Haven",
          style: TextStyle(color: Color(0xffe6020a), fontSize: 24.0,fontWeight: FontWeight.bold),)),
      ),
      Padding(
        padding: const EdgeInsets.only(left: 8.0),
        child: Container(child: Row(children: <Widget>[
          Container(child: Text("4.3",
            style: TextStyle(color: Colors.black54, fontSize: 18.0,),)),
          Container(child: Icon(
            FontAwesomeIcons.solidStar, color: Colors.amber, size: 15.0,),),
          Container(child: Icon(
            FontAwesomeIcons.solidStar, color: Colors.amber, size: 15.0,),),
          Container(child: Icon(
            FontAwesomeIcons.solidStar, color: Colors.amber, size: 15.0,),),
          Container(child: Icon(
            FontAwesomeIcons.solidStar, color: Colors.amber, size: 15.0,),),
          Container(child: Icon(
            FontAwesomeIcons.solidStarHalf, color: Colors.amber,
            size: 15.0,),),
          Container(child: Text("(75) \u00B7 1.2 mi",
            style: TextStyle(color: Colors.black54, fontSize: 18.0,),)),
        ],)),
      ),
      Container(child: Text("Pastries \u00B7 Phoenix,AZ",
        style: TextStyle(color: Colors.black54, fontSize: 18.0,),)),
    ],
  );
}
android flutter dart
1个回答
热门问题
推荐问题
最新问题