FocusButton class
Botón con un gradiente animado en el borde que rota continuamente.
Crea un efecto visual atractivo con un gradiente multicolor que se mueve alrededor del borde del botón. Ideal para CTAs (Call To Action) y elementos que requieren atención visual.
El gradiente utiliza SweepGradient con GradientRotation para crear una animación fluida y continua.
Ejemplo básico:
FocusButton(
child: Text(
'Click me',
style: TextStyle(color: Colors.white),
),
onPressed: () => print('Pressed!'),
)
Ejemplo con personalización completa:
FocusButton(
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 24, vertical: 12),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(Icons.star, color: Colors.white),
SizedBox(width: 8),
Text('Premium', style: TextStyle(color: Colors.white, fontSize: 16)),
],
),
),
onPressed: () => upgradeToPremium(),
gradientColors: [
Colors.cyan,
Colors.blue,
Colors.purple,
Colors.pink,
Colors.cyan,
],
borderWidth: 3.0,
borderRadius: 12.0,
backgroundColor: Colors.black87,
animationDuration: Duration(seconds: 3),
height: 56,
)
Ejemplo con tamaño fijo:
FocusButton(
width: 200,
height: 50,
borderRadius: 25, // Botón circular
child: Text('Botón fijo', style: TextStyle(color: Colors.white)),
onPressed: () {},
)
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- FocusButton
Constructors
-
FocusButton({Key? key, required Widget child, VoidCallback? onPressed, double borderWidth = 2.0, List<
Color> gradientColors = const [Colors.blue, Colors.purple, Colors.pink, Colors.orange, Colors.blue], Duration duration = const Duration(seconds: 2), double borderRadius = 8.0, Color backgroundColor = Colors.black, double? height, double? width}) -
Crea un FocusButton.
const
Properties
- backgroundColor → Color
-
Color de fondo del contenido del botón.
final
- borderRadius → double
-
Radio de las esquinas del botón.
final
- borderWidth → double
-
Ancho del borde del gradiente animado.
final
- child → Widget
-
Widget hijo que se mostrará dentro del botón.
final
- duration → Duration
-
Duración de una rotación completa del gradiente.
final
-
gradientColors
→ List<
Color> -
Colores del gradiente que se animará alrededor del borde.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- height → double?
-
Altura del botón (opcional).
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- onPressed → VoidCallback?
-
Callback cuando se presiona el botón.
Si es null, el botón no será interactivo.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- width → double?
-
Ancho del botón (opcional).
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< FocusButton> -
Creates the mutable state for this widget at a given location in the tree.
override
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of DiagnosticsNode objects describing this node's
children.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited