You only need add the permission message on the Info.plist
<key>NSPhotoLibraryUsageDescription</key>
<string>Save video in gallery</string><key>NSMicrophoneUsageDescription</key><string>Save audio in video</string>
Usage/Examples
import'package:screen_recorder/screen_recorder.dart';
ScreenRecorder? screenRecorder;
Map<String, dynamic>? _response;
@overridevoidinitState() {
super.initState();
screenRecorder = ScreenRecorder();
}
Future<void> startRecord({requiredString fileName}) async {
// Directory tempDir = await getTemporaryDirectory();// String tempPath = tempDir.path;var response = await edScreenRecorder?.startRecordScreen(
fileName: fileName,
// `dirPathToSave` Optional. It will save the video there when you give the file path with whatever you want.//If you leave it blank, the Android operating system will save it to the gallery.
dirPathToSave: tempPath,
audioEnable: false,
);
setState(() {
_response = response;
});
}
Future<void> stopRecord() async {
var response = await edScreenRecorder?.stopRecord();
setState(() {
_response = response;
});
}
@overrideWidgetbuild(BuildContext context) {
returnScaffold(
appBar: AppBar(
title: constText("Screen Recording Debug"),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text("File: ${(_response?['file'] as File?)?.path}"),
Text("Status: ${(_response?['success']).toString()}"),
Text("Event: ${_response?['eventname']}"),
Text("Progress: ${(_response?['progressing']).toString()}"),
Text("Message: ${_response?['message']}"),
Text("Video Hash: ${_response?['videohash']}"),
Text("Start Date: ${(_response?['startdate']).toString()}"),
Text("End Date: ${(_response?['enddate']).toString()}"),
ElevatedButton(onPressed: () => startRecord(fileName: "eren"), child: constText('START RECORD')),
ElevatedButton(onPressed: () => stopRecord(), child: constText('STOP RECORD')),
],
),
),
);
}
Resources used within the plugin
HBRecorder
Lightweight screen and audio recording Android library.
URL