Code Monkey home page Code Monkey logo

pluto_filtered_list's Introduction

PlutoFilteredList - v0.2.0

codecov


A List where filters can be applied to the List and elements can be accessed or modified in that state.


Check out how to install from the official distribution site.


Report any questions or errors.


Todo

  • Not implemented yet.
    • removeRange, fillRange, replaceRange.

Done

var list = FilteredList(initialList: [1, 2, 3, 4, 5]);
  • insert : If the filter is applied, the index at which the element is added is adjusted.
    list.setFilter((e) => e > 3); // [4, 5]
    list.insert(0, 35); // [35, 4, 5]
    
    list.setFilter(null); // [1, 2, 3, 35, 4, 5]
    list.insert(0, -1); // [-1, 1, 2, 3, 35, 4, 5]
  • removeAt : If the filter is applied, the index at which the element is removed is adjusted.
    list.setFilter((e) => e > 3); // [4, 5]
    list.removeAt(0); // [5]
    
    list.setFilter(null); // [1, 2, 3, 5]
    list.removeAt(0); // [2, 3, 5]
  • insertAll : If the filter is applied, the index at which the element is added is adjusted.
    list.setFilter((e) => e > 3); // [4, 5]
    list.insertAll(0, [35, 36, 37]); // [35, 36, 37, 4, 5]
    
    list.setFilter(null); // [1, 2, 3, 35, 36, 37, 4, 5]
    list.insertAll(0, [-1, -2, -3]); // [-1, -2, -3, 1, 2, 3, 35, 36, 37, 4, 5]
  • remove : If the filter has been applied, the element is removed from the range where the filter is applied.
    list.setFilter((e) => e > 3); // [4, 5]
    var removedThree = list.remove(3); // false
    var removedFour = list.remove(4); // true
    
    list.setFilter(null); // [1, 2, 3, 5]
    var removedThreeAgain = list.remove(3); // true
  • removeFromOriginal : Removes elements across the entire scope regardless of filter application.
    list.setFilter((e) => e > 3); // [4, 5]
    var removedThree = list.removeFromOriginal(3); // true
    var removedFour = list.removeFromOriginal(4); // true
    
    list.setFilter(null); // [1, 2, 5]
    var removedThreeAgain = list.removeFromOriginal(3); // false
  • removeWhere : If the filter has been applied, the element is removed from the range where the filter is applied.
  • removeWhereFromOriginal : Removes elements across the entire scope regardless of filter application.
  • retainWhere : If the filter has been applied, the element is retained from the range where the filter is applied.
  • retainWhereFromOriginal : Retains elements across the entire scope regardless of filter application.
  • clear : If the filter has been applied, the element is cleared from the range where the filter is applied.
  • clearFromOriginal : Clears elements across the entire scope.
  • removeLast : The last element is deleted while the filter is applied.
  • removeLastFromOriginal : Delete the last element from the entire list.
  • shuffle : Shuffles elements across the entire scope.

Example

/// Create an empty list.
var filteredList = FilteredList<String>();

/// Contains the methods of List.
/// add, remove, clear, where, ...
filteredList.add('one');

print(filteredList); // ['one']

filteredList.addAll(['two', 'three', 'four', 'five']);

print(filteredList); // ['one', 'two', 'three', 'four', 'five']

/// Set the filter.
/// Implement a callback function that returns a bool type.
/// The example filters a string of length 4, as shown below.
filteredList.setFilter((element) => element.length == 4); // ['four', 'five']

/// Only elements of length 4 in the list were filtered out,
/// resulting in the length of the list being 2.
print(filteredList.length); // 2

print(filteredList[0]); // 'four'

print(filteredList[1]); // 'five'

/// You can turn off the filter by passing null to setFilter.
filteredList.setFilter(null); // ['one', 'two', 'three', 'four', 'five']

/// The filter is cleared, so the length of the original list is 5.
print(filteredList.length); // 5

print(filteredList[0]); // 'one'

print(filteredList[1]); // 'two'

Pluto series

develop packages that make it easy to develop admin pages or CMS with Flutter.

pluto_filtered_list's People

Contributors

bosskmk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

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.