The RaisedButton
is to create a material button whose elevation increases when the button is pressed.
The default constructor creates a filled button.
RaisedButton(
onPressed: // required argument
textColor:
color:
disabledColor:
padding:
shape:
child:
)
It contains many input parameters which can be configured to change its behavior and appearance.
The onPressed
parameter is to callback when the button is tapped or otherwise activated.
The textColor
parameter is to apply color to the button's text.
The color
parameter is to fill the button with a color.
The padding
parameter is to add the internal padding for the button's [child].
The shape
parameter is to define shape for the button.
The child
parameter is to add the child widget below the RaisedButton widget in a tree.
The following code snippet shows how to configure RaisedButton
widget.
RaisedButton(
onPressed: () {},
child: const Text('Enabled Button', style: TextStyle(fontSize: 20)),
),
The example shows how to place RaisedButton on the screen.
import 'package:flutter/material.dart';
class RaisedButtonDemo extends StatelessWidget {
Widget build(BuildContext context) {
return Center(
child: RaisedButton(
onPressed: () {},
child: const Text('Enabled Button', style: TextStyle(fontSize: 20)),
),
);
}
}
class MyApp extends StatelessWidget {
static const String _title = 'RaisedButton Demo';
Widget build(BuildContext context) {
return MaterialApp(
title: _title,
home: Scaffold(
appBar: AppBar(title: const Text(_title)),
body: RaisedButtonDemo(),
),
);
}
}
void main() => runApp(MyApp());