animated_stream_list 0.0.2 copy "animated_stream_list: ^0.0.2" to clipboard
animated_stream_list: ^0.0.2 copied to clipboard

outdated

A Flutter library to easily display a list with animated changes from a Stream<List<E>>. It's like StreamBuilder + ListView.Builder with animations.

Animated Stream List #

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 s, Animation<double> animation) {
  return SizeTransition(  
    axis: Axis.vertical,  
    sizeFactor: animation,  
    child: const Text(s),
  );
}

// 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 s, Animation<double> animation) {
  return SizeTransition(  
    axis: Axis.vertical,  
    sizeFactor: animation,  
    child: const Text(s),
  );
}

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

Getting Started #

TBD

Parameters #

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

AnimatedStreamListItemBuilder is just a function which builds a tile

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

Options #

Equalizer<E> equals; 

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

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

typedef bool Equalizer<E>(E item1, E item2);

You can check the Animated List Documentation for the rest:

final Axis scrollDirection;  
final bool reverse;  
final ScrollController scrollController;  
final bool primary;  
final ScrollPhysics scrollPhysics;  
final bool shrinkWrap;  
final EdgeInsetsGeometry padding;  
33
likes
0
pub points
67%
popularity

Publisher

unverified uploader

A Flutter library to easily display a list with animated changes from a Stream<List<E>>. It's like StreamBuilder + ListView.Builder with animations.

Repository (GitLab)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter, meta

More

Packages that depend on animated_stream_list