defaultBuilder function

List<Widget> defaultBuilder(
  1. BuildContext context,
  2. String? title,
  3. String? subtitle,
  4. String? description,
  5. Color? color,
  6. Color? textColor,
)

Implementation

List<Widget> defaultBuilder(BuildContext context, String? title,
    String? subtitle, String? description, Color? color, Color? textColor) {
  final _color = color != null ? color : Theme.of(context).primaryColor;
  final List<Widget> content = [];

  if (title != null) {
    content.add(Container(
      color: _color,
      child: Padding(
        padding: const EdgeInsets.all(16),
        child: Text(
          title,
          textAlign: TextAlign.center,
          style: Theme.of(context)
              .textTheme
              .labelLarge!
              .copyWith(color: textColor),
        ),
      ),
    ));
  }

  if (subtitle != null || description != null) {
    content.add(Padding(
      padding: const EdgeInsets.only(bottom: 16.0, top: 16),
      child: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        crossAxisAlignment: CrossAxisAlignment.center,
        children: [
          if (subtitle != null)
            Text(
              subtitle,
              textAlign: TextAlign.center,
              style: Theme.of(context)
                  .textTheme
                  .bodyLarge!
                  .copyWith(color: textColor),
            ),
          if (description != null)
            Text(
              description,
              textAlign: TextAlign.center,
              style: Theme.of(context)
                  .textTheme
                  .bodyMedium!
                  .copyWith(color: textColor),
            ),
        ],
      ),
    ));
  }

  return content;
}