LCOV - code coverage report
Current view: top level - common - view_state.dart (source / functions) Hit Total Coverage
Test: lcov.info Lines: 20 20 100.0 %
Date: 2019-10-10 15:54:03 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           4 :   const ViewState();
       8             : 
       9           4 :   @override
      10           4 :   List<Object> get props => [];
      11             : }
      12             : 
      13             : /// State indicating that data is being loaded.
      14             : class Loading extends ViewState {
      15           4 :   @override
      16             :   String toString() => 'Loading';
      17             : }
      18             : 
      19             : /// State indicating that data is being refreshed. It can occur only after
      20             : /// initial loading ends with [Success] or [Empty] result. It may contain
      21             : /// the data that has already been loaded.
      22             : class Refreshing<T> extends ViewState {
      23             :   final T data;
      24             : 
      25           2 :   const Refreshing(this.data);
      26             : 
      27           2 :   @override
      28           4 :   List<Object> get props => [data];
      29             : 
      30           2 :   @override
      31           4 :   String toString() => 'Refreshing: $data';
      32             : }
      33             : 
      34             : /// State indicating that data was loaded successfully, but was null or empty.
      35             : class Empty extends ViewState {
      36           4 :   @override
      37             :   String toString() => 'Empty';
      38             : }
      39             : 
      40             : /// State indicating that data was loaded successfully and is not null nor empty.
      41             : /// [T] - list element type.
      42             : class Success<T> extends ViewState {
      43             :   final T data;
      44             : 
      45           4 :   Success(this.data) : assert(data != null);
      46             : 
      47           4 :   @override
      48           8 :   List<Object> get props => [data];
      49             : 
      50           4 :   @override
      51           8 :   String toString() => 'Success: $data';
      52             : }
      53             : 
      54             : /// State indicating that loading or refreshing has failed. It contains an
      55             : /// exact [error] that has occurred.
      56             : class Failure extends ViewState {
      57             :   final dynamic error;
      58             : 
      59           4 :   Failure(this.error) : assert(error != null);
      60             : 
      61           4 :   @override
      62           8 :   List<Object> get props => [error];
      63             : 
      64           4 :   @override
      65           8 :   String toString() => 'Failure: $error';
      66             : }

Generated by: LCOV version 1.14