model_viewer 0.3.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 81

3D Model Viewer for Flutter #

Project license Pub package Dartdoc reference Travis CI build status

This is a Flutter widget for rendering interactive 3D models in the glTF and GLB formats.

Prerequisites #

Installation #

dependencies:
  model_viewer: ^0.3.0

Examples #

Importing the library #

import 'package:model_viewer/model_viewer.dart';

Creating a ModelViewer widget #

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: Text("Model Viewer")),
        body: ModelViewer(
          src: 'https://modelviewer.dev/shared-assets/models/Astronaut.glb',
          alt: "A 3D model of an astronaut",
          ar: true,
          autoRotate: true,
          cameraControls: true,
        ),
      ),
    );
  }
}

Screenshot #

Screenshot of astronaut model

Changelog #

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.

example/lib/main.dart

/* This is free and unencumbered software released into the public domain. */

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

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: Text("Model Viewer")),
        body: ModelViewer(
          backgroundColor: Color.fromARGB(0xFF, 0xEE, 0xEE, 0xEE),
          src: 'https://modelviewer.dev/shared-assets/models/Astronaut.glb',
          alt: "A 3D model of an astronaut",
          ar: true,
          autoRotate: true,
          cameraControls: true,
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  model_viewer: ^0.3.0

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:model_viewer/model_viewer.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
62
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
81
Learn more about scoring.

We analyzed this package on Jul 11, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.14
  • Flutter: 1.17.5

Analysis suggestions

Package does not support Flutter platform linux

Because:

  • package:model_viewer/model_viewer.dart that imports:
  • package:model_viewer/src/model_viewer.dart that imports:
  • package:webview_flutter/webview_flutter.dart that declares support for platforms: android, ios

Package does not support Flutter platform macos

Because:

  • package:model_viewer/model_viewer.dart that imports:
  • package:model_viewer/src/model_viewer.dart that imports:
  • package:webview_flutter/webview_flutter.dart that declares support for platforms: android, ios

Package does not support Flutter platform web

Because:

  • package:model_viewer/model_viewer.dart that imports:
  • package:model_viewer/src/model_viewer.dart that imports:
  • package:webview_flutter/webview_flutter.dart that declares support for platforms: android, ios

Package does not support Flutter platform windows

Because:

  • package:model_viewer/model_viewer.dart that imports:
  • package:model_viewer/src/model_viewer.dart that imports:
  • package:webview_flutter/webview_flutter.dart that declares support for platforms: android, ios

Package not compatible with SDK dart

Because:

  • model_viewer that is a package requiring null.

Health suggestions

Format lib/src/html_builder.dart.

Run flutter format to format lib/src/html_builder.dart.

Format lib/src/model_viewer.dart.

Run flutter format to format lib/src/model_viewer.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.8.1 <3.0.0
flutter 0.0.0
webview_flutter ^0.3.22 0.3.22+1
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8 1.2.2
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8 2.1.0-nullsafety
Dev dependencies
flutter_test