Flutter - Circular OutlinedButton
The OutlinedButton class represents a material design outlined button that is
essentially a TextButton with an outlined border. The outlined buttons are
medium-emphasis buttons. In a flutter application, the OutlinedButtons contain
actions that are important, but they are not the primary action in an app. An
OutlinedButton widget’s default style is defined by defaultStyleOf. The
flutter application developers can override the OutlinedButton’s style with
its style parameter. An OutlinedButton has a default ButtonStyle.side which
defines the appearance of the outline. The flutter app developers can specify
an OutlinedButton's shape and the appearance of its outline by specifying both
the ButtonStyle.shape and ButtonStyle.side properties.
The following flutter application development tutorial will demonstrate how to create a circular OutlinedButton widget. Here we will use the OutlinedButton class’s styleFrom() static method’s shape and fixedSize parameters to create a circular-shaped OutlinedButton.
The OutlinedButton class’s styleFrom() method is a static convenience method that constructs an outlined button ButtonStyle given simple values. By default, OutlinedButton class styleFrom() method returns a ButtonStyle that doesn't override anything.
The ButtonStyle class represents the visual properties that most buttons have in common. The ButtonStyle class’s all properties are null by default.
The flutter developers can create a circle-shaped OutlinedButton by passing a value to the styleFrom() method’s shape parameter and another value to the fixedSize parameter.
The ButtonStyle class’s shape property defines the shape of the button's underlying Material.
The CircleBorder class represents a border that fits a circle within the available space. Here we set the same width and height for the OutlinedButton, so CircleBorder() constructor creates a circular OutlinedButton.
The flutter developers can change an OutlinedButton‘s width and height (size) by passing a value to the styleFrom() method’s fixedSize parameter.
The styleFrom() method’s fixedSize parameter value is a Size instance, which holds a 2D floating-point size. Here we used the Size class Size(double width, double height) constructors to create a Size with the given width and height.
The following flutter application development tutorial will demonstrate how to create a circular OutlinedButton widget. Here we will use the OutlinedButton class’s styleFrom() static method’s shape and fixedSize parameters to create a circular-shaped OutlinedButton.
The OutlinedButton class’s styleFrom() method is a static convenience method that constructs an outlined button ButtonStyle given simple values. By default, OutlinedButton class styleFrom() method returns a ButtonStyle that doesn't override anything.
The ButtonStyle class represents the visual properties that most buttons have in common. The ButtonStyle class’s all properties are null by default.
The flutter developers can create a circle-shaped OutlinedButton by passing a value to the styleFrom() method’s shape parameter and another value to the fixedSize parameter.
The ButtonStyle class’s shape property defines the shape of the button's underlying Material.
The CircleBorder class represents a border that fits a circle within the available space. Here we set the same width and height for the OutlinedButton, so CircleBorder() constructor creates a circular OutlinedButton.
The flutter developers can change an OutlinedButton‘s width and height (size) by passing a value to the styleFrom() method’s fixedSize parameter.
The styleFrom() method’s fixedSize parameter value is a Size instance, which holds a 2D floating-point size. Here we used the Size class Size(double width, double height) constructors to create a Size with the given width and height.
main.dart
import 'package:flutter/material.dart';
void main(){
runApp(
MaterialApp(
theme: ThemeData(primarySwatch: Colors.amber),
home: Scaffold(
appBar: AppBar(
title: const Text("Flutter - Circular OutlinedButton")
),
body: Center(
child: OutlinedButton(
onPressed: (){},
child: const Text("Click Me"),
style: OutlinedButton.styleFrom(
fixedSize: const Size(125, 125),
shape: const CircleBorder()
)
),
)
),
),
);
}