flutter_android_foreground_service 0.5.1 copy "flutter_android_foreground_service: ^0.5.1" to clipboard
flutter_android_foreground_service: ^0.5.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_android_foreground_service/flutter_android_foreground_service.dart';

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

void startForegroundService() async {
  ForegroundService.startService('test title', 'test text');
  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.stopService();
    super.dispose();
  }
}
0
likes
130
points
15
downloads

Publisher

unverified uploader

Weekly Downloads

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

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on flutter_android_foreground_service

Packages that implement flutter_android_foreground_service