wingetscreen 0.0.1 copy "wingetscreen: ^0.0.1" to clipboard
wingetscreen: ^0.0.1 copied to clipboard

PlatformWindows

flutter plugin for windows screen capture

example/lib/main.dart

import 'dart:io';

import 'package:flutter/material.dart';
import 'dart:async';

import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
import 'package:wingetscreen/wingetscreen.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> {
  String _platformVersion = 'Unknown';
  Image? _capturedimage;
  @override
  void initState() {
    initPlatformState();

    super.initState();


  }

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    String result;
    // Platform messages may fail, so we use a try/catch PlatformException.
    // We also handle the message potentially returning null.
    try {
      result =
          await Wingetscreen.rawBMPFile ?? 'Unknown platform version';//return "done"
    } on PlatformException {
      result = 'Failed ';
    }
    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
    if (!mounted) return;
    setState(() {
      _platformVersion = result;
      _capturedimage = Image.file(File("sss.bmp"),fit: BoxFit.contain,width: 640,key: UniqueKey(),);
    });
  }

  Future<void> capture() async{
    String result;
    // Platform messages may fail, so we use a try/catch PlatformException.
    // We also handle the message potentially returning null.
    try {
      result =
          await Wingetscreen.rawBMPFile ?? 'Unknown platform version';//return "done"
    } on PlatformException {
      result = 'Failed ';
    }

    print("capture()");
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Column(
          children:<Widget>[
            Text('TestPlugin'),
            //Spacer(),
            Text('message : $_platformVersion\n'),
            // ignore: unnecessary_null_comparison
            _capturedimage??Image.file(File("error.png"),fit: BoxFit.contain,width: 640,),
            ElevatedButton(
              onPressed: () async {
                capture();
                setState(()  {
                  print("setstate()");
                  _capturedimage = Image.file(File("sss.bmp"),fit: BoxFit.contain,width: 640);//please delete image cache
              });},
              child: Text('Button'),
              style: ElevatedButton.styleFrom(
                shadowColor: Colors.green,
                shape: RoundedRectangleBorder(
                  borderRadius: BorderRadius.circular(12),
                ),
              ),
            ),

          ],
        ),
      ),
    );
  }
}
1
likes
120
points
2
downloads

Publisher

unverified uploader

Weekly Downloads

flutter plugin for windows screen capture

Homepage

Documentation

API reference

License

unknown (license)

Dependencies

flutter

More

Packages that depend on wingetscreen

Packages that implement wingetscreen