How to Use 3D Models in Flutter

Updated 19 March 2024

Save

In this blog, we will learn how to use 3D Models in Flutter.

You may want to visit our page dedicated to our Flutter app development.

Introduction:-

Three-dimensional (3D) models have three dimensions: depth, breadth, and length. They are used in many ways to improve user experience.

A 3D model is a digital representation in three dimensions of a necessary object, which can be fictional or actual. The creation of 3D models takes place with the help of special software for digital model.

A Flutter widget for displaying interactive 3D models in glTF and GLB formats. The widget utilizes Google’s model-viewer web component within a WebView for smooth rendering.

Implementation:-

Step 1: Add the dependencies

Now, run the command “flutter pub get” to add the dependencies.

To include the required package in your class, please add it using the appropriate method.

Step 1: AndroidManifiest.xml (Android 9+ only)

To use this widget on an Android device running version 9 or higher, your app must be permitted to establish an HTTP connection to http://localhost:XXXXX.

It’s worth noting that Android 9 (API level 28) has changed the default setting for android:usesCleartextTraffic from true to false.

To ensure proper functioning of your app, you must modify its AndroidManifest.xml file as shown below.

Step 3: app/build.gradle (Android only)

Change minSdkVersion to 21.

Step 4:Info.plist (iOS only)

To enable the widget on iOS, add a boolean property named “io.flutter.embedded_views_preview” to your app’s ios/Runner/Info.plist file with the value “YES”.

Step 5: Add the assets

assets:
– lib/assets/Astronaut.glb

Step 6:How to use ModelViewer Widget

Completed Code:-

Output:-

Conclusion:-

That’s it! You’ve successfully used 3d model in your Flutter app.

You can also check other blogs from here.

Thanks for reading this blog ❤️

Hope this blog helped you to better understand how to use 3D model In Flutter.

References:-

https://pub.dev/packages/model_viewer_plus

author
. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


Be the first to comment.

Start a Project


    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home