builder method

  1. @override
Widget builder(
  1. BuildContext context,
  2. UIWrapperThemeData theme
)
override

Implementation

@override
Widget builder(BuildContext context, UIWrapperThemeData theme) {
  final colorTheme = context.colorTheme;

  return Container(
    margin: margin,
    padding: _padding,
    decoration: switch (state) {
      .decorator => BoxDecoration(
        borderRadius: theme.borderRadius ?? .circular(20),
        color: theme.backgroundColor ?? colorTheme.backgroundSurface1,
        boxShadow: boxShadow,
        image: decorationImage,
      ),
      _ => null,
    },
    child: Builder(
      builder: (context) {
        if (title.isEmpty && actions.isEmpty) {
          return child ?? const SizedBox.shrink();
        }

        return Column(
          crossAxisAlignment: .start,
          spacing: theme.runSpacing ?? 20,
          children: [
            Padding(
              padding: titlePadding,
              child: Row(
                spacing: theme.spacing ?? 8,
                crossAxisAlignment: .center,
                mainAxisAlignment: .spaceBetween,
                children: [
                  if (title.isNotEmpty)
                    Expanded(
                      child: TitleWidget(
                        title,
                        theme: theme.titleTheme,
                      ),
                    ),

                  if (actions.isNotEmpty)
                    Row(
                      mainAxisAlignment: .end,
                      spacing: theme.actionSpacing ?? 8,
                      children: actions,
                    ),
                ],
              ),
            ),
            if (child != null)
              Padding(
                padding: childPadding,
                child: child,
              ),
          ],
        );
      },
    ),
  );
}