Конструктор Flutter Gridview не работает с колонкой - PullRequest
0 голосов
/ 27 августа 2018

Вот мой файл, и Gridview не работает, он показывает мне единственную ошибку ...

Я использую несколько дочерних элементов для столбца, и мне нужно использовать компоновщик gridview здесь.

ТакжеЯ попытался использовать Stack и удалил столбец, и это сработало, но в этом случае мне нужно использовать много отступов для каждого раздела, и это бесполезно.

Widget build(BuildContext context) {
return Scaffold(
    appBar: AppBarComponent(),
    drawer: new Drawer(child: DrawerList()),
    body: Container(
      color: Colors.black12.withOpacity(0.02),
        child: Column(
          children: <Widget>[
            Container(
              child: Row(
                children: <Widget>[
                  Form(
                    key: formKey,
                    child: Container(
                      width: 280.0,
                      height: 40.0,
                      child: TextFormField(
                        onSaved: (val) => keyword = val,
                        validator: this._validateKeyword,
                        decoration: new InputDecoration(
                          hintText: "Search Product",
                          fillColor: Colors.white,
                          filled: true,
                          contentPadding: new EdgeInsets.all(12.0),
                        ),
                      ),
                    ),
                  ),
                  ButtonTheme(

                    minWidth: 6.0,
                    height: 40.0,

                    child: RaisedButton(
                      color: Colors.redAccent.withOpacity(0.9),

                      onPressed: _search,
                      child: Icon(Icons.search,color:Colors.white,size: 26.0),
                    ),
                  ),
                ],
              ),
            ),
            Padding(padding: new EdgeInsets.only(top: 12.0)),
            Container(
              color: Colors.white,
              height: 40.0,
              child: Row(
                mainAxisSize: MainAxisSize.min,
                children: <Widget>[
                  Icon(Icons.assignment_turned_in,color: Colors.greenAccent,),

                  Padding(
                    padding: const EdgeInsets.only(left: 4.0,right: 8.0),
                    child: Text("SEARCH RESULT",style: TextStyle(fontSize:14.0,fontWeight: FontWeight.w500),),
                  ),
                  Padding(padding: EdgeInsets.only(left: 12.0)),
                  ButtonTheme(
                    height: 24.0,
                    child: RaisedButton(
                      padding: const EdgeInsets.all(6.0),
                      onPressed:()=>print("a"),
                      child: new Row(
                        mainAxisSize: MainAxisSize.min,
                        children: <Widget>[
                          Padding(
                            padding: const EdgeInsets.only(right: 6.0),
                            child: Icon(Icons.filter,size: 16.0,),
                          ),
                          Text('FILTER',style: TextStyle(fontSize: 12.0),),
                        ],
                      ),
                    ),
                  ),
                  Padding(padding: EdgeInsets.only(left: 10.0)),
                  ButtonTheme(
                    height: 24.0,
                    child: RaisedButton(
                      onPressed:()=>print("a"),
                      padding: const EdgeInsets.all(6.0),
                      child: new Row(
                        mainAxisSize: MainAxisSize.min,
                        children: <Widget>[
                          Padding(
                            padding: const EdgeInsets.only(right: 6.0),
                            child: Text('SORT BY',style: TextStyle(fontSize: 12.0),),
                          ),
                          Icon(Icons.keyboard_arrow_down,size: 16.0,),
                        ],
                      ),
                    ),
                  ),
                ],
              ),
            ),

            Expanded(
                child: new GridView.builder(

                  itemCount: 10,
                  gridDelegate: new SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2),
                  itemBuilder: (BuildContext context, int index) {



                    return Container(
                      child: Card(
                        child: Column(
                          crossAxisAlignment: CrossAxisAlignment.center,
                          children: <Widget>[
                            Padding(
                              padding: const EdgeInsets.only(top: 8.0),
                              child: Image.asset('images/product-1.png',width: 100.0),
                            ),
                            Container(
                              color: Colors.black12.withOpacity(0.02),
                              height: 55.0,
                              child: Column(
                                children: <Widget>[
                                  Padding(
                                    padding: const EdgeInsets.only(left: 4.0),
                                    child: Container(
                                      child: Text("It is a long established fact that a readerIt is a long established fact that a reader.",
                                          overflow: TextOverflow.ellipsis,
                                          style: TextStyle(fontSize: 14.0)),
                                    ),
                                  ),
                                  Padding(
                                    padding: const EdgeInsets.only(top:8.0,left: 4.0),
                                    child: Row(
                                      children: <Widget>[
                                        Text("\$57 ",style: TextStyle(fontSize:12.0,color: Colors.red,fontWeight: FontWeight.bold),),
                                        Text(" \$57",style: TextStyle(fontSize:12.0,decoration: TextDecoration.lineThrough),),
                                        Padding(
                                          padding: const EdgeInsets.only(left: 4.0),
                                          child: ButtonTheme(

                                            minWidth: 8.0,
                                            height: 8.0,

                                            child: RaisedButton(
                                              color: Colors.white.withOpacity(0.9),

                                              onPressed: null,
                                              child: Icon(Icons.shopping_cart,size: 18.0),
                                            ),
                                          ),
                                        ),

                                        Padding(
                                          padding: const EdgeInsets.only(left: 1.0),
                                          child: ButtonTheme(

                                            minWidth: 8.0,
                                            height: 8.0,

                                            child: RaisedButton(
                                              color: Colors.white.withOpacity(0.9),

                                              onPressed: null,
                                              child: Icon(Icons.favorite,size: 18.0),
                                            ),
                                          ),
                                        ),


                                      ],
                                    ),
                                  )
                                ],
                              ),

                            ),



                          ],

                        ),
                      ),
                    );



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

}

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...