LCOV - code coverage report
Current view: top level - view - view_state.dart (source / functions) Hit Total Coverage
Test: lcov.info Lines: 21 24 87.5 %
Date: 2020-03-25 12:10:52 Functions: 0 0 -

          Line data    Source code
       1             : import 'package:equatable/equatable.dart';
       2             : import 'package:flutter/foundation.dart';
       3             : 
       4             : /// Base class for states.
       5             : @immutable
       6             : abstract class ViewState extends Equatable {
       7           7 :   const ViewState();
       8             : 
       9           5 :   @override
      10           5 :   List<Object> get props => [];
      11             : }
      12             : 
      13             : /// The initial view state.
      14             : class Initial extends ViewState {
      15           0 :   const Initial();
      16             : 
      17           5 :   @override
      18             :   String toString() => 'Initial';
      19             : }
      20             : 
      21             : /// State indicating that data is being loaded.
      22             : class Loading extends ViewState {
      23           0 :   const Loading();
      24             : 
      25           5 :   @override
      26             :   String toString() => 'Loading';
      27             : }
      28             : 
      29             : /// State indicating that data is being refreshed. It can occur only after
      30             : /// initial loading ends with [Success] or [Empty] result. It may contain
      31             : /// the data that has already been loaded.
      32             : class Refreshing<T> extends ViewState {
      33             :   final T data;
      34             : 
      35           2 :   const Refreshing(this.data);
      36             : 
      37           2 :   @override
      38           4 :   List<Object> get props => [data];
      39             : 
      40           2 :   @override
      41           4 :   String toString() => 'Refreshing: $data';
      42             : }
      43             : 
      44             : /// State indicating that data was loaded successfully, but was null or empty.
      45             : class Empty extends ViewState {
      46           0 :   const Empty();
      47             : 
      48           5 :   @override
      49             :   String toString() => 'Empty';
      50             : }
      51             : 
      52             : /// State indicating that data was loaded successfully and is not null nor empty.
      53             : /// [T] - list element type.
      54             : class Success<T> extends ViewState {
      55             :   final T data;
      56             : 
      57           5 :   const Success(this.data) : assert(data != null);
      58             : 
      59           5 :   @override
      60          10 :   List<Object> get props => [data];
      61             : 
      62           5 :   @override
      63          10 :   String toString() => 'Success: $data';
      64             : }
      65             : 
      66             : /// State indicating that loading or refreshing has failed. It contains an
      67             : /// exact [error] that has occurred.
      68             : class Failure extends ViewState {
      69             :   final dynamic error;
      70             : 
      71           7 :   const Failure(this.error) : assert(error != null);
      72             : 
      73           5 :   @override
      74          10 :   List<Object> get props => [error];
      75             : 
      76           5 :   @override
      77          10 :   String toString() => 'Failure: $error';
      78             : }

Generated by: LCOV version 1.14