Skip to content

Commit

Permalink
Added RequestStatus
Browse files Browse the repository at this point in the history
  • Loading branch information
shinayser committed Dec 12, 2019
1 parent a38feec commit 3899566
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 13 deletions.
42 changes: 42 additions & 0 deletions lib/utils/request_status.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
class RequestStatus {
final String name;

const RequestStatus._internal(this.name);

static const RequestStatus IDLE = const RequestStatus._internal("IDLE");
static const RequestStatus WAITING = const RequestStatus._internal("WAITING");
static const RequestStatus DONE = const RequestStatus._internal("DONE");
static const RequestStatus ERROR = const RequestStatus._internal("ERROR");

@override
String toString() => name;
}

class RequestObject<T> {
T result;
dynamic error;
RequestStatus status;
dynamic tag; //A dynamic value to identify this RequestObject

RequestObject(this.result, this.status);

RequestObject.done({this.result, this.tag}) {
this.status = RequestStatus.DONE;
}

RequestObject.error({this.error, this.tag}) {
this.status = RequestStatus.ERROR;
}

RequestObject.waiting({this.result, this.tag}) {
this.status = RequestStatus.WAITING;
}

RequestObject.idle({this.result, this.tag}) {
this.status = RequestStatus.IDLE;
}

@override
String toString() =>
"RequestObject {$status} ${result != null ? "{$result}" : ""}";
}
71 changes: 60 additions & 11 deletions pubspec.lock
Original file line number Diff line number Diff line change
@@ -1,20 +1,34 @@
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
archive:
dependency: transitive
description:
name: archive
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.11"
args:
dependency: transitive
description:
name: args
url: "https://pub.dartlang.org"
source: hosted
version: "1.5.2"
async:
dependency: transitive
description:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.2.0"
version: "2.4.0"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.4"
version: "1.0.5"
charcode:
dependency: transitive
description:
Expand All @@ -29,6 +43,20 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.14.11"
convert:
dependency: transitive
description:
name: convert
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.1"
crypto:
dependency: transitive
description:
name: crypto
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.3"
flutter:
dependency: "direct main"
description: flutter
Expand All @@ -39,48 +67,62 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
image:
dependency: transitive
description:
name: image
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.4"
matcher:
dependency: transitive
description:
name: matcher
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.5"
version: "0.12.6"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.6"
version: "1.1.8"
path:
dependency: transitive
description:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.6.2"
version: "1.6.4"
pedantic:
dependency: transitive
description:
name: pedantic
url: "https://pub.dartlang.org"
source: hosted
version: "1.7.0"
version: "1.8.0+1"
petitparser:
dependency: transitive
description:
name: petitparser
url: "https://pub.dartlang.org"
source: hosted
version: "2.4.0"
quiver:
dependency: "direct main"
description:
name: quiver
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.3"
version: "2.0.5"
rxdart:
dependency: "direct main"
description:
name: rxdart
url: "https://pub.dartlang.org"
source: hosted
version: "0.22.0"
version: "0.22.6"
sky_engine:
dependency: transitive
description: flutter
Expand Down Expand Up @@ -113,7 +155,7 @@ packages:
name: string_scanner
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.4"
version: "1.0.5"
term_glyph:
dependency: transitive
description:
Expand All @@ -127,7 +169,7 @@ packages:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.5"
version: "0.2.11"
typed_data:
dependency: transitive
description:
Expand All @@ -142,5 +184,12 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.8"
xml:
dependency: transitive
description:
name: xml
url: "https://pub.dartlang.org"
source: hosted
version: "3.5.0"
sdks:
dart: ">=2.2.2 <3.0.0"
dart: ">=2.4.0 <3.0.0"
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: shinayser_essentials_flutter
description: A new Flutter project.
version: 1.15.0
version: 1.16.0
author:
homepage:

Expand All @@ -12,7 +12,7 @@ dependencies:
sdk: flutter

quiver: '>=2.0.0 <3.0.0'
rxdart: ^0.22.0
rxdart: ^0.22.6

dev_dependencies:
flutter_test:
Expand Down

0 comments on commit 3899566

Please sign in to comment.