buttonStub function

String buttonStub(
  1. ReCase rc
)

This stub is used to create a Button Widget in the /resources/widgets/buttons/partials/ directory.

Implementation

String buttonStub(ReCase rc) => '''
import 'package:flutter/material.dart';
import '/resources/widgets/buttons/abstract/app_button.dart';

class ${rc.pascalCase}Button extends StatefulAppButton {
  final Color? backgroundColor;
  final Color? contentColor;

  ${rc.pascalCase}Button({
    super.key,
    required super.text,
    super.onPressed,
    super.submitForm,
    super.onFailure,
    super.showToastError = true,
    super.loadingStyle,
    super.width,
    super.height,
    super.animationStyle,
    super.splashStyle,
    this.backgroundColor,
    this.contentColor,
  });

  @override
  Widget buildButton(BuildContext context) {
    final theme = Theme.of(context);

    final bgColor = backgroundColor ?? theme.colorScheme.primary;
    final fgColor = contentColor ?? theme.colorScheme.onPrimary;
    final radius = BorderRadius.circular(14);

    return Container(
      width: width ?? double.infinity,
      height: height,
      decoration: BoxDecoration(
        color: bgColor,
        borderRadius: radius,
      ),
      child: Center(
        child: Text(
          text,
          style: TextStyle(
            color: fgColor,
            fontSize: 16,
            fontWeight: FontWeight.w600,
            letterSpacing: 0.3,
          ),
        ),
      ),
    );
  }
}
''';