easy_camera_plus 0.0.6 copy "easy_camera_plus: ^0.0.6" to clipboard
easy_camera_plus: ^0.0.6 copied to clipboard

Easy custom camera plus

example/lib/main.dart

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

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

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

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Camera Easy Plus Demo',
      theme: ThemeData(
        primarySwatch: Colors.amber,
      ),
      home: const MyHomePage(title: 'Camera Easy Plus Demo'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key, required this.title}) : super(key: key);
  final String title;

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

class _MyHomePageState extends State<MyHomePage> {
  String? imagePath;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            if (imagePath != null) Image.asset(imagePath!),
            TextButton.icon(
              onPressed: () {
                Navigator.of(context)
                    .push(
                  MaterialPageRoute(
                    builder: (context) => const CameraScreen(),
                  ),
                )
                    .then((value) {
                  setState(() {
                    imagePath = value;
                  });
                });
              },
              icon: const Icon(Icons.photo_album),
              label: const Text('Take photo'),
            ),
            TextButton.icon(
              onPressed: () {
                Navigator.of(context).push(
                  MaterialPageRoute(
                    builder: (context) => const CameraScreen(),
                  ),
                );
              },
              icon: const Icon(Icons.video_camera_back_rounded),
              label: const Text('Record video'),
            ),
          ],
        ),
      ),
    );
  }
}