build method
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 note = ref.model(NoteModel.document(viewId))..load();
final adapter =
MasamuneAdapterScope.of<SimpleBlogModuleMasamuneAdapter>(context);
ref.page.on(initOrUpdate: () async {
final read = appPrefs.read.get();
await note.loading;
if (!read.contains(note.uid)) {
appPrefs.read.set([...read, note.uid]);
}
});
// Describes the structure of the page.
return UniversalScaffold(
appBar: const UniversalAppBar(),
body: UniversalListView(
onRefresh: () {
return note.reload();
},
children: [
ListTile(
title: Text(note.value?.title ?? ""),
subtitle: Text(note.value?.time.value.yyyyMMddHHmm() ?? ""),
),
const Divider(),
ConstrainedBox(
constraints: const BoxConstraints(minHeight: 420),
child: Padding(
padding: 16.p,
child: SelectableAutoLinkText(
note.value?.text ?? "",
style: adapter?.theme?.text.bodyLarge ??
Theme.of(context).textTheme.bodyLarge,
linkStyle: const TextStyle(color: Colors.blue),
onTap: (link) {
openURL(link);
},
),
),
),
...note.value?.images.map(
(e) {
return Padding(
padding: 16.p,
child: InkWell(
onTap: () {
adapter!.router.push(
ViewPage.query(imageUrl: e),
TransitionQuery.fadeModal,
);
},
child: ClipRRect(
borderRadius: BorderRadius.circular(8.0),
child: Image(
image: Asset.image(e),
fit: BoxFit.fitWidth,
),
),
),
);
},
) ??
[],
],
),
);
}