made a simple counter app with shake package to increment counter var by shaking phone, things works well when app is running in front (in active state) but opening other app stops this shake feature after one minute, it works only for one minute but not after one minute, i have tried to implement isolate but i couldn't do so, If someone can show me how to implement isolate in following code i will be very thanks full to him, Thank you
Code is here:
import 'package:flutter/material.dart';
import 'package:shake/shake.dart';
void main() => runApp(MyApp());
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
int _counter = 0;
ShakeDetector detector;
@override
void initState() {
detector = ShakeDetector.autoStart(onPhoneShake: () {
setState(() {
_counter++;
});
});
super.initState();
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: Center(child: Text('$_counter')),
),
);
}
}