๐Ÿ“ฆ smart_views

smart_views is a Flutter package that provides smart wrappers around common Flutter widgets like ListView, GridView, and PageView. It automatically handles empty states (via emptyWidget) and adds optional animations for a smoother user experience.


โœจ Features

  • โœ… SmartListView โ†’ replacement for ListView with empty state handling.
  • โœ… SmartGridView โ†’ replacement for GridView with empty state handling.
  • โœ… SmartPageView โ†’ replacement for PageView with empty state handling.
  • โœ… SmartAnimatedListView โ†’ list view with animated items.
  • โœ… SmartAnimatedGridView โ†’ grid view with animated items.
  • โœ… SmartAnimatedPageView โ†’ page view with page transition animations.

๐Ÿš€ Installation

Add this to your pubspec.yaml:

dependencies:
  smart_views: ^1.0.0

Then run:

flutter pub get

๐Ÿ“– Usage

SmartListView

SmartListView.builder(
  itemCount: items.length,
  emptyWidget: Center(child: Text("No items found")),
  itemBuilder: (context, index) {
    return ListTile(
      title: Text("Item ${items[index]}"),
    );
  },
)

SmartGridView

SmartGridView.count(
  crossAxisCount: 2,
  emptyWidget: Center(child: Text("No items found")),
  children: items.map((e) => Card(child: Center(child: Text(e)))).toList(),
)

SmartPageView

SmartPageView(
  items: ["Page 1", "Page 2", "Page 3"],
  emptyWidget: Center(child: Text("No pages available")),
  itemBuilder: (context, index) => Center(
    child: Text("This is page ${index + 1}"),
  ),
)

SmartAnimatedListView

SmartAnimatedListView(
  items: items,
  emptyWidget: Center(child: Text("Empty list")),
  itemBuilder: (context, index) {
    return ListTile(title: Text("Animated Item $index"));
  },
  animationType: AnimationType.fade, // or slide, scale
)

SmartAnimatedGridView

SmartAnimatedGridView.count(
  crossAxisCount: 2,
  items: items,
  emptyWidget: Center(child: Text("Nothing here")),
  itemBuilder: (context, index) => Card(child: Text("Animated $index")),
  animationType: AnimationType.slide,
)

SmartAnimatedPageView

SmartAnimatedPageView(
  items: items,
  emptyWidget: Center(child: Text("No pages")),
  itemBuilder: (context, index) => Center(child: Text("Page $index")),
  animationType: AnimationType.scale,
)

๐Ÿงช Running Tests

flutter test

Tests cover:

  • Empty state rendering
  • Items rendering
  • Animation behavior

๐Ÿ“Œ Roadmap

  • Add customizable animation durations
  • Add staggered animations
  • Add infinite scroll support

๐Ÿค Contributing

Contributions are welcome! Feel free to open issues and PRs on GitHub.


๐Ÿ“„ License

MIT License ยฉ 2025


Libraries

smart_views