build method

  1. @override
Widget build(
  1. BuildContext context
)
override

Describes the part of the UI represented by this widget.

Implementation

@override
Widget build(BuildContext context) {
  final theme = ThemeScope.of(context);
  final sbTheme = theme.statusBarTheme;

  final bg = background ?? sbTheme?.background ?? theme.surface;
  final fg = foreground ?? sbTheme?.foreground ?? theme.onSurface;
  final sep = separator ?? sbTheme?.separator;
  final fgStyle = _copyStyle(theme.bodySmall)..foreground(fg);

  final children = <Widget>[];

  if (leading != null) {
    children.add(leading!);
  }

  for (var i = 0; i < items.length; i++) {
    children.add(items[i]);
    if (sep != null && i < items.length - 1) {
      children.add(Text(sep, style: fgStyle));
    }
  }

  if (trailing != null) {
    if (children.isNotEmpty) children.add(Spacer());
    children.add(trailing!);
  }

  return Container(
    padding:
        padding ?? const EdgeInsets.symmetric(horizontal: 1, vertical: 0),
    color: bg,
    child: Row(gap: sep != null ? 0 : gap, children: children),
  );
}