Skip to content

Instantly share code, notes, and snippets.

Created November 24, 2022 15:16
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
class AppButton extends StatefulWidget {
const AppButton({
required this.text,
required this.styleBundle,
this.isDisabled = false,
final String text;
final AppButtonStyleBundle styleBundle;
final VoidCallback? onTap;
final bool isDisabled;
State<AppButton> createState() => _AppButtonState();
class _AppButtonState extends State<AppButton> {
bool _isPressed = false;
AppButtonStyleBundle get bundle => widget.styleBundle;
final BorderRadius _borderRadius = const BorderRadius.all(
Widget build(BuildContext context) => AnimatedContainer(
height: AppSizes.buttonHeight,
decoration: BoxDecoration(
border: bundle.borderColors != null
? Border.all(
color: bundle.borderColors!.define(
isPressed: _isPressed, isDisabled: widget.isDisabled),
width: 1.5)
: null,
color: bundle.backgroundColors
.define(isPressed: _isPressed, isDisabled: widget.isDisabled),
borderRadius: _borderRadius),
duration: const Duration(milliseconds: 190),
child: InkWell(
onTap: widget.isDisabled ? null : widget.onTap,
onTapDown: (_) => setState(() {
_isPressed = true;
onTapUp: (_) => setState(() {
_isPressed = false;
onTapCancel: () => setState(() {
_isPressed = false;
child: Center(
child: Text(
style: TextStyle(
fontSize: AppFontSizes.extraBig,
color: bundle.textColors.define(
isPressed: _isPressed, isDisabled: widget.isDisabled),
fontWeight: FontWeight.w500),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment