UniversalGridView class
Create GridView to provide a consistent UI across web, desktop, and mobile.
UniversalGridView is the UniversalUI version of GridView. It automatically transforms into Sliver widgets when used with UniversalScaffold.
Supports onRefresh for pull-to-refresh, onLoadNext for infinite scrolling, and padding/decoration for styling. Responsive and automatically sets maximum width based on UniversalScaffold.breakpoint.
Basic Usage
UniversalGridView(
padding: const EdgeInsets.all(16),
crossAxisCount: 2,
mainAxisSpacing: 16,
crossAxisSpacing: 16,
onRefresh: () async {
// Handle refresh logic
},
onLoadNext: () async {
// Handle load next logic
},
children: [
// Any widget
],
);
Webとデスクトップ、モバイルで一貫したUIを提供するためのGridViewを作成します。
UniversalGridViewはGridViewのUniversalUI版です。UniversalScaffoldと連携しSliverウィジェットへの自動変換を行います。
onRefreshを設定可能でグリッドの更新を可能にする。onLoadNextを設定可能でグリッドの追加読み込みを可能にする。paddingやdecorationを設定可能でグリッドの外側に余白やボーダーを設定可能。レスポンシブ対応しておりUniversalScaffold.breakpointによって最大の横幅が設定されます。
基本的な利用方法
UniversalGridView(
padding: const EdgeInsets.all(16),
crossAxisCount: 2,
mainAxisSpacing: 16,
crossAxisSpacing: 16,
onRefresh: () async {
// リフレッシュロジックを処理
},
onLoadNext: () async {
// 追加読み込みロジックを処理
},
children: [
// 任意のウィジェット
],
);
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatelessWidget
- UniversalGridView
Constructors
-
UniversalGridView({required List<
Widget> children, Key? key, Decoration? decoration, Axis scrollDirection = Axis.vertical, bool reverse = false, ScrollController? controller, Future<void> onRefresh()?, Future<void> onLoadNext()?, bool canLoadNext = true, bool? primary, ScrollPhysics? physics, ScrollBehavior? scrollBehavior, bool shrinkWrap = false, Key? center, double anchor = 0.0, double? cacheExtent, int? semanticChildCount, DragStartBehavior dragStartBehavior = DragStartBehavior.start, ScrollViewKeyboardDismissBehavior keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.manual, String? restorationId, Clip clipBehavior = Clip.hardEdge, double? maxWidth, EdgeInsetsGeometry? padding, bool? enableResponsivePadding, bool showScrollbarWhenDesktopOrWeb = true, Radius? scrollbarRadius, double? scrollbarThickness, bool displayInvisibleArea = false, double? bottomExtent, double? topExtent, int crossAxisCount = 2, double mainAxisSpacing = 0.0, double crossAxisSpacing = 0.0, double childAspectRatio = 1.0}) -
Create GridView to provide a consistent UI across web, desktop, and mobile.
const
Properties
- anchor → double
-
The relative position of the zero scroll offset.
final
- bottomExtent → double?
-
Specify the space at the bottom.
final
- cacheExtent → double?
-
The viewport has an area before and after the visible area to cache items
that are about to become visible when the user scrolls.
final
- canLoadNext → bool
-
If this is
false, onLoadNext will not be executed.final - center → Key?
-
final
- childAspectRatio → double
-
The ratio of the cross-axis to the main-axis extent of each child.
final
-
children
→ List<
Widget> -
A list of child elements for display in GridView.
final
- clipBehavior → Clip
-
The content will be clipped (or not) according to this option.
final
- controller → ScrollController?
-
An object that can be used to control the position to which this scroll
view is scrolled.
final
- crossAxisCount → int
-
The number of children in the cross axis.
final
- crossAxisSpacing → double
-
The number of logical pixels between each child along the cross axis.
final
- decoration → Decoration?
-
Sets the container background decoration.
final
- displayInvisibleArea → bool
-
Return
trueif invisible areas should also be drawn.final - dragStartBehavior → DragStartBehavior
-
final
- enableResponsivePadding → bool?
-
Specify whether to enable responsive padding.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- keyboardDismissBehavior → ScrollViewKeyboardDismissBehavior
-
The ScrollViewKeyboardDismissBehavior defines how this ScrollView will
dismiss the keyboard automatically.
final
- mainAxisSpacing → double
-
The number of logical pixels between each child along the main axis.
final
- maxWidth → double?
-
Maximum width.
final
-
onLoadNext
→ Future<
void> Function()? -
一番最後の要素が表示されたときに呼ばれるメソッド。
final
-
onRefresh
→ Future<
void> Function()? -
Method called by RefreshIndicator.
final
- padding → EdgeInsetsGeometry?
-
final
- physics → ScrollPhysics?
-
How the scroll view should respond to user input.
final
- primary → bool
-
Whether this is the primary scroll view associated with the parent
PrimaryScrollController.
final
- restorationId → String?
-
Restoration ID to save and restore the scroll offset of the scrollable.
final
- reverse → bool
-
Whether the scroll view scrolls in the reading direction.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- scrollbarRadius → Radius?
-
Scrollbar corner radius.
final
- scrollbarThickness → double?
-
Scrollbar width.
final
- scrollBehavior → ScrollBehavior?
-
final
- scrollDirection → Axis
-
The Axis along which the scroll view's offset increases.
final
- semanticChildCount → int?
-
final
- showScrollbarWhenDesktopOrWeb → bool
-
Setting this to
truewill display scrollbars on desktop and web.final - shrinkWrap → bool
-
Whether the extent of the scroll view in the scrollDirection should be
determined by the contents being viewed.
final
- topExtent → double?
-
Specify the space at the top.
final
Methods
-
build(
BuildContext context) → Widget -
Describes the part of the user interface represented by this widget.
override
-
createElement(
) → StatelessElement -
Creates a StatelessElement to manage this widget's location in the tree.
inherited
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of DiagnosticsNode objects describing this node's
children.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited