The named parameter 'icon' isn't defined. Try defining a named parameter with the name 'icon'

Issue

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 85My code is as below`import

    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),

         ),
  ),

I am building grid view Application with flutter flat icons and I want to navigate when clicked on Flat Icons to another screens (i.e .dart page/screen)`

Solution

Change the Child Of Center with the code below:

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

This would make the text ‘mobiles’ and the Icon to appear side by side. If you are not happy with the alignment change the mainAxisAlignment and the crossAxisAlignment

Answered By – Adithya Shetty

Answer Checked By – Gilberto Lyons (FlutterFixes Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *