Last active
January 21, 2019 22:31
-
-
Save felangel/e983846f7e60c3ecbe9a5643ab54e493 to your computer and use it in GitHub Desktop.
[flutter_infinite_list] post state
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:equatable/equatable.dart'; | |
import 'package:flutter_infinite_list/models/models.dart'; | |
abstract class PostState extends Equatable { | |
PostState([List props = const []]) : super(props); | |
} | |
class PostUninitialized extends PostState { | |
@override | |
String toString() => 'PostUninitialized'; | |
} | |
class PostError extends PostState { | |
@override | |
String toString() => 'PostError'; | |
} | |
class PostLoaded extends PostState { | |
final List<Post> posts; | |
final bool hasReachedMax; | |
PostLoaded({ | |
this.posts, | |
this.hasReachedMax, | |
}) : super([posts, hasReachedMax]); | |
PostLoaded copyWith({ | |
List<Post> posts, | |
bool hasReachedMax, | |
}) { | |
return PostLoaded( | |
posts: posts ?? this.posts, | |
hasReachedMax: hasReachedMax ?? this.hasReachedMax, | |
); | |
} | |
@override | |
String toString() => | |
'PostLoaded { posts: ${posts.length}, hasReachedMax: $hasReachedMax }'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment