Skip to content

Instantly share code, notes, and snippets.

@bardiarastin
Last active January 29, 2020 09:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bardiarastin/3997adb995e3bbb4f7eeb7f6f445af86 to your computer and use it in GitHub Desktop.
Save bardiarastin/3997adb995e3bbb4f7eeb7f6f445af86 to your computer and use it in GitHub Desktop.
import 'package:meta/meta.dart';
import 'package:redux_example/src/models/i_post.dart';
@immutable
class PostsState {
final bool isError;
final bool isLoading;
final List<IPost> posts;
PostsState({
this.isError,
this.isLoading,
this.posts,
});
factory PostsState.initial() => PostsState(
isLoading: false,
isError: false,
posts: const [],
);
PostsState copyWith({
@required bool isError,
@required bool isLoading,
@required List<IPost> posts,
}) {
return PostsState(
isError: isError ?? this.isError,
isLoading: isLoading ?? this.isLoading,
posts: posts ?? this.posts,
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment