listview_empty_builder 1.0.0 copy "listview_empty_builder: ^1.0.0" to clipboard
listview_empty_builder: ^1.0.0 copied to clipboard

A Flutter extension that adds an empty state builder to ListView.

ListView Empty Builder Extension #

A simple Flutter extension that allows you to display a custom widget when a ListView is empty, directly on the ListView widget.

Screenshots #

Example Output #

Screenshot 1 Screenshot 2

Installation #

Add the package to your pubspec.yaml:

dependencies:
  listview_empty_builder: latest_version

Then run:

flutter pub get

Usage #

Import the package:

import 'package:listview_empty_builder/listview_empty_builder.dart';

Use the .emptyBuilder extension on a ListView to define a widget that will be displayed when the list is empty:

import 'package:flutter/material.dart';
import 'package:listview_empty_builder/listview_empty_builder.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: Text("ListView Empty Builder Example")),
        body: ListView(
          children: [], // Empty list
        ).emptyBuilder(
          builder: () => Center(child: Text("No items available")),
        ),
      ),
    );
  }
}

Features #

✅ Easily handle empty list states inside ListView. ✅ No need for additional conditional checks in your widgets. ✅ Works seamlessly with ListView.builder and ListView(children: []).

License #

This package is licensed under the MIT License. See the LICENSE file for details.

5
likes
150
points
19
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter extension that adds an empty state builder to ListView.

Repository (GitHub)

Topics

#listview #flutter #extension #empty-state

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on listview_empty_builder