Line data Source code
1 : import 'platform/platform_none.dart' 2 : if (dart.library.io) 'platform/platform_io.dart' 3 : if (dart.library.js) 'platform/platform_web.dart'; 4 : 5 : /// This library is a wrapper for iOS and Android to send the application to the background programmatically. 6 : import 'dart:async'; 7 : 8 : import 'package:flutter/services.dart'; 9 : 10 : /// A class containing the static function used. 11 : class MoveToBackground { 12 : /// The method channel used to contact the native side 13 : static const MethodChannel _channel = 14 : const MethodChannel('move_to_background'); 15 : 16 : /// Calls the platform-specific function to send the app to the background 17 0 : static Future<void> moveTaskToBack() async { 18 0 : if (Platform.isIOS || Platform.isAndroid) { 19 0 : await _channel.invokeMethod('moveTaskToBack'); 20 : } else { 21 : throw ('This method should only be called on IOS or Android.'); 22 : } 23 : } 24 : }