ScreenshotX
The ScreenshotX package provides a cross-platform solution for capturing desktop screenshots and picking colors from the screen in Flutter applications.
Linux | macOS | Windows | |
---|---|---|---|
Support | ✅ | ❌ | ❌ |
To use the ScreenshotX plugin, add screenshotx
as a dependency in your project's pubspec.yaml file.
Image? fullScreenImage = await screenshotX.captureFullScreen();
Color? pickedColor = await screenshotX.pickColor();
For more details on using the ScreenshotX package, check out the example provided in the example directory.
Created by @aadarshadhakalg
Feel free to report any issues or contribute to the project on GitHub. We appreciate your feedback and contributions!
Run this command:
With Flutter:
$ flutter pub add screenshotx
This will add a line like this to your package's pubspec.yaml (and run an implicit flutter pub get
):
dependencies:
screenshotx: ^1.0.0
Alternatively, your editor might support flutter pub get
. Check the docs for your editor to learn more.
Now in your Dart code, you can use:
import 'package:screenshotx/screenshotx.dart';
example/lib/main.dart
import 'dart:typed_data';
import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:screenshotx/screenshotx.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
final _screenshotX = ScreenshotX();
Uint8List? imageBytes;
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
floatingActionButton: FloatingActionButton(
onPressed: () async {
var image = await _screenshotX.captureFullScreen();
if (image != null) {
final pngBytes =
await image.toByteData(format: ImageByteFormat.png);
imageBytes = Uint8List.view(pngBytes!.buffer);
}
setState(() {});
},
child: const Icon(Icons.camera),
),
body: Center(
child: imageBytes != null
? Image.memory(imageBytes!)
: const Text("No Screenshot Taken"),
),
),
);
}
}
Download details:
Author: