Skip to content

Instantly share code, notes, and snippets.

@IhwanID
Last active May 6, 2020 18:52
Show Gist options
  • Select an option

  • Save IhwanID/73671a234b01ab82c32a9ba85200cd0c to your computer and use it in GitHub Desktop.

Select an option

Save IhwanID/73671a234b01ab82c32a9ba85200cd0c to your computer and use it in GitHub Desktop.
Rounded Button with FlatButton & RaisedButton in flutter
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: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Button"),
elevation: 0,
),
body: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [Colors.blue, Colors.blueGrey],
begin: Alignment.topCenter,
end: Alignment.bottomCenter)),
child: Center(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
FlatButton(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(15),
side: BorderSide(color: Colors.white)),
color: Colors.green,
onPressed: () {
print("YES terpilih");
},
textColor: Colors.white,
child: Text("YES")),
SizedBox(
width: 10,
),
RaisedButton(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(15),
side: BorderSide(color: Colors.white)),
color: Colors.red,
textColor: Colors.white,
onPressed: () {
print("NO terpilih");
},
child: Text("NO"))
],
),
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment