Skip to content
Snippets Groups Projects
Select Git revision
  • 8f23c0a3548d0799185527a6965bc4c8b98c98b9
  • master default protected
  • 21-add-onlongpress-with-popup-on-parameters
  • 23-center-vertically-buttons
  • 30-highlight-bin-when-selecting-disabled-item
  • 1.0.7 protected
  • 1.0.6 protected
  • 1.0.5 protected
  • 1.0.4 protected
  • 1.0.3 protected
  • 1.0.2 protected
  • 1.0.0 protected
  • 0.9.1 protected
  • 0.9.0 protected
  • 0.8.4 protected
  • 0.8.3 protected
  • 0.8.2 protected
  • 0.8.1 protected
  • 0.8.0 protected
  • 0.7.0 protected
  • 0.6.1 protected
  • 0.6.0 protected
  • 0.5.0 protected
  • 0.4.0 protected
  • 0.3.0 protected
25 results

button_start_new_activity.dart

Blame
  • styled_button.dart 5.18 KiB
    import 'package:flutter/material.dart';
    
    import 'package:auto_size_text/auto_size_text.dart';
    
    import 'package:flutter_custom_toolbox/utils/color_extensions.dart';
    
    class StyledButton extends StatelessWidget {
      const StyledButton({
        super.key,
        required this.color,
        required this.onPressed,
        this.onLongPress,
        required this.child,
      });
    
      final Color color;
      final VoidCallback? onPressed;
      final VoidCallback? onLongPress;
      final Widget child;
    
      factory StyledButton.text({
        Key? key,
        required VoidCallback? onPressed,
        VoidCallback? onLongPress,
        required String caption,
        required Color color,
      }) {
        final Widget captionWidget = AutoSizeText(
          caption,
          maxLines: 1,
          style: TextStyle(
            inherit: true,
            fontWeight: FontWeight.w900,
            color: color.darken(60),
            shadows: [
              Shadow(
                blurRadius: 5.0,
                color: color.lighten(60),
                offset: const Offset(2, 2),
              ),
              Shadow(
                blurRadius: 5.0,
                color: color.lighten(60),
                offset: const Offset(2, -2),
              ),
              Shadow(
                blurRadius: 5.0,
                color: color.lighten(60),
                offset: const Offset(-2, 2),
              ),
              Shadow(
                blurRadius: 5.0,
                color: color.lighten(60),
                offset: const Offset(-2, -2),
              ),
            ],
          ),
        );
    
        return StyledButton(
          color: color,
          onPressed: onPressed,
          onLongPress: onLongPress,
          child: captionWidget,
        );
      }
    
      factory StyledButton.icon({
        Key? key,
        required VoidCallback? onPressed,