win_capture 0.0.4 copy "win_capture: ^0.0.4" to clipboard
win_capture: ^0.0.4 copied to clipboard

outdated

screen capture plugin for mac, linux and window os

example/lib/main.dart

import 'dart:io';
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:path_provider/path_provider.dart';
import 'package:win_capture/win_capture.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
        home: HomeScreen()
    );
  }
}

class HomeScreen extends StatefulWidget {
  const HomeScreen({Key? key}) : super(key: key);

  @override
  State<HomeScreen> createState() => _HomeScreenState();
}

class _HomeScreenState extends State<HomeScreen> {

  late WinCapture _winCapture;
  var _libPath;
  @override
  void initState() {
    super.initState();
    _winCapture = WinCapture();
    initialSetup();
  }
  void initialSetup()async{
   if(Platform.isMacOS){
     _winCapture.requestPermission();
   }else if(Platform.isLinux){
     final getTempPath = await getDownloadsDirectory();
     final Directory appDocDirFolder = Directory(getTempPath!.path);
     if (!await appDocDirFolder.exists()) {
       await appDocDirFolder.create(recursive: true);
     }
     _libPath = appDocDirFolder.path;
     _winCapture.initLinuxSnapLib(_libPath);
   }
   setState(() {

   });
  }
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Plugin example app'),
      ),
      body: Container(
        color: Colors.white,
        width: MediaQuery.of(context).size.width,
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            MaterialButton(
              padding: const EdgeInsets.symmetric(horizontal: 40),
              color: Colors.blue,
              onPressed: ()async{
                final Directory appDocDirFolder = Directory('${Directory.current.path}/snapshot');
                if (!await appDocDirFolder.exists()) {
                  await appDocDirFolder.create(recursive: true);
                }
                if(Platform.isMacOS || Platform.isWindows){
              var path =    await _winCapture.getScreenSnapShot(fileName: "${DateTime.now().millisecondsSinceEpoch}.png",
                      filePath: appDocDirFolder.path);
              print(path);
                }else{
                  _winCapture.getScreenSnapShot(fileName: "${DateTime.now().millisecondsSinceEpoch}.png",
                      filePath: appDocDirFolder.path, libPath: _libPath);
                }

              },
              child:const Text("Capture Screen", style: TextStyle(color: Colors.white),),),
            SizedBox(height: 30,),
            MaterialButton(
              padding: const EdgeInsets.symmetric(horizontal: 40),
              color: Colors.blue,
              onPressed: ()async{

                _winCapture.popUpWindow().then((value) {
                  print(value);
                });
              },
              child:const Text("popUpWindow", style: TextStyle(color: Colors.white),),),
          ],
        ),
      ),
    );
  }
}
3
likes
120
points
33
downloads

Publisher

unverified uploader

Weekly Downloads

screen capture plugin for mac, linux and window os

Repository (GitHub)

Documentation

API reference

License

unknown (license)

Dependencies

ffi, flutter, path, plugin_platform_interface

More

Packages that depend on win_capture