Skip to content

Instantly share code, notes, and snippets.

@josue1dario2
Created November 13, 2022 20:01
Show Gist options
  • Save josue1dario2/3806a42621cbc17ce5e85f22b453c4b7 to your computer and use it in GitHub Desktop.
Save josue1dario2/3806a42621cbc17ce5e85f22b453c4b7 to your computer and use it in GitHub Desktop.
Custom button Flutter
class CustomButton extends StatelessWidget {
final String textButton;
final Icon iconButton;
final String navigator;
const CustomButton(
{Key? key,
required this.textButton,
required this.iconButton,
required this.navigator})
: super(key: key);
@override
Widget build(BuildContext context) {
Size size = MediaQuery.of(context).size;
TextStyle styleText = const TextStyle(
color: Color(0XFFFFFFFF),
fontSize: 22,
fontWeight: FontWeight.w500,
letterSpacing: 1.6);
BoxDecoration containerDecoration =
const BoxDecoration(color: Color(0xFF212121), boxShadow: [
BoxShadow(color: Colors.grey, offset: Offset(0.0, 15.0), blurRadius: 20.0)
]);
return MaterialButton(
onPressed: () {
Navigator.pushNamed(context, navigator);
},
child: Container(
height: size.height * 0.07,
width: size.width * 0.4,
decoration: containerDecoration,
child: Center(
child: Row(
children: [
SizedBox(
width: size.width * 0.03,
),
iconButton,
SizedBox(
width: size.width * 0.03,
),
FittedBox(
fit: BoxFit.contain,
child: Text(
textButton,
style: styleText,
),
),
],
),
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment