Mohale Nakana
Mohale Nakana

Reputation: 87

How to style LikeButton in flutter?

I am trying to create a like button (using like_button library) that also has to show the number of likes next to it however my icon is stacked on top of the number of likes, how can I create some space between them?

Expanded(
                          child: LikeButton(
                            size: 15,
                            likeCount: 0,
                            likeBuilder: (bool like) {
                              return Icon(
                                Icons.thumb_up,
                                color: Colors.red,
                              );
                            },
                          ), //Text("Liked"),
                        ),

this is what I get: enter image description here

Upvotes: 0

Views: 1447

Answers (1)

zpouip
zpouip

Reputation: 787

You can either wrap your Icon with a Padding widget:

LikeButton(
    size: 30,
    likeCount: 0,
    likeBuilder: (bool like) {
      return Padding(
          padding: const EdgeInsets.all(4.0)
          child: Icon(
              Icons.thumb_up,
              color: Colors.red,
            ),
        );
    },
),

or use the likeCountPadding property already defined in the LikeButton:

LikeButton(
    size: 15,
    likeCount: 0,
    likeCountPadding: const EdgeInsets.all(4.0)
    likeBuilder: (bool like) {
      return Icon(
        Icons.thumb_up,
        color: Colors.red,
      );
    },
),

Upvotes: 2

Related Questions