camera_360 1.0.6 copy "camera_360: ^1.0.6" to clipboard
camera_360: ^1.0.6 copied to clipboard

This plugin allows the users to take 360 Panoramic Images using the phone's Camera. It uses OpenCV to stitch the images together.

example/lib/main.dart

import 'package:camera_360/camera_360.dart';
import 'package:flutter/material.dart';
import 'package:image_picker/image_picker.dart';
import 'package:gallery_saver/gallery_saver.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: Scaffold(
        appBar: AppBar(
          title: const Text('360 Camera App'),
        ),
        body: const CameraPage(),
      ),
    );
  }
}

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

  @override
  State<CameraPage> createState() => _CameraPageState();
}

class _CameraPageState extends State<CameraPage> {
  int progressPecentage = 0;

  @override
  Widget build(BuildContext context) {
    void displayPanoramaMessage(context, String message) {
      final snackBar = SnackBar(
        content: Text(message),
      );
      ScaffoldMessenger.of(context).showSnackBar(snackBar);
    }

    return Stack(
      children: [
        Camera360(
          // Text shown while panorama image is being prepared
          userLoadingText: "Preparing panorama...",
          // Text shown on while taking the first image
          userHelperText: "Point the camera at the dot",
          // Text shown when user should tilt the device to the left
          userHelperTiltLeftText: "Tilt left",
          // Text shown when user should tilt the device to the right
          userHelperTiltRightText: "Tilt Right",
          // Suggested key for iPhone >= 11 is 2 to select the wide-angle camera
          // On android devices 0 is suggested as at the moment Camera switching is not possible on android
          userSelectedCameraKey: 2,
          // Camera selector Visibilitiy
          cameraSelectorShow: true,
          // Camera selector Info Visibilitiy
          cameraSelectorInfoPopUpShow: true,
          // Camera selector Info Widget
          cameraSelectorInfoPopUpContent: const Column(
            children: [
              Padding(
                padding: EdgeInsets.only(bottom: 10),
                child: Text(
                  "Notice: This feature only works if your phone has a wide angle camera.",
                  textAlign: TextAlign.center,
                  style: TextStyle(
                    color: Color(0xffDB4A3C),
                  ),
                ),
              ),
              Text(
                "Select the camera with the widest viewing angle below.",
                textAlign: TextAlign.center,
                style: TextStyle(
                  color: Color(0xffEFEFEF),
                ),
              ),
            ],
          ),
          // Callback function called when 360 capture ended
          onCaptureEnded: (data) {
            if (data['success'] == true) {
              // Save image to the gallery
              XFile panorama = data['panorama'];
              GallerySaver.saveImage(panorama.path);
              displayPanoramaMessage(context, 'Panorama saved!');
            } else {
              displayPanoramaMessage(context, 'Panorama failed!');
            }
            print(data);
          },
          // Callback function called when the camera lens is changed
          onCameraChanged: (cameraKey) {
            displayPanoramaMessage(
                context, "Camera changed ${cameraKey.toString()}");
          },
          // Callback function called when capture progress is changed
          onProgressChanged: (newProgressPercentage) {
            debugPrint(
                "'Panorama360': Progress changed: $newProgressPercentage");
            setState(() {
              progressPecentage = newProgressPercentage;
            });
          },
        ),
        Column(
          mainAxisAlignment: MainAxisAlignment.start,
          children: [
            Text(
              "Progress: $progressPecentage",
              style: const TextStyle(
                  color: Colors.white, backgroundColor: Colors.black),
            )
          ],
        ),
      ],
    );
  }
}
15
likes
0
pub points
68%
popularity

Publisher

verified publishermax.al

This plugin allows the users to take 360 Panoramic Images using the phone's Camera. It uses OpenCV to stitch the images together.

Repository (GitHub)
View/report issues

Topics

#camera #panorama

License

unknown (license)

Dependencies

camera, dchs_motion_sensors, ffi, flutter, flutter_native_image, image_picker, path_provider, plugin_platform_interface, shared_preferences, vector_math, wakelock_plus

More

Packages that depend on camera_360