Skip to content

Commit 2608518

Browse files
FarazFaraz
authored andcommitted
fix controller refrence bug
1 parent 7c42349 commit 2608518

File tree

3 files changed

+77
-18
lines changed

3 files changed

+77
-18
lines changed

example/assets/business_woman.glb

32.7 MB
Binary file not shown.

example/ios/Podfile.lock

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
PODS:
2+
- Flutter (1.0.0)
3+
- webview_flutter_wkwebview (0.0.1):
4+
- Flutter
5+
6+
DEPENDENCIES:
7+
- Flutter (from `Flutter`)
8+
- webview_flutter_wkwebview (from `.symlinks/plugins/webview_flutter_wkwebview/ios`)
9+
10+
EXTERNAL SOURCES:
11+
Flutter:
12+
:path: Flutter
13+
webview_flutter_wkwebview:
14+
:path: ".symlinks/plugins/webview_flutter_wkwebview/ios"
15+
16+
SPEC CHECKSUMS:
17+
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
18+
webview_flutter_wkwebview: 2a23822e9039b7b1bc52e5add778e5d89ad488d1
19+
20+
PODFILE CHECKSUM: 819463e6a0290f5a72f145ba7cde16e8b6ef0796
21+
22+
COCOAPODS: 1.15.2

example/lib/main.dart

Lines changed: 55 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ class MyHomePage extends StatefulWidget {
3232

3333
class _MyHomePageState extends State<MyHomePage> {
3434
Flutter3DController controller = Flutter3DController();
35+
Flutter3DController controller2 = Flutter3DController();
36+
3537
String? chosenAnimation;
3638
String? chosenTexture;
3739

@@ -56,12 +58,24 @@ class _MyHomePageState extends State<MyHomePage> {
5658
floatingActionButton: Column(
5759
mainAxisAlignment: MainAxisAlignment.end,
5860
mainAxisSize: MainAxisSize.min,
61+
crossAxisAlignment: CrossAxisAlignment.end,
5962
children: [
60-
IconButton(
61-
onPressed: () {
62-
controller.playAnimation();
63-
},
64-
icon: const Icon(Icons.play_arrow),
63+
Row(
64+
mainAxisAlignment: MainAxisAlignment.end,
65+
children: [
66+
IconButton(
67+
onPressed: () {
68+
controller.playAnimation();
69+
},
70+
icon: const Icon(Icons.play_arrow),
71+
),
72+
IconButton(
73+
onPressed: () {
74+
controller2.playAnimation();
75+
},
76+
icon: const Icon(Icons.play_arrow_outlined),
77+
),
78+
],
6579
),
6680
const SizedBox(
6781
height: 4,
@@ -153,18 +167,8 @@ class _MyHomePageState extends State<MyHomePage> {
153167
children: [
154168
Flexible(
155169
flex: 1,
156-
child: Flutter3DViewer.obj(
157-
src: 'assets/flutter_dash.obj',
158-
//src: 'https://raw.githubusercontent.com/m-r-davari/content-holder/refs/heads/master/flutter_3d_controller/flutter_dash_model/flutter_dash.obj',
159-
scale: 5,
160-
// Initial scale of obj model
161-
cameraX: 0,
162-
// Initial cameraX position of obj model
163-
cameraY: 0,
164-
//Initial cameraY position of obj model
165-
cameraZ: 10,
166-
//Initial cameraZ position of obj model
167-
//This callBack will return the loading progress value between 0 and 1.0
170+
child: Flutter3DViewer(
171+
src: 'assets/sheen_chair.glb',
168172
onProgress: (double progressValue) {
169173
debugPrint('model loading progress : $progressValue');
170174
},
@@ -205,7 +209,40 @@ class _MyHomePageState extends State<MyHomePage> {
205209
//You can have full control of 3d model animations, textures and camera
206210
controller: controller,
207211
src:
208-
'assets/business_man.glb', //3D model with different animations
212+
'assets/business_man.glb', //3D model with different animations
213+
//src: 'assets/sheen_chair.glb', //3D model with different textures
214+
//src: 'https://modelviewer.dev/shared-assets/models/Astronaut.glb', // 3D model from URL
215+
),
216+
)
217+
,
218+
Flexible(
219+
flex: 1,
220+
child: Flutter3DViewer(
221+
//If you pass 'true' the flutter_3d_controller will add gesture interceptor layer
222+
//to prevent gesture recognizers from malfunctioning on iOS and some Android devices.
223+
// the default value is true
224+
activeGestureInterceptor: true,
225+
//If you don't pass progressBarColor, the color of defaultLoadingProgressBar will be grey.
226+
//You can set your custom color or use [Colors.transparent] for hiding loadingProgressBar.
227+
progressBarColor: Colors.orange,
228+
//You can disable viewer touch response by setting 'enableTouch' to 'false'
229+
enableTouch: true,
230+
//This callBack will return the loading progress value between 0 and 1.0
231+
onProgress: (double progressValue) {
232+
debugPrint('model loading progress : $progressValue');
233+
},
234+
//This callBack will call after model loaded successfully and will return model address
235+
onLoad: (String modelAddress) {
236+
debugPrint('model loaded : $modelAddress');
237+
},
238+
//this callBack will call when model failed to load and will return failure error
239+
onError: (String error) {
240+
debugPrint('model failed to load : $error');
241+
},
242+
//You can have full control of 3d model animations, textures and camera
243+
controller: controller2,
244+
src:
245+
'assets/business_woman.glb', //3D model with different animations
209246
//src: 'assets/sheen_chair.glb', //3D model with different textures
210247
//src: 'https://modelviewer.dev/shared-assets/models/Astronaut.glb', // 3D model from URL
211248
),

0 commit comments

Comments
 (0)