How to present an empty view in flutter? Ask Question

How to present an empty view in flutter? Ask Question

How to present an empty view in flutter as Widget.build cannot return null to indicate that there is nothing to render.

ベストアンサー1

For anyone like me who was wondering what is "the correct way" to show an empty widget - official Material codebase uses this:

Widget build(BuildContext context) {
  return SizedBox.shrink();
}

SizedBox.shrink() is a widget that is unlike Container or Material has no background or any decorations whatsoever. It sizes itself to the smallest area possible, if not influenced by parent constraints.

おすすめ記事