title: Flutter-background process
body: <p>I have a question about background process in flutter. The app I am building needs to constantly work in the background and use live accelerometer data. I have been over many libraries and tutorials, but I just can find something which will work constantly in the background. I used the <a href="https://pub.dev/packages/flutter_background_service" rel="nofollow noreferrer">flutter_background_service</a>package  and there is a notification on the top of the screen which says &quot;background service- preparing.&quot; Any suggestions?</p>
  <pre><code>void onStart() {
    WidgetsFlutterBinding.ensureInitialized();
    
    final service = FlutterBackgroundService();
    service.setForegroundMode(false);
    
    }
  
  
  
  
  void didChangeAppLifecycleState(AppLifecycleState state) {
      super.didChangeAppLifecycleState(state);
  
      if (state == AppLifecycleState.inactive ||
          state == AppLifecycleState.detached) return;
  
      final isBackground = state == AppLifecycleState.paused;
  
      if (isBackground) {
        number=1;
      }
  
      else{
        number=0;
  </code></pre>