-
Notifications
You must be signed in to change notification settings - Fork 227
/
snapshot_scene.dart
74 lines (66 loc) · 1.81 KB
/
snapshot_scene.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import 'package:arkit_plugin/arkit_plugin.dart';
import 'package:arkit_plugin_example/util/ar_helper.dart';
import 'package:flutter/material.dart';
class SnapshotScenePage extends StatefulWidget {
@override
_SnapshotScenePageState createState() => _SnapshotScenePageState();
}
class _SnapshotScenePageState extends State<SnapshotScenePage> {
late ARKitController arkitController;
@override
void dispose() {
arkitController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) => Scaffold(
appBar: AppBar(
title: const Text('Snapshot'),
),
floatingActionButton: FloatingActionButton(
child: Icon(Icons.camera_alt),
onPressed: () async {
try {
final image = await arkitController.snapshot();
await Navigator.push(
context,
MaterialPageRoute(
builder: (context) => SnapshotPreview(
imageProvider: image,
),
),
);
} catch (e) {
print(e);
}
},
),
body: Container(
child: ARKitSceneView(onARKitViewCreated: onARKitViewCreated),
));
void onARKitViewCreated(ARKitController arkitController) {
this.arkitController = arkitController;
this.arkitController.add(createSphere());
}
}
class SnapshotPreview extends StatelessWidget {
const SnapshotPreview({
Key? key,
required this.imageProvider,
}) : super(key: key);
final ImageProvider imageProvider;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Image Preview'),
),
body: Stack(
fit: StackFit.expand,
children: [
Image(image: imageProvider),
],
),
);
}
}