flutter_foreground_service 0.4.1 copy "flutter_foreground_service: ^0.4.1" to clipboard
flutter_foreground_service: ^0.4.1 copied to clipboard

PlatformAndroid

Foreground service for the Android platform, keeps app running even when in background.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter_foreground_service/flutter_foreground_service.dart';

void main() {
  runApp(MyApp());
  startForegroundService();
}

void startForegroundService() async {
  ForegroundService().start();
  debugPrint("Started service");
}

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Foreground Service Example'),
        ),
        body: Center(
            child: Text('Foreground service example, check notification bar')),
      ),
    );
  }

  @override
  void dispose() {
    ForegroundService().stop();
    super.dispose();
  }
}
31
likes
150
points
394
downloads

Publisher

verified publishercachet.dk

Weekly Downloads

Foreground service for the Android platform, keeps app running even when in background.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on flutter_foreground_service