Ramesh
Ramesh

Reputation: 177

How to draw star with label in flutter

I am trying to draw *star in label as the image below

enter image description here

I have tried

Text("5 *",style: TextStyle(color: Colors.white, backgroundColor: Colors.green),)

But I don't know how I can embed *(Star) with label ?

Upvotes: 1

Views: 2574

Answers (3)

Sagar Acharya
Sagar Acharya

Reputation: 3767

Just check this code :

The star icon can be obtained using this plugin:

https://pub.dev/packages/material_design_icons_flutter#-readme-tab-

Container(
                decoration: BoxDecoration(borderRadius: BorderRadius.circular(10.0),color: Colors.green),
                width: 100,
                height: 50,

                              child: Row(
                                mainAxisAlignment: MainAxisAlignment.center,
                                crossAxisAlignment: CrossAxisAlignment.center,
                    children: <Widget>[
                      Padding(
                        padding: const EdgeInsets.all(8.0),
                        child: Text('5',style: TextStyle(color: Colors.white),),
                      ),
                           Icon(MdiIcons.star,color: Colors.white,),
                    ],
                  ),
              ),

Upvotes: 1

Naveen Avidi
Naveen Avidi

Reputation: 3073

Container(
              width: 80,
            height:50,
              padding: EdgeInsets.all(10),
              alignment: Alignment.center,
              decoration: BoxDecoration(
                borderRadius: BorderRadius.circular(10),
                color: Colors.green[700],
              ),
              child: Row(
                mainAxisAlignment:MainAxisAlignment.center,
                children: [
                Text('5',
                    style: TextStyle(
                      color: Colors.white,
                      fontSize: 20,
                      fontWeight: FontWeight.bold,
                    )),
                SizedBox(width: 10),
                Icon(Icons.star, color: Colors.white)
              ])),

Screenshot

Upvotes: 2

Ahmed Khattab
Ahmed Khattab

Reputation: 2799

you can use the icon class for that


Row(
  children: [
    Text("5),
    Icon(Icons.star),
  ]

)

Upvotes: 3

Related Questions