未定义命名参数“ icon”。尝试定义名称为“ icon”的命名参数

时间:2020-09-05 10:21:00

标签: flutter flutter-gridview

Grid view with flutter icons with 2 columns and Each Images Text under the image aligned bottom center with 300 by 300 pixel dimensions or icon size 98 or 85我的代码如下所示。

    appBar: AppBar(title: Text("Digital Directory"),),
  body: Center(
      child: GridView.count(
        primary: false,
        padding: const EdgeInsets.all(20),
        crossAxisSpacing: 10,
        mainAxisSpacing: 10,
        crossAxisCount: 2,
        children: <Widget>[
          Container(
            color: Colors.cyan[100],
             child: GestureDetector
          (
          onTap:(){

            Navigator.of(context).push(MaterialPageRoute(builder:(context)=>MobileAccessoriesPage(),
            ),
            );
          },

    child: Center (child:Text ('Mobiles'),icon:Icons.mobile_screen_share),

         ),
  ),

我正在使用带有颤动平面图标的网格视图应用程序构建,并且我想在单击平面图标时导航到其他屏幕(即.dart页面/屏幕)`

1 个答案:

答案 0 :(得分:0)

使用以下代码更改“中心儿童”:

Center(
   child: Row(
      mainAxisAlignment: MainAxisAlignment.spaceEvenly,
              crossAxisAlignment: CrossAxisAlignment.center,
                   children: [
                              Text(
                                'Mobiles',
                              ),
                              Icon(Icons.mobile_screen_share),
                            ],
                          ),
                         )

这将使文本“ mobiles”和“ Icon”并排出现。如果您对对齐不满意,请更改mainAxisAlignmentcrossAxisAlignment