for this question the library flutter_recorder has the solution, check this simple snipped code
/project/pubspec.yaml
dependencies:
...
flutter_recorder: ^0.9.2
/project/lib/main.dart
import 'package:flutter_recorder/flutter_recorder.dart';
....
class _YourWiget extends State<MainWidget>{
final _recorder = Recorder.instance
...
void dispose() async {
super.dispose();
// Good practices, stop the recording when the widget isn't showing
_recorder.stop();
...
}
void initState(){
super.initState();
// init recorder library
_recorder.init();
// start recording
_recorder.start();
...
}
}
see the pub.dev page to configure the android, ios and macos permissions : https://pub.dev/packages/flutter_recorder