animated_stream_list 0.0.5

Animated Stream List #

Looking for a maintainer, my fling with Flutter has sadly come to an end

pub package

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

// 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), 
  ); 
} 

Getting Started #

1. Add dependency to your pubspec.yaml

dependencies:
  animated_stream_list: ^0.0.4

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; 

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

typedef Widget AnimatedStreamListItemBuilder<T>(
  T item,
  int index,
  BuildContext context,
  Animation<double> 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; 

[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

example/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(
      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: ^0.0.5

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]
78
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
80
Overall:
Weighted score of the above. [more]
85
Learn more about scoring.

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

  • Dart: 2.4.0
  • pana: 0.12.19
  • Flutter: 1.7.8+hotfix.3

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health suggestions

Format lib/src/animated_stream_list.dart.

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

Maintenance issues and suggestions

Support latest dependencies. (-10 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency (meta).

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
meta ^1.1.6 1.1.6 1.1.7
Transitive dependencies
collection 1.14.11
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
benchmark_harness 1.0.5
flutter_test
mockito 4.0.0
quiver >=2.0.0 <3.0.0
test 1.5.3

Admin