components/buttons/flutstrap_button library Components
Flutstrap Button
A versatile button component with Bootstrap-inspired variants, sizes, and states.
Performance
Button styles are automatically cached based on variant, size, and theme brightness for optimal performance. Multiple buttons with the same configuration will reuse the same computed styles.
Accessibility
- Uses
Semanticswidget for screen readers - Provides proper semantic labels for text and loading states
- Follows Material Design accessibility guidelines
Best Practices
- Use
copyWith()for state modifications to benefit from style caching - Prefer
textproperty overchildfor simple text buttons - Use
loadingstate to provide feedback for async operations - Consider using convenience methods for common variant changes
Usage Examples
// Basic button
FlutstrapButton(
onPressed: () {},
text: 'Primary Button',
variant: FSButtonVariant.primary,
)
// With icon and loading state
FlutstrapButton(
onPressed: _submitForm,
text: 'Submit',
variant: FSButtonVariant.success,
leading: Icon(Icons.check),
loading: _isSubmitting,
expanded: true,
)
// Using copyWith for state modifications
FlutstrapButton(
onPressed: () {},
text: 'Button',
).copyWith(variant: FSButtonVariant.danger)
// Disabled outline button
FlutstrapButton(
onPressed: null,
text: 'Disabled',
variant: FSButtonVariant.outlinePrimary,
)
// Using const constructor for common cases
const FlutstrapButton.primary(
onPressed: _handlePress,
text: 'Primary Button',
)
Performance
Button styles are automatically cached based on variant, size, and theme brightness for optimal performance. Multiple buttons with the same configuration will reuse the same computed styles.
Accessibility
- Uses
Semanticswidget for screen readers - Provides proper semantic labels for text and loading states
- Follows Material Design accessibility guidelines
Best Practices
- Use
copyWith()for state modifications to benefit from style caching - Prefer
textproperty overchildfor simple text buttons - Use
loadingstate to provide feedback for async operations - Consider using convenience methods for common variant changes
Classes
- FlutstrapButton
- Flutstrap Button Component
Enums
- FSButtonSize
- Flutstrap Button Sizes
- FSButtonVariant
- Flutstrap Button Variants