Skip to content

Instantly share code, notes, and snippets.

@kmvignesh
Created September 20, 2020 13:53
Show Gist options
  • Select an option

  • Save kmvignesh/e4cc5183011efb2b3ba20b09190be161 to your computer and use it in GitHub Desktop.

Select an option

Save kmvignesh/e4cc5183011efb2b3ba20b09190be161 to your computer and use it in GitHub Desktop.
Button types code snippet.
import 'package:flutter/material.dart';
import 'package:flutter_button/gradient_outline_button.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: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Flutter Button'),
),
body: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
SizedBox(
width: 200,
height: 50,
child: RaisedButton(
padding: EdgeInsets.symmetric(vertical: 8, horizontal: 30),
onPressed: () {
print("RaisedButton");
},
color: Colors.blue,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(30))),
child: Text(
"Click Me",
style: TextStyle(color: Colors.white),
),
),
),
SizedBox(
height: 16,
),
FlatButton(
onPressed: () {
print("FlatButton");
},
child: Icon(Icons.add),
color: Colors.amber,
),
SizedBox(
height: 16,
),
OutlineButton(
shape: StadiumBorder(),
onPressed: () {
print("OutlineButton");
},
borderSide: BorderSide(
color: Colors.amber,
style: BorderStyle.solid,
width: 3,
),
child: Text(
"Click Me",
),
),
SizedBox(
height: 16,
),
RaisedButton(
onPressed: () {},
padding: EdgeInsets.zero,
shape: StadiumBorder(),
child: Container(
padding: EdgeInsets.symmetric(vertical: 10, horizontal: 16),
decoration: ShapeDecoration(
gradient: LinearGradient(colors: [Colors.blue, Colors.green]),
shape: StadiumBorder(),
),
child: Text(
"Click Me",
style: TextStyle(color: Colors.white),
),
),
),
SizedBox(
height: 16,
),
GradientOutlineButton(
child: Text("Click Me"),
gradient: LinearGradient(colors: [Colors.blue, Colors.green]),
onPressed: () {},
radius: 16,
)
],
),
),
floatingActionButton: FloatingActionButton.extended(
onPressed: () {},
icon: Icon(Icons.add),
label: Text("Click Me"),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment