fix: foreground task scope (#314)

This commit is contained in:
Levi authored and GitHub committed 2024-01-05 21:49:21 +08:00
1 parent 29d0f5ebcf
commit 895a8d2ee4
2 files changed
+6 -6

No files matched your search

@@ -1,4 +1,5 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_foreground_task/flutter_foreground_task.dart';
import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
@@ -14,7 +15,8 @@ class AppView extends GetView<AppController> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final config = controller.downloaderConfig.value; final config = controller.downloaderConfig.value;
return GetMaterialApp.router( return WithForegroundTask(
child: GetMaterialApp.router(
useInheritedMediaQuery: true, useInheritedMediaQuery: true,
debugShowCheckedModeBanner: false, debugShowCheckedModeBanner: false,
theme: GopeedTheme.light, theme: GopeedTheme.light,
@@ -30,6 +32,7 @@ class AppView extends GetView<AppController> {
], ],
supportedLocales: messages.keys.keys.map((e) => toLocale(e)).toList(), supportedLocales: messages.keys.keys.map((e) => toLocale(e)).toList(),
getPages: AppPages.routes, getPages: AppPages.routes,
),
); );
} }
} }
@@ -1,5 +1,4 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_foreground_task/flutter_foreground_task.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import '../../../routes/app_pages.dart'; import '../../../routes/app_pages.dart';
@@ -12,7 +11,7 @@ class HomeView extends GetView<HomeController> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return GetRouterOutlet.builder(builder: (context, delegate, currentRoute) { return GetRouterOutlet.builder(builder: (context, delegate, currentRoute) {
switch (currentRoute?.location) { switch (currentRoute?.uri.path) {
case Routes.EXTENSION: case Routes.EXTENSION:
controller.currentIndex.value = 1; controller.currentIndex.value = 1;
break; break;
@@ -24,8 +23,7 @@ class HomeView extends GetView<HomeController> {
break; break;
} }
return WithForegroundTask( return Scaffold(
child: Scaffold(
// extendBody: true, // extendBody: true,
body: Row( body: Row(
// crossAxisAlignment: CrossAxisAlignment.start, // crossAxisAlignment: CrossAxisAlignment.start,
@@ -158,7 +156,6 @@ class HomeView extends GetView<HomeController> {
// }, // },
// ) // )
: const SizedBox.shrink(), : const SizedBox.shrink(),
),
); );
}); });
} }