Text widget with circular background in flutter
Asked Answered
P

4

8

enter image description here

How can I get this type of rounded background in Text widget?

Percival answered 26/2, 2020 at 17:56 Comment(0)
B
21

You can achieve it by

      CircleAvatar(
          backgroundColor: Colors.grey,
          child: Center(
            child: Text(
              "B",
              style: TextStyle(color: Colors.black),
            ),
          ),
        )
Bussey answered 26/2, 2020 at 18:13 Comment(0)
N
7

Screenshot:

enter image description here


You can also use ClipOval

ClipOval(
  child: Container(
    color: Colors.grey,
    padding: EdgeInsets.symmetric(horizontal: 30),
    child: Text(
      "B",
      style: TextStyle(color: Colors.black, fontSize: 90),
    ),
  ),
)
Nonstriated answered 26/2, 2020 at 18:16 Comment(0)
C
0

You can use BoxDecoration:

Container(
  width: 30,
  height: 30,
  alignment: Alignment.center,
  decoration: BoxDecoration(
    borderRadius: BorderRadius.circular(15),
  ),
  child: const Text('B'),
);
Chao answered 16/11, 2023 at 9:25 Comment(0)
P
-4

Just use a FAB:

 floatingActionButton: FloatingActionButton(
    backgroundColor: Colors.grey,
    child: Text(
      "A",
      style: TextStyle(
        fontSize: 20,
        fontStyle: FontStyle.italic,
      ),
    ),
  )
Percival answered 27/2, 2020 at 15:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.