background_mode_new 1.0.3 copy "background_mode_new: ^1.0.3" to clipboard
background_mode_new: ^1.0.3 copied to clipboard

PlatformAndroid

Package to perform infinite background execution (Android only).

example/lib/main.dart

import 'dart:async';

import 'package:background_mode/background_mode_new.dart';
import 'package:flutter/material.dart';

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

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

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

  // Platform messages are asynchronous, so we initialize in an async method.
  void initPlatformState() async {
    BackgroundMode.start();

    Timer.periodic(Duration(seconds: 10), (timer) {
      BackgroundMode.disable();
      BackgroundMode.bringToForeground();
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Text('Example'),
        ),
      ),
    );
  }
}
3
likes
140
points
39
downloads

Publisher

verified publisherromreed.dev

Weekly Downloads

Package to perform infinite background execution (Android only).

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-2-Clause (license)

Dependencies

flutter

More

Packages that depend on background_mode_new