RaisedButton is the material design button based on a Material widget that elevates when pressed upon in flutter. It is one of the most widely used buttons in the flutter library. Let’s understand this button with the help of an example.
Constructors:
Syntax:
RaisedButton({Key key,
@required VoidCallback onPressed,
VoidCallback onLongPress,
ValueChanged<bool> onHighlightChanged,
MouseCursor mouseCursor,
ButtonTextTheme textTheme,
Color textColor,
Color disabledTextColor,
Color color,
Color disabledColor,
Color focusColor,
Color hoverColor,
Color highlightColor,
Color splashColor,
Brightness colorBrightness,
double elevation,
double focusElevation,
double hoverElevation,
double highlightElevation,
double disabledElevation,
EdgeInsetsGeometry padding,
VisualDensity visualDensity,
ShapeBorder shape,
Clip clipBehavior: Clip.none,
FocusNode focusNode,
bool autofocus: false,
MaterialTapTargetSize materialTapTargetSize,
Duration animationDuration,
Widget child})
Properties:
- child: the widget to be displayed.
- shape: the shape of the raised button.
- color: the color of the button.
- padding: padding inside the button.
- disabledColor: the color of the button when disabled.
- splashColor: splash color of the button.
- textColor: the color of the text.
- onLongPress: the callback function when the button is long pressed.
- onPressed: the callback function when the button is tapped.
Implementation:
The main.dart file:
Dart
import 'package:flutter/material.dart'; void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { // This widget is the root of your application. @override Widget build(BuildContext context) { return MaterialApp( title: 'Raised Button', theme: ThemeData( primarySwatch: Colors.blue, ), home: MyHomePage(), debugShowCheckedModeBanner: false, ); } } class MyHomePage extends StatefulWidget { @override _MyHomePageState createState() => _MyHomePageState(); } class _MyHomePageState extends State<MyHomePage> { String istapped = ''; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('GeeksforGeeks'), backgroundColor: Colors.green, ), body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ RaisedButton( // disabledColor: Colors.red, // disabledTextColor: Colors.black, padding: const EdgeInsets.all(20), textColor: Colors.white, color: Colors.green, onPressed: () { setState(() { istapped = 'Button tapped'; }); }, child: Text('Enabled Button'), ), Text( istapped, textScaleFactor: 2, ) ], ), ), backgroundColor: Colors.lightBlue[50], ); } } |
Output:
If the properties are defined as below:
RaisedButton(
disabledColor: Colors.red,
disabledTextColor: Colors.black,
onPressed: null,
child: Text('Disabled Button'),
),
The following design changes can be observed:

If the properties are defined as below:
RaisedButton(
padding: const EdgeInsets.all(20),
textColor: Colors.white,
color: Colors.green,
onPressed: ()=>null,
child: Text('Enabled Button'),
),
The following design changes can be observed:

If the properties are defined as below:
RaisedButton(
padding: const EdgeInsets.all(20),
textColor: Colors.white,
color: Colors.green,
onPressed: (){
setState(() {
istapped='Button tapped';
});
},
child: Text('Enabled Button'),
),
Text(istapped,textScaleFactor: 2,)
),
The following design changes can be observed:

Explanation:
- Create RaisedButton and wrap it with Center widget.
- Give the child of RaisedButton as a Text widget.
- Perform onPressed function when the button is tapped.
- Perform optional onLongPress function when button is long pressed.
Recommended Posts:
- Difference Between Stateless and Stateful Widget in Flutter
- PageView Widget in Flutter
- FlatButton Widget in Flutter
- BottomNavigationBar Widget in Flutter
- ClipRRect Widget in Flutter
- Drawer Widget in Flutter
- ClipRect Widget in Flutter
- Opacity Widget in Flutter
- RotatedBox Widget in Flutter
- TextSpan Widget in Flutter
- Align Widget in Flutter
- ClipOval widget in Flutter
- Flutter - AppBar Widget
- Flutter - Expanded Widget
- Flutter - SilverAppBar Widget
- Flutter - OctoImage Widget
- Flutter - Tooltip Widget
- Flutter - Stack Widget
- Flutter - Flexible Widget
- Flutter - AbsorbPointer Widget
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

