Skip to content

Commit

Permalink
Merge pull request #1 from davidhsoftware/master
Browse files Browse the repository at this point in the history
Unknown event instead of force unwrap
  • Loading branch information
bartonip authored Jul 14, 2022
2 parents 4c71c16 + 4adb250 commit fcacbd6
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 30 deletions.
20 changes: 10 additions & 10 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ packages:
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "1.15.0"
version: "1.16.0"
cross_file:
dependency: transitive
description:
Expand All @@ -63,7 +63,7 @@ packages:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
version: "1.3.0"
flutter:
dependency: "direct main"
description: flutter
Expand All @@ -75,7 +75,7 @@ packages:
path: ".."
relative: true
source: path
version: "0.1.0"
version: "0.2.0"
flutter_plugin_android_lifecycle:
dependency: transitive
description:
Expand Down Expand Up @@ -141,7 +141,7 @@ packages:
name: js
url: "https://pub.dartlang.org"
source: hosted
version: "0.6.3"
version: "0.6.4"
local_auth:
dependency: "direct main"
description:
Expand All @@ -162,7 +162,7 @@ packages:
name: material_color_utilities
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.3"
version: "0.1.4"
meta:
dependency: transitive
description:
Expand All @@ -176,7 +176,7 @@ packages:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0"
version: "1.8.1"
platform:
dependency: transitive
description:
Expand All @@ -202,7 +202,7 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.1"
version: "1.8.2"
stack_trace:
dependency: transitive
description:
Expand Down Expand Up @@ -237,7 +237,7 @@ packages:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.8"
version: "0.4.9"
typed_data:
dependency: transitive
description:
Expand All @@ -251,7 +251,7 @@ packages:
name: vector_math
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.1"
version: "2.1.2"
sdks:
dart: ">=2.14.0 <3.0.0"
dart: ">=2.17.0-0 <3.0.0"
flutter: ">=2.5.0"
7 changes: 3 additions & 4 deletions lib/flutter_fgbg.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@ import 'package:flutter/widgets.dart';
enum FGBGType {
enteredForeground,
enteredBackground,

willEnterForeground,

willTerminate,

willSwitchContext,
unknown,
}

Map<String, FGBGType> messageToFGBGMapping = {
Expand All @@ -33,7 +31,8 @@ Map<String, FGBGType> messageToFGBGMapping = {
class FGBGEvents {
static const _channel = EventChannel("com.ajinasokan.flutter_fgbg/events");

static Stream<FGBGType> get stream => _channel.receiveBroadcastStream().map((event) => messageToFGBGMapping[event]!);
static Stream<FGBGType> get stream =>
_channel.receiveBroadcastStream().map((event) => messageToFGBGMapping[event] ?? FGBGType.unknown);
}

class FGBGNotifier extends StatefulWidget {
Expand Down
25 changes: 9 additions & 16 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ packages:
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "1.15.0"
version: "1.16.0"
fake_async:
dependency: transitive
description:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
version: "1.3.0"
flutter:
dependency: "direct main"
description: flutter
Expand All @@ -73,7 +73,7 @@ packages:
name: material_color_utilities
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.3"
version: "0.1.4"
meta:
dependency: transitive
description:
Expand All @@ -87,7 +87,7 @@ packages:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0"
version: "1.8.1"
sky_engine:
dependency: transitive
description: flutter
Expand All @@ -99,7 +99,7 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.1"
version: "1.8.2"
stack_trace:
dependency: transitive
description:
Expand Down Expand Up @@ -134,21 +134,14 @@ packages:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.8"
typed_data:
dependency: transitive
description:
name: typed_data
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
version: "0.4.9"
vector_math:
dependency: transitive
description:
name: vector_math
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.1"
version: "2.1.2"
sdks:
dart: ">=2.14.0 <3.0.0"
flutter: ">=1.10.0"
dart: ">=2.17.0-0 <3.0.0"
flutter: ">=1.12.13+hotfix.6"

0 comments on commit fcacbd6

Please sign in to comment.