Generation

generate functionThu, 06 Apr 2023

este es mi codigo, quiero que me des denuevo el codigo completo pero quiero que el boton primario cuando el boton se active cambie al color blue[300], cuando el secondary se active el color del texto sea blue[300] y el color del boton blue[50] y el color del borde del boton un blue[300], cuando el boton link se le de click, el fondo sea blue[50] y el color del texto blue[300] import 'package:flutter/material.dart'; import '../assets/colors.dart'; enum Type { primary, secondary, link } enum Size { normal, big } enum Position { left, right, center, none } class Button extends StatelessWidget { final String label; final IconData iconName; final Position iconPosition; final String route; final Type type; final Size size; final bool isDisabled; final Function func; const Button({ this.label = '', this.iconName = Icons.wifi, this.iconPosition = Position.none, this.route = '', this.type = Type.primary, this.size = Size.normal, required this.isDisabled, required this.func, }); @override Widget build(BuildContext context) { var button; switch (type) { case Type.primary: button = ElevatedButton( style: ElevatedButton.styleFrom( backgroundColor: Colors.black, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(5), ), padding: EdgeInsets.symmetric( horizontal: size == Size.normal ? 10 : 20, vertical: size == Size.normal ? 5 : 10, ), ), onPressed: () { func(); if (route != '') Navigator.pushNamed(context, route); }, child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ if (iconPosition == Position.left) Icon(iconName), if (iconPosition == Position.left) SizedBox(width: 5), if (iconPosition == Position.center && label != '') Icon(iconName), if (iconPosition != Position.center) Text(label, style: TextStyle(color: Colors.white)), if (iconPosition == Position.right) SizedBox(width: 5), if (iconPosition == Position.right) Icon(iconName), ], ), ); break; case Type.secondary: button = ElevatedButton( style: ElevatedButton.styleFrom( backgroundColor: Colors.white, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(5), side: BorderSide(color: Colors.black), ), padding: EdgeInsets.symmetric( horizontal: size == Size.normal ? 10 : 20, vertical: size == Size.normal ? 5 : 10, ), ), onPressed: () { func(); if (route != '') Navigator.pushNamed(context, route); }, child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ if (iconPosition == Position.left) Icon(iconName, color: Colors.black), if (iconPosition == Position.left) SizedBox(width: 5), if (iconPosition == Position.center && label != '') Icon(iconName, color: Colors.black), if (iconPosition != Position.center) Text(label, style: TextStyle(color: Colors.black)), if (iconPosition == Position.right) SizedBox(width: 5), if (iconPosition == Position.right) Icon(iconName, color: Colors.black), ], ), ); break; case Type.link: button = TextButton( onPressed: () { func(); if (route != '') Navigator.pushNamed(context, route); }, child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ if (iconPosition == Position.left) Icon(iconName, color: Colors.black), if (iconPosition == Position.left) SizedBox(width: 5), if (iconPosition == Position.center && label != '') Icon(iconName, color: Colors.black), if (iconPosition != Position.center) Text(label, style: TextStyle(color: Colors.black)), if (iconPosition == Position.right) SizedBox(width: 5), if (iconPosition == Position.right) Icon(iconName, color: Colors.black), ], ), ); break; } return button; } }

## Acceptance Criteria

Questions about programming?Chat with your personal AI assistant