dotlottie_loader 0.0.5 copy "dotlottie_loader: ^0.0.5" to clipboard
dotlottie_loader: ^0.0.5 copied to clipboard

dotLottieLoader is a library to help downloading and deflating a .lottie file.

example/lib/main.dart

import 'package:dotlottie_loader/dotlottie_loader.dart';
import 'package:flutter/material.dart';
import 'package:lottie/lottie.dart';

/**
* library samples
* */
void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'DotLottieLoader Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key});

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text("DotLottie Loader"),
      ),
      body: SingleChildScrollView(
        child: Center(
          child: Column(
            children: [
              ///Simple .Lottie Animation
              DotLottieLoader.fromAsset("assets/animation.lottie",
                  frameBuilder: (ctx, dotlottie) {
                if (dotlottie != null) {
                  return Lottie.memory(dotlottie.animations.values.single);
                } else {
                  return Container();
                }
              }),
              const SizedBox(height: 20),

              ///.Lottie Animation From network
              DotLottieLoader.fromNetwork(
                "https://github.com/sartajroshan/dotlottieloader-flutter/raw/master/example/assets/animation.lottie",
                frameBuilder: (ctx, dotlottie) {
                  if (dotlottie != null) {
                    return Lottie.memory(
                      dotlottie.animations.values.single,
                    );
                  } else {
                    return Container();
                  }
                },
                errorBuilder: (ctx, e, s) {
                  return Text(e.toString());
                },
              ),
              const SizedBox(height: 20),

              ///.lottie animation with external image
              DotLottieLoader.fromAsset(
                  "assets/animation_external_image.lottie",
                  frameBuilder: (ctx, dotlottie) {
                if (dotlottie != null) {
                  return Lottie.memory(dotlottie.animations.values.single,
                      imageProviderFactory: (asset) {
                    return MemoryImage(dotlottie.images[asset.fileName]!);
                  });
                } else {
                  return Container();
                }
              }),
              const SizedBox(height: 20),

              ///.lottie animation with inline image
              DotLottieLoader.fromAsset("assets/animation_inline_image.lottie",
                  frameBuilder: (ctx, dotlottie) {
                if (dotlottie != null) {
                  return Lottie.memory(dotlottie.animations.values.single,
                      imageProviderFactory: (asset) {
                    return MemoryImage(dotlottie.images[asset.fileName]!);
                  });
                } else {
                  return Container();
                }
              }),
            ],
          ),
        ),
      ),
    );
  }
}
24
likes
140
points
4.93k
downloads

Publisher

verified publishersartajroshan.tech

Weekly Downloads

dotLottieLoader is a library to help downloading and deflating a .lottie file.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

archive, flutter

More

Packages that depend on dotlottie_loader