Skip to content

Commit

Permalink
Migrate last_online_reporting to null safety. (#727)
Browse files Browse the repository at this point in the history
Closes #190
  • Loading branch information
Jonas-Sander authored Aug 9, 2023
1 parent a7f3f7c commit 2706c77
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
6 changes: 3 additions & 3 deletions lib/last_online_reporting/lib/last_online_reporting.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class LastOnlineReporter {
final CrashAnalytics _crashAnalytics;
final Stream<AppLifecycleState> _lifecycleChanges;
final Duration _debounceTime;
StreamSubscription _streamSubscription;
StreamSubscription? _streamSubscription;

factory LastOnlineReporter.startReporting(
FirebaseFirestore firestore,
Expand All @@ -36,7 +36,7 @@ class LastOnlineReporter {
/// report being online every ten minutes (instead of reporting more often).
/// This does not mean that there absolutely will be an update e.g. every 10
/// minutes only that this is the miniumum allowed duration between reports.
@required Duration minimumDurationBetweenReports,
required Duration minimumDurationBetweenReports,
}) {
final reporter = LastOnlineReporter.internal(
FirestoreLastOnlineReporterBackend(firestore, userId)
Expand All @@ -56,7 +56,7 @@ class LastOnlineReporter {
this._reportBeingCurrentlyOnlineToBackend,
this._lifecycleChanges,
this._crashAnalytics, {
@required Duration debounceTime,
required Duration debounceTime,
}) : _debounceTime = debounceTime;

@visibleForTesting
Expand Down
3 changes: 1 addition & 2 deletions lib/last_online_reporting/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@
name: last_online_reporting
description: A new Flutter package project.
version: 0.0.1
homepage: null
publish_to: none

environment:
sdk: ">=2.10.0 <3.0.0"
sdk: ">=2.12.0 <3.0.0"
flutter: ">=1.17.0 <2.0.0"

dependencies:
Expand Down
14 changes: 6 additions & 8 deletions lib/last_online_reporting/test/last_online_reporting_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,18 @@

import 'dart:async';

import 'package:common_domain_models/src/ids/user_id.dart';
import 'package:crash_analytics/mock_crash_analytics.dart';
import 'package:fake_async/fake_async.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:last_online_reporting/last_online_reporting.dart';
import 'package:last_online_reporting/src/implementation.dart';

class MockLastOnlineReporterBackend extends FirestoreLastOnlineReporterBackend {
class MockLastOnlineReporterBackend
implements FirestoreLastOnlineReporterBackend {
int reportedOnlineToBackend = 0;
bool shouldThrow = false;

MockLastOnlineReporterBackend() : super(null, UserId('userId'));

@override
Future<void> reportCurrentlyOnline() async {
reportedOnlineToBackend += 1;
Expand All @@ -33,10 +31,10 @@ class MockLastOnlineReporterBackend extends FirestoreLastOnlineReporterBackend {

void main() {
group('$LastOnlineReporter', () {
MockLastOnlineReporterBackend backend;
StreamController<AppLifecycleState> lifecycleChanges;
LastOnlineReporter lastOnlineReporter;
MockCrashAnalytics crashAnalytics;
late MockLastOnlineReporterBackend backend;
late StreamController<AppLifecycleState> lifecycleChanges;
late LastOnlineReporter lastOnlineReporter;
late MockCrashAnalytics crashAnalytics;
const debounceTime = Duration(minutes: 10);

setUp(() {
Expand Down

0 comments on commit 2706c77

Please sign in to comment.