flutter_foreground_service 0.4.0 copy "flutter_foreground_service: ^0.4.0" to clipboard
flutter_foreground_service: ^0.4.0 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();
  }
}
30
likes
150
pub points
90%
popularity

Publisher

verified publishercachet.dk

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