Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


📦 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


About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages