You need a background collection service. Usually both Android and iOS gives you the option to run background operations with the following options:
Run background operations when APP is closed
Run background operations when the device restarts
Beware that these background operations will be terminated after a certain time by the OS. This is the default behavior, but there are some workarounds you can try.
There is a package that will help you with these features, its the flutter-background-geolocation, made by Transistorsoftware, I use this package on my applications and it works pretty fine!
https://github.com/transistorsoft/flutter_background_geolocation
Just beware: you can't easily access the keychain while the APP is in the background, so keep that in mind when you're performing these operations 😉