|
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"), |
|
), |
|
); |
|
} |
|
} |