NyListView<T> class
The NyListView widget is a wrapper for the ListView widget. It provides a simple way to display a list of items with full type safety.
Basic Example (backwards compatible):
NyListView<String>(
data: () => ['Item 1', 'Item 2', 'Item 3'],
child: (context, data) => Text(data), // data is dynamic (backwards compatible)
)
Type-safe Examples:
NyListView<String>(
data: () => ['Item 1', 'Item 2', 'Item 3'],
childTyped: (context, String data) => Text(data), // data is String (type-safe)
)
NyListView<String>(
data: () => ['Item 1', 'Item 2', 'Item 3'],
childTypedWithIndex: (context, String data, int index) => Text('$data at $index'),
)
NyListView<String>(
data: () => ['Item 1', 'Item 2', 'Item 3'],
childTypedWithHelper: (context, String data, int index, NyListViewItemHelper helper) {
return Container(
color: helper.isEven() ? Colors.grey : Colors.white,
child: Text(data),
);
},
)
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- NyListView
- Available extensions
Constructors
-
NyListView.new({Key? key, Function? child, NyChildBuilder<
T> ? childTyped, NyChildBuilderWithIndex<T> ? childTypedWithIndex, NyChildBuilderWithHelper<T> ? childTypedWithHelper, required dynamic data(), dynamic transform(List<T> data)?, Widget? empty, LoadingStyle? loadingStyle, String? stateName, Axis? scrollDirection, bool? reverse, ScrollController? controller, bool? primary, ScrollPhysics? physics, bool? shrinkWrap, EdgeInsets? padding, double? itemExtent, Widget? prototypeItem, ChildIndexGetter? findChildIndexCallback, bool addAutomaticKeepAlives = true, bool addRepaintBoundaries = true, bool addSemanticIndexes = true, double? cacheExtent, int? semanticChildCount, DragStartBehavior? dragStartBehavior, ScrollViewKeyboardDismissBehavior? keyboardDismissBehavior, String? restorationId, Clip? clipBehavior, Widget? header, dynamic sort(List<T> items)?}) -
const
-
NyListView.grid({Key? key, int? crossAxisCount = 2, double? mainAxisSpacing = 1.0, double? crossAxisSpacing = 1.0, Function? child, NyChildBuilder<
T> ? childTyped, NyChildBuilderWithIndex<T> ? childTypedWithIndex, NyChildBuilderWithHelper<T> ? childTypedWithHelper, required dynamic data(), dynamic transform(List<T> data)?, Widget? empty, LoadingStyle? loadingStyle, String? stateName, Axis? scrollDirection, bool? reverse, ScrollController? controller, bool? primary, ScrollPhysics? physics, bool? shrinkWrap, EdgeInsets? padding, double? itemExtent, Widget? prototypeItem, ChildIndexGetter? findChildIndexCallback, bool addAutomaticKeepAlives = true, bool addRepaintBoundaries = true, bool addSemanticIndexes = true, double? cacheExtent, int? semanticChildCount, DragStartBehavior? dragStartBehavior, ScrollViewKeyboardDismissBehavior? keyboardDismissBehavior, String? restorationId, Clip? clipBehavior, Widget? header, dynamic sort(List<T> items)?}) -
const
-
NyListView.separated({Key? key, required dynamic data(), dynamic transform(List<
T> data)?, Function? child, NyChildBuilder<T> ? childTyped, NyChildBuilderWithIndex<T> ? childTypedWithIndex, NyChildBuilderWithHelper<T> ? childTypedWithHelper, required IndexedWidgetBuilder? separatorBuilder, Widget? empty, LoadingStyle? loadingStyle, String? stateName, Axis? scrollDirection, bool? reverse, ScrollController? controller, bool? primary, ScrollPhysics? physics, bool? shrinkWrap, EdgeInsets? padding, double? itemExtent, Widget? prototypeItem, ChildIndexGetter? findChildIndexCallback, bool addAutomaticKeepAlives = true, bool addRepaintBoundaries = true, bool addSemanticIndexes = true, double? cacheExtent, int? semanticChildCount, DragStartBehavior? dragStartBehavior, ScrollViewKeyboardDismissBehavior? keyboardDismissBehavior, String? restorationId, Clip? clipBehavior, Widget? header, dynamic sort(List<T> items)?}) -
const
Properties
- addAutomaticKeepAlives → bool
-
final
- addRepaintBoundaries → bool
-
final
- addSemanticIndexes → bool
-
final
- cacheExtent → double?
-
final
- child → Function?
-
final
-
childTyped
→ NyChildBuilder<
T> ? -
final
-
childTypedWithHelper
→ NyChildBuilderWithHelper<
T> ? -
final
-
childTypedWithIndex
→ NyChildBuilderWithIndex<
T> ? -
final
- clipBehavior → Clip?
-
final
- controller → ScrollController?
-
final
- crossAxisCount → int?
-
final
- crossAxisSpacing → double?
-
final
- data → dynamic Function()
-
final
- dragStartBehavior → DragStartBehavior?
-
final
- empty → Widget?
-
final
- findChildIndexCallback → ChildIndexGetter?
-
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- header → Widget?
-
final
- itemExtent → double?
-
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- keyboardDismissBehavior → ScrollViewKeyboardDismissBehavior?
-
final
- kind → String
-
final
- loadingStyle → LoadingStyle?
-
final
- mainAxisSpacing → double?
-
final
- padding → EdgeInsets?
-
final
- physics → ScrollPhysics?
-
final
- primary → bool?
-
final
- prototypeItem → Widget?
-
final
- restorationId → String?
-
final
- reverse → bool?
-
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- scrollDirection → Axis?
-
final
- semanticChildCount → int?
-
final
- separatorBuilder → IndexedWidgetBuilder?
-
final
- shrinkWrap → bool?
-
final
-
sort
→ dynamic Function(List<
T> items)? -
final
- stateName → String?
-
final
-
transform
→ dynamic Function(List<
T> data)? -
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< StatefulWidget> -
Creates the mutable state for this widget at a given location in the tree.
override
-
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
-
faderBottom(
int strength, {Color color = Colors.black}) → NyFader -
Available on StatefulWidget, provided by the NyStateful extension
Make gradient fader from the bottom of the widget. -
faderFrom(
int strength, {Color color = Colors.black, List< AlignmentGeometry> alignment = const [Alignment.topCenter, Alignment.bottomCenter]}) → NyFader -
Available on StatefulWidget, provided by the NyStateful extension
fader from bottom -
faderLeft(
int strength, {Color color = Colors.black}) → NyFader -
Available on StatefulWidget, provided by the NyStateful extension
Make gradient fader from the left of the widget. -
faderRight(
int strength, {Color color = Colors.black}) → NyFader -
Available on StatefulWidget, provided by the NyStateful extension
Make gradient fader from the right of the widget. -
faderTop(
int strength, {Color color = Colors.black}) → NyFader -
Available on StatefulWidget, provided by the NyStateful extension
Make gradient fader from the top of the widget. -
flexible(
{Key? key, int flex = 1, FlexFit fit = FlexFit.loose}) → Flexible -
Available on StatefulWidget, provided by the NyStateful extension
Make a StatefulWidget Flexible. Example: -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
pullable(
{required Future< void> onRefresh()?, PullableConfig? pullableConfig}) → Widget -
Available on Widget, provided by the NyWidget extension
Make a widget pullable using the Pullable widget. -
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toSkeleton(
{Key? key, bool? ignoreContainers, bool? justifyMultiLineText, Color? containersColor, bool ignorePointers = true, bool enabled = true, PaintingEffect? effect, TextBoneBorderRadius? textBoneBorderRadius}) → Skeletonizer -
Available on Widget, provided by the NyWidget extension
Make a widget a skeleton using theSkeletonizer
package. -
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
Static Methods
-
stateReset(
String stateName) → dynamic - Resets the state