Giter Site home page Giter Site logo

wu9007 / dynamic_list_view Goto Github PK

View Code? Open in Web Editor NEW
17.0 1.0 4.0 72 KB

A list component that refreshes and adds more data for Flutter.

License: MIT License

Java 6.92% Objective-C 8.54% Dart 80.58% Ruby 3.96%
flutter-components flutter-plugin flutter-package flutter-widget flutter-listview

dynamic_list_view's Introduction

Language: English | 中文简体

Dynamic List View

License Pub

A list component that can refreshes and adds more data for Flutter App. 🚀

github

Dynamic List View

Installation

Add this to your package's pubspec.yaml file:

dependencies:
 dynamic_list_view: ^0.2.1

Usage example

import 'package:dynamic_list_view/dynamic_list.dart';
import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  DynamicListController _dynamicListController = DynamicListController();

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          backgroundColor: Colors.grey[200],
          leading: Icon(Icons.accessibility, color: Colors.cyan),
          title: Text('Dynamic list', style: TextStyle(color: Colors.black)),
        ),
        body: Container(
          child: DynamicList.build(
            controller: _dynamicListController,
            itemBuilder: _itemBuilder,
            dataRequester: _dataRequester,
            initRequester: _initRequester,
          ),
        ),
        persistentFooterButtons: <Widget>[
          MaterialButton(
              onPressed: () => this._dynamicListController.fireRefresh(),
              child: Icon(Icons.refresh)),
          MaterialButton(
              onPressed: () => this._dynamicListController.toTop(),
              child: Icon(Icons.vertical_align_top))
        ],
      ),
    );
  }

  Future<List> _initRequester() async {
    return Future.value(List.generate(15, (i) => i));
  }

  Future<List> _dataRequester() async {
    return Future.delayed(Duration(seconds: 2), () {
      return List.generate(10, (i) => 15 + i);
    });
  }

  final Function _itemBuilder =
      (List dataList, BuildContext context, int index) {
    String title = dataList[index].toString();
    return ListTile(title: Text("Number $title"));
  };
}

Contribute

We would ❤️ to see your contribution!

License

Distributed under the MIT license. See LICENSE for more information.

About

Created by Shusheng.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.