ios_screen_recorder 0.0.8
ios_screen_recorder: ^0.0.8 copied to clipboard
Screen Recorder plugin is for iOS.
example/lib/main.dart
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:screen_recorder/screen_recorder.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
String _logs = 'Unknown';
final _screenRecorderPlugin = ScreenRecorder();
@override
void initState() {
super.initState();
String dirPath = ''; // Add path to save the video.
startRecord(dirPath);
}
// Void
Future<void> startRecord(String dirPath) async {
try {
final recordStatus =
await _screenRecorderPlugin.startScreenRecord(dirPath) ?? 'Start recording failure.';
setState(() {
_logs = recordStatus;
});
} on PlatformException catch(e) {
_logs = 'Failed to get platform version.';
}
}
Future<void> stopRecord() async {
try {
final videoURL =
await _screenRecorderPlugin.stopScreenRecord() ?? 'Stop recording failure.';
setState(() {
_logs = videoURL;
});
} on PlatformException {
_logs = 'Failed to get platform version.';
}
}
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
appBar: AppBar(
title: const Text('Screen Recorder Plugin example'),
),
body: Center(
child: Column(mainAxisAlignment: MainAxisAlignment.center, children: [Text('log: $_logs\n'),
ElevatedButton(onPressed: (){
stopRecord();
}, child: const Text('STOP Record'))
]),
),
),
);
}
}