Articles → FLUTTER AND DART → Raisedbutton Widget In Flutter
Raisedbutton Widget In Flutter
Purpose
Example
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
Widget build(BuildContext context) {
return MaterialApp(home: Scaffold(
appBar: AppBar(title: Text("my app bar")),
body: RaisedButton(
onPressed: null,
child: Text(
'Disabled Button'
),
),
));
}
}
Output
Click to Enlarge
Onpressed Event
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(),
body: RaisedButton(
onPressed: () {
print("Raised Button Clicked");
},
child: Text('Button'),
),
));
}
}
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
printCommand() {
print("Raised Button Clicked");
}
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(),
body: RaisedButton(
onPressed: printCommand,
child: Text('Button'),
),
));
}
}
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(),
body: RaisedButton(
onPressed: () => print("Raised"),
child: Text('Button'),
),
));
}
}
Click to Enlarge