flutter_foreground_task
flutter_foreground_task copied to clipboard
Question WithForegroundTask
Hello ,
i need help using the Widget WithForegroundTask. I followed the tutorial , adding the widget just before the scaffold. The apps starts fine the foregrounbd task too, but if i close app , the task shutdown too. How can i debug my app ?
For now i just added the code from the example in my app. I use riverpod , so my app do not depends on <State> but <ConsumerState> could it be the issue ?
by the way if i remove the WithForegroundTask
from the example
@override Widget build(BuildContext context) { // A widget that prevents the app from closing when the foreground service is running. // This widget must be declared above the [Scaffold] widget. return WithForegroundTask( child: Scaffold( appBar: AppBar( title: const Text('Flutter Foreground Task'), centerTitle: true, ), body: _buildContentView(), ), ); }
i got no change, will closing app , it do not close , i still get notification running in top bar. On other side in my app if i add the WithForegroundTask widget , the app closes as it should prevent it to happen.