Trying to use GLB file in flutter

508 views Asked by At

I am Created a 3D model and exported the file in the extension .GLB I like to use that file in flutter is there any way to use.

And I have tried with this dependencies model_viewer_plus: ^1.5.0, babylon_dart 1.1.2 and babylonjs_viewer 1.2.1 this and not working.

1

There are 1 answers

4
Unknown Developer On

Try to use model_viewer package inorder to display 3D model in your app.

Try my code to give you an idea:

import 'package:flutter/material.dart';
import 'package:model_viewer/model_viewer.dart';

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: ModelViewer(
          src: 'assets/model.glb',
          alt: 'A 3D model',
          ar: true,
          autoPlay: true,
          preferredDevicePixelRatio: 1.0,
        ),
      ),
    );
  }
}