move_to_bg
A Flutter plugin that allows you to programmatically move your application to the background.
Platform Support
| Platform | Status | Notes |
|---|---|---|
| Android | ✅ Supported | Uses official public API |
| iOS | ⚠️ Caution | Uses private API - see iOS Warning |
Installation
Add this to your package's pubspec.yaml file:
dependencies:
move_to_bg: ^1.0.0
Usage
import 'package:move_to_bg/move_to_bg';
// Move the app to the background
final moveToBg = MoveToBg();
await moveToBg.moveTaskToBack();
Platform Behavior
Android
The app will move to the background but remain in the recent apps list. The app will not be closed.
iOS
⚠️ IMPORTANT: The iOS implementation uses UIApplication.suspend, which is a private API. Using this method may cause your app to be rejected during App Store review.
Use at your own risk. This plugin is recommended for:
- Enterprise applications
- Development builds
- Applications distributed outside the App Store
There is currently no official public API available to programmatically move an iOS app to the background.
Example
import 'package:flutter/material.dart';
import 'package:move_to_bg/move_to_bg';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('Move to Background Example')),
body: Center(
child: ElevatedButton(
onPressed: () async {
final moveToBg = MoveToBg();
await moveToBg.moveTaskToBack();
},
child: const Text('Move to Background'),
),
),
),
);
}
}
Requirements
- Android: min SDK 24+ (Android 7.0)
- iOS: Deployment target 13.0+
License
See LICENSE file for details.