windows_native_camera 1.0.0+1
windows_native_camera: ^1.0.0+1 copied to clipboard
the simplest way to launch the native Windows Camera app directly from your Flutter app and instantly retrieve the captured photo path!
example/main.dart
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:windows_native_camera/windows_native_camera.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 filePath = "";
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Windows Camera Demo',
home: Scaffold(
appBar: AppBar(title: const Text('Capture Image')),
body: Column(
children: [
Center(
child: ElevatedButton(
onPressed: () async {
filePath = (await WindowsCameraTrigger.triggerCamera())!;
setState(() {});
if (filePath != null) {
debugPrint("Captured Image Path: $filePath");
} else {
debugPrint("No image captured.");
}
},
child: const Text("Open Windows Camera"),
),
),
Visibility(
visible: filePath != "",
child: Image.file(
File(filePath),
width: 500,
height: 500,
))
],
),
),
);
}
}