Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR DART

how to make a circular button shape in flutter

// 1
ElevatedButton(
          child: const Text(
            'Button',
            style: TextStyle(fontSize: 24),
          ),
          onPressed: () {},
          style: ElevatedButton.styleFrom(
              fixedSize: const Size(200, 200)
              shape: const CircleBorder(), 
          ),
),

// 2
MaterialButton(
        color: Colors.blue,
        shape: const CircleBorder(),
        onPressed: () {},
        child: const Padding(
          padding: EdgeInsets.all(100),
          child: Text(
            'A circle button',
            style: TextStyle(color: Colors.white, fontSize: 24),
          ),
        ),
),

// 3
GestureDetector(
            onTap: () {
              print('Button tapped');
            },
            child: const CircleAvatar(
              radius: 100,
              backgroundColor: Colors.indigo,
              child: Text(
                'A Button',
                style: TextStyle(fontSize: 30),
              ),
)),

// 4
ElevatedButton(
        style: ElevatedButton.styleFrom(
            shape: const CircleBorder(), primary: Colors.red),
        child: Container(
          width: 200,
          height: 200,
          alignment: Alignment.center,
          decoration: const BoxDecoration(shape: BoxShape.circle),
          child: const Text(
            'I am a button',
            style: TextStyle(fontSize: 24),
          ),
        ),
        onPressed: () {},
),

// 5
ClipRRect(
          borderRadius: BorderRadius.circular(120),
          child: SizedBox(
            width: 240,
            height: 240,
            child: ElevatedButton.icon(
              icon: const Icon(
                Icons.camera,
                size: 40,
              ),
              label: const Text(
                'Camera',
                style: TextStyle(fontSize: 25),
              ),
              onPressed: () {},
            ),
          ),
),
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #circular #button #shape #flutter
ADD COMMENT
Topic
Name
8+7 =