Panorama Viewer
A 360-degree panorama viewer.
This package is an updated porting of the plugin https://github.com/zesage/panorama.
Getting Started
Add panorama as a dependency in your pubspec.yaml file.
dependencies:
panorama_viewer: ^3.0.0
Import and add the Panorama Viewer widget to your project.
import 'package:panorama_viewer/panorama_viewer.dart';
... ...
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: PanoramaViewer(
child: Image.asset('assets/panorama360.jpg'),
),
),
);
}
Migration from panorama_viewer 2.x to 3.0.0
Version 3.0.0 uses dchs_motion_sensors ^3.0.0.
The PanoramaViewer, PanoramaController and SensorControl Dart APIs are unchanged.
- Flutter / Dart: upgrade to Flutter 3.47 or newer and Dart 3.13 or newer. Update your app's
environmentconstraints before runningflutter pub get. - Android: Kotlin 1.8 is no longer supported by the sensor plugin. Apps using AGP 8, or AGP 9 with built-in Kotlin disabled, must provide Kotlin Gradle Plugin 2.2.20 or newer with a compatible AGP / Gradle toolchain. The example uses AGP 9.1.1 and Gradle 9.3.1 with built-in Kotlin,
android.builtInKotlin=true,android.newDsl=false, and Java / Kotlin target 17. Remove the separatekotlin-androidplugin when using built-in Kotlin and configure targets throughkotlin.compilerOptions. Use JDK 17 or newer to run Gradle. - iOS: the dependency now uses Swift-only registration and supports Swift Package Manager. The sensor plugin declares iOS 13 as its minimum; this example targets iOS 15 with Flutter 3.47. For an older host, back up custom native changes and regenerate its Flutter integration with
flutter create --platforms=ios ., then review the diff and rebuild. Do not lower a higher deployment target already required by Flutter or another plugin. - Dependency constraints: remove old
dchs_motion_sensors/vector_mathoverrides or pins that conflict withdchs_motion_sensors ^3.0.0andvector_math ^2.4.3.
See the sensor plugin changelog for the upstream changes. Sensor control remains available on Android and iOS only.
The Android example declares org.jetbrains.kotlin.android version 2.4.20 with apply false in settings.gradle to align the compiler classpath with Flutter's requirements. It does not apply that plugin to the app when built-in Kotlin is enabled.
Migration from the Panorama package
- In the dependencies, use
panorama_viewerinstead ofpanorama. - In the Dart files where you use panorama, change the import to:
import 'package:panorama_viewer/panorama_viewer.dart';. - Change the widget name from
PanoramatoPanoramaViewer. - If you've used
SensorControl, changeSensorControl.OrientationtoSensorControl.orientation. All constant names are now in lower camel case, following the latest Dart best practices.
Web implementation
On the web, sensors are not utilized because the sensor library used is only compatible with iOS and Android devices. Additionally, on some Android devices, if the panoramic image is too large, nothing is displayed. When checking the console log remotely, you may encounter WebGL errors or warnings.