Skip to content

Instantly share code, notes, and snippets.

@axross
Created December 6, 2019 03:00
Show Gist options
  • Save axross/872e017691fd0ac950f14d0bfb3fc1d1 to your computer and use it in GitHub Desktop.
Save axross/872e017691fd0ac950f14d0bfb3fc1d1 to your computer and use it in GitHub Desktop.
import 'package:flutter/material.dart';
void main() => runApp(App());
class App extends StatelessWidget {
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData.dark(),
debugShowCheckedModeBanner: false,
home: Scaffold(
body: Center(
child: TinyStadiumButton(
label: "Press Me!",
foregroundColor: Color(0xffffffff),
backgroundColor: Color(0xffee5253),
),
),
),
);
}
}
class TinyStadiumButton extends StatelessWidget {
TinyStadiumButton({
@required this.label,
@required this.foregroundColor,
@required this.backgroundColor,
this.onTap,
Key key,
}) : assert(label != null),
assert(foregroundColor != null),
assert(backgroundColor != null),
super(key: key);
final String label;
final Color foregroundColor;
final Color backgroundColor;
final void Function() onTap;
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: onTap,
child: Container(
decoration: ShapeDecoration(
shape: StadiumBorder(),
color: backgroundColor,
),
padding: EdgeInsets.symmetric(vertical: 6, horizontal: 12),
child: Text(
label,
style: TextStyle(
color: foregroundColor,
fontWeight: FontWeight.w600,
),
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment