builk_camera 0.0.3 copy "builk_camera: ^0.0.3" to clipboard
builk_camera: ^0.0.3 copied to clipboard

retractedoutdated

Camera widget ios and Android

example/lib/main.dart

import 'dart:io';

import 'package:builk_camera/controller/camera_view_controller.dart';
import 'package:builk_camera/widget/builk_camera.dart';
import 'package:flutter/material.dart';

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

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

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

class _MyAppState extends State<MyApp> {

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: PreviewImage(),
    );
  }
}

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

  @override
  _PreviewImageState createState() {
    return _PreviewImageState();
  }
}

class _PreviewImageState extends State<PreviewImage> {
  File? imagefile;

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

  @override
  void dispose() {
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Plugin example app'),
      ),
      body: Container(
        alignment: Alignment.center,
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            (imagefile != null)
                ? Container(
              alignment: Alignment.center,
              width: 200,
              child: Image.file(imagefile!),
            )
                : Container(
              alignment: Alignment.center,
              width: 200,
              child: Icon(Icons.image, size: 200),
            )
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () async {
          File file = await showDialog(
            context: context,
            builder: (context) {
              return CameraView(controller: CameraViewController());
            },
          );

          setState(() {
            imagefile = file;
          });
        },
        child: Icon(Icons.camera),
      ),
    );
  }
}