animated_stream_list 1.1.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 91

Animated Stream List #

pub package Build Status

A Flutter library to easily display a list with animated changes from a Stream<List<E>>.
It's like StreamBuilder + ListView.Builder with animations.
Taken inspiration from the Animated List Sample and Java-diff-utils

Getting Started #

1. Add dependency to your pubspec.yaml

dependencies:
  animated_stream_list: ^1.1.0

2. Import it

import 'package:animated_stream_list/animated_stream_list.dart';

3. Use it. See the examples folder for an ... example.

Parameters #

@required Stream<List<E>> streamList;
@required AnimatedStreamListItemBuilder<E> itemBuilder; 
@required AnimatedStreamListItemBuilder<E> itemRemovedBuilder; 
Duration duration;

AnimatedStreamListItemBuilder<T> is just a function which builds a tile

typedef Widget AnimatedStreamListItemBuilder<T>(
  T item,
  int index,
  BuildContext context,
  Animation<double> animation,
); 

Example #

// create tile view as the user is going to see it, attach any onClick callbacks etc. 
Widget _createTile(String item, Animation<double> animation) {    
 return SizeTransition(      
    axis: Axis.vertical,      
    sizeFactor: animation,      
    child: const Text(item),    
  ); 
}

// what is going to be shown as the tile is being removed, usually same as above but without any 
// onClick callbacks as, most likely, you don't want the user to interact with a removed view 
Widget _createRemovedTile(String item, Animation<double> animation) {    
 return SizeTransition(      
    axis: Axis.vertical,      
    sizeFactor: animation,      
    child: const Text(item),    
  ); 
}

final Stream<List<String>> list = // get list from some source, like BLOC  
final animatedView = AnimatedStreamList<String>(      
  streamList: list,      
  itemBuilder: (String item, int index, BuildContext context, Animation<double> animation) =>      
    _createTile(item, animation),      
  itemRemovedBuilder: (String item, int index, BuildContext context, Animation<double> animation) =>  
    _createRemovedTile(item, animation), 
  ); 
} 

Options #

List<E> initialList;

Initial list

Equalizer equals; 

Compares items for equality, by default it uses the == operator, it's critical this works properly.

Equalizer is function, that, given two items of the same type, returns true if they are equal, false otherwise

typedef bool Equalizer(dynamic item1, dynamic item2); 

You can check the Animated List Documentation for the rest:

Axis scrollDirection;
bool reverse;
ScrollController scrollController;
bool primary;
ScrollPhysics scrollPhysics;
bool shrinkWrap;
EdgeInsetsGeometry padding;

Credits #

This amazing package was originally created by Dawid Bota over here. I have taken over the development with his blessing and all tracking will be done on this repo moving forward.

[0.0.1] - 07.03.2019. #

  • initial release.

[0.0.3] - 10.03.2019 #

  • expose index in the item builder function
  • make deleting items instant when change is needed

[0.0.4] - 11.03.2019 #

  • changes are done without animations
  • write test cases

[0.0.5] - 05.06.2019 #

  • allow setting initial list
  • fix memory leak

1.0.0 #

  • Exposed duration parameter to enable customisation
  • Cleaned up dependencies
  • Added a full example

1.1.0 #

  • Merged fix by @den163 for crashing caused by rapid addition/deletion of items

example/lib/main.dart

import 'package:flutter/material.dart';

import 'home_page.dart';

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      title: 'Animated Stream List example',
      home: HomePage(),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  animated_stream_list: ^1.1.0

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:animated_stream_list/animated_stream_list.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
82
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
91
Learn more about scoring.

We analyzed this package on Jul 7, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.13
  • Flutter: 1.17.5

Analysis suggestions

Package not compatible with SDK dart

because of import path [animated_stream_list] that is in a package requiring null.

Health suggestions

Format lib/src/animated_stream_list.dart.

Run flutter format to format lib/src/animated_stream_list.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
flutter_test 0.0.0
meta ^1.1.6 1.1.8 1.2.1
Transitive dependencies
archive 2.0.13
args 1.6.0
async 2.4.1 2.4.2
boolean_selector 2.0.0
charcode 1.1.3
collection 1.14.12 1.14.13
convert 2.1.1
crypto 2.1.4 2.1.5
image 2.1.12 2.1.14
matcher 0.12.6 0.12.8
path 1.6.4 1.7.0
petitparser 2.4.0 3.0.4
sky_engine 0.0.99
source_span 1.7.0
stack_trace 1.9.3 1.9.5
stream_channel 2.0.0
string_scanner 1.0.5
term_glyph 1.1.0
test_api 0.2.15 0.2.17
typed_data 1.1.6 1.2.0
vector_math 2.0.8
xml 3.6.1 4.2.0
Dev dependencies
benchmark_harness ^1.0.5
mockito ^4.1.1
quiver >=2.0.0 <3.0.0 2.1.3