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

A Flutter plugin for Apple's RoomPlan API that allows room scanning and USDZ export on iOS devices.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter_roomplan/flutter_roomplan.dart';

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

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

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

class _MyAppState extends State<MyApp> {
  final FlutterRoomplan flutterRoomplan = FlutterRoomplan();
  bool isSupported = false;
  bool isMultiRoomSupported = false;
  String? usdzFilePath;
  String? jsonFilePath;

  @override
  void initState() {
    super.initState();
    WidgetsBinding.instance.addPostFrameCallback((_) {
      _checkSupport();
    });
    flutterRoomplan.onRoomCaptureFinished(() async {
      debugPrint('Room scan completed');
      // Get the USDZ and JSON file paths after scan is complete
      final usdzPath = await flutterRoomplan.getUsdzFilePath();
      final jsonPath = await flutterRoomplan.getJsonFilePath();
      setState(() {
        usdzFilePath = usdzPath;
        jsonFilePath = jsonPath;
      });
    });
  }

  Future<void> _checkSupport() async {
    final isSupported = await flutterRoomplan.isSupported();
    final isMultiRoomSupported = await flutterRoomplan.isMultiRoomSupported();
    setState(() {
      this.isSupported = isSupported;
      this.isMultiRoomSupported = isMultiRoomSupported;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: const Text('RoomPlan Example')),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              if (isSupported)
                Padding(
                  padding: const EdgeInsets.all(16.0),
                  child: Column(
                    children: [
                      Text(
                        'RoomPlan: Supported ✅ (iOS 16.0+)',
                        style: TextStyle(color: Colors.green),
                        textAlign: TextAlign.center,
                      ),
                      const SizedBox(height: 8),
                      ElevatedButton(
                        onPressed: () {
                          flutterRoomplan.startScan();
                        },
                        child: Text('Start Room Scan'),
                      ),
                    ],
                  ),
                ),
              if (isMultiRoomSupported)
                Padding(
                  padding: const EdgeInsets.all(16.0),
                  child: Column(
                    children: [
                      Text(
                        'Multi-Room: Supported ✅ (iOS 17.0+)',
                        style: TextStyle(color: Colors.green),
                        textAlign: TextAlign.center,
                      ),
                      const SizedBox(height: 8),
                      ElevatedButton(
                        onPressed: () {
                          flutterRoomplan.startScan(enableMultiRoom: true);
                        },
                        child: Text('Start Multi-Room Scan'),
                      ),
                    ],
                  ),
                ),
              if (usdzFilePath != null)
                Padding(
                  padding: const EdgeInsets.all(16.0),
                  child: Text(
                    'Scanned USDZ file:\n$usdzFilePath',
                    textAlign: TextAlign.center,
                  ),
                ),
              if (jsonFilePath != null)
                Padding(
                  padding: const EdgeInsets.all(16.0),
                  child: Text(
                    'Scanned JSON file:\n$jsonFilePath',
                    textAlign: TextAlign.center,
                  ),
                ),
            ],
          ),
        ),
      ),
    );
  }
}
5
likes
0
points
186
downloads

Publisher

verified publisherstudykiya.in

Weekly Downloads

A Flutter plugin for Apple's RoomPlan API that allows room scanning and USDZ export on iOS devices.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on flutter_roomplan

Packages that implement flutter_roomplan