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

Generated by: LCOV version 1.14