build method

  1. @override
Widget build(
  1. BuildContext context,
  2. PageRef ref
)
override

Build the internal widget.

The context used during the build is passed as is.

Also, WidgetRef is passed to ref to update the state.

内部のウィジェットをビルドします。

ビルド中に使用されるcontextがそのまま渡されます。

また、refに状態を更新するためのPageRefが渡されます。

Implementation

@override
Widget build(BuildContext context, PageRef ref) {
  // Describes the process of loading
  // and defining variables required for the page.
  final adapter = MasamuneModuleSimpleblogMasamuneAdapter.primary;
  final user = UserModel.document(userId).watch(ref)..load();

  // Describes the structure of the page.
  return UniversalScaffold(
    appBar: UniversalAvatarSliverAppBar(
      leadingWhenDisabledPop: CloseButton(
        onPressed: () {
          adapter.page.index().push(adapter.router);
        },
      ),
      backgroundColor: adapter.theme.color.primary,
      foregroundColor: adapter.theme.color.onPrimary,
      expandedForegroundColor: adapter.theme.color.onPrimary,
      avatarIcon: user.value?.image != null
          ? Image(
              image: user.value!.image!.toImageProvider(),
              fit: BoxFit.cover,
            )
          : ColoredBox(
              color: adapter.theme.color.disabled,
            ),
    ),
    body: UniversalListView(
      children: [
        16.sy,
        Indent(
          padding: 16.px,
          children: [
            Text(
              user.value?.name ?? "",
              style: adapter.theme.text.displaySmall.withBold(),
            ),
          ],
        ),
        32.sy,
      ],
    ),
  );
}