simple_camera 1.0.2 copy "simple_camera: ^1.0.2" to clipboard
simple_camera: ^1.0.2 copied to clipboard

outdated

Package for fast and easy use of the camera

example/lib/main.dart

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

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

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Simple Camera',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(title: 'Flutter Simple Camera Example'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  var simpleCamera = SimpleCamera();

  @override
  void initState() {
    super.initState();
    initSimpleCamera();
  }

  void initSimpleCamera() async {
    try {
      // Here you initialize the camera and pass some options, such as resolution, image format, etc..
      // If it does not inform any camera description, by default it starts with the front camera
      // To learn more, see the documentation.
      simpleCamera.initializeCamera();
    } catch (e) {
      // Important
      // Here you must give the permissions to access the device camera and or audio
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SafeArea(
        // Simple camera has a preview to view the camera image,
        //if you have questions about how it works, see the package example
        child: SimpleCameraPreview(
          simpleCamera: simpleCamera,
          onPressedTakePicture: (xfile) {
            // ignore: avoid_print
            print(xfile.name);
          },
        ),
      ),
    );
  }
}
5
likes
0
points
33
downloads

Publisher

unverified uploader

Weekly Downloads

Package for fast and easy use of the camera

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

camera_android, camera_avfoundation, camera_platform_interface, flutter

More

Packages that depend on simple_camera