vertical_load_more 0.0.10 copy "vertical_load_more: ^0.0.10" to clipboard
vertical_load_more: ^0.0.10 copied to clipboard

This package can use for load more data and refresh to reset the data. pagination, easy refresh, loading, pulling, pull to refresh, loadmore, scroll, list, infinite scrolling, load more & lazy loading.

example/lib/main.dart

import 'dart:math';

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

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

/// example easy load more
class MyApp extends StatefulWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  late List<Map<String, dynamic>> data;

  Random randomColor = Random();
  VerticalLoadMoreController verticalLoadMoreController =
      VerticalLoadMoreController();
  @override
  void initState() {
    verticalLoadMoreController.hasMore = true;
    setData();
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Vertical Load More Demo',
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: Scaffold(
        body: SafeArea(
          child: VerticalLoadMore(
            child: ListView.builder(
              itemBuilder: (_, index) {
                return Container(
                  margin: const EdgeInsets.all(10),
                  padding: const EdgeInsets.all(16),
                  decoration: BoxDecoration(
                    color: data[index]["color"],
                    borderRadius: BorderRadius.circular(10),
                  ),
                  child: Text(
                    data[index]["value"].toString(),
                    style: Theme.of(context).textTheme.headline3,
                  ),
                );
              },
              itemCount: data.length,
            ),
            onLoadMore: onMoreData,
            onRefresh: onRefresh,
            controller: verticalLoadMoreController,
          ),
        ),
      ),
    );
  }

  Future<void> onMoreData() async {
    await Future.delayed(const Duration(milliseconds: 500), () {
      setState(() {
        verticalLoadMoreController.hasMore = true;
        data.addAll(
          List.generate(
            10,
            (index) => {
              "value": "ស្រុករំដួល",
              "color": Color.fromRGBO(
                randomColor.nextInt(255),
                randomColor.nextInt(255),
                randomColor.nextInt(255),
                0.4,
              ),
            },
          ),
        );
      });
    });
  }

  Future<void> onRefresh() async {
    await Future.delayed(const Duration(milliseconds: 500), () {
      setState(() {
        verticalLoadMoreController.hasMore = true;
        data = List.generate(
          10,
          (index) => {
            "value": "ទីក្រុងគុជ",
            "color": Color.fromRGBO(
              randomColor.nextInt(255),
              randomColor.nextInt(255),
              randomColor.nextInt(255),
              0.4,
            ),
          },
        );
      });
    });
  }

  void setData() {
    data = List.generate(
      10,
      (index) => {
        "value": "ខ្មែរស្រឡាញ់ខ្មែរKSK",
        "color": Color.fromRGBO(
          randomColor.nextInt(255),
          randomColor.nextInt(255),
          randomColor.nextInt(255),
          0.4,
        ),
      },
    );
  }
}
5
likes
145
points
26
downloads

Publisher

verified publishersivhongdeab.com

Weekly Downloads

This package can use for load more data and refresh to reset the data. pagination, easy refresh, loading, pulling, pull to refresh, loadmore, scroll, list, infinite scrolling, load more & lazy loading.

Repository (GitLab)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on vertical_load_more