Browse Source

Kill the background isolate

vishnukvmd 3 years ago
parent
commit
bc76b1033b
1 changed files with 2 additions and 0 deletions
  1. 2 0
      lib/main.dart

+ 2 - 0
lib/main.dart

@@ -1,4 +1,5 @@
 import 'dart:async';
 import 'dart:async';
+import 'dart:isolate';
 
 
 import 'package:background_fetch/background_fetch.dart';
 import 'package:background_fetch/background_fetch.dart';
 import 'package:flutter/foundation.dart';
 import 'package:flutter/foundation.dart';
@@ -222,6 +223,7 @@ Future<void> _killBGTask(String taskId) async {
   final prefs = await SharedPreferences.getInstance();
   final prefs = await SharedPreferences.getInstance();
   prefs.remove(kLastBGTaskHeartBeatTime);
   prefs.remove(kLastBGTaskHeartBeatTime);
   BackgroundFetch.finish(taskId);
   BackgroundFetch.finish(taskId);
+  Isolate.current.kill(priority: Isolate.immediate);
 }
 }
 
 
 class EnteApp extends StatefulWidget {
 class EnteApp extends StatefulWidget {