flutter_avataaar 0.1.9 copy "flutter_avataaar: ^0.1.9" to clipboard
flutter_avataaar: ^0.1.9 copied to clipboard

outdated

Fork of Flutter wrapper widget for Avataaars API allowing to generate and display avatar images.

example/lib/main.dart

import 'package:example/assets_loader.dart';
// ignore: implementation_imports
import 'package:flutter_avataaar/src/avataaar/avataaar_generator.dart';
import 'package:flutter/material.dart';
import 'package:flutter_avataaar/flutter_avataaar.dart';

void main() => runApp(const AvataaarExample());

class AvataaarExample extends StatefulWidget {
  const AvataaarExample({Key? key}) : super(key: key);

  @override
  State<AvataaarExample> createState() => _AvataaarExampleState();
}

class _AvataaarExampleState extends State<AvataaarExample> {
  final String baseUrl = 'https://avataaars.io';
  late Avataaar _avatar;

  @override
  void initState() {
    super.initState();
    _avatar = Avataaar.random(baseUrl: baseUrl);
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: SafeArea(
        child: Scaffold(
          appBar: AppBar(title: const Text('Avataaars'), centerTitle: true),
          body: Padding(
            padding: const EdgeInsets.all(16.0),
            child: Column(
              children: [
                Expanded(
                  child: FutureBuilder<Map<String, dynamic>>(
                    future: AssetsLoader().load(),
                    builder: (context, snapshot) {
                      if (snapshot.hasData) {
                        var data = snapshot.data!;
                        return AvataaarGenerator(
                          avataaar: _avatar,
                          onUpdateAvataaar: () => setState(() {}),
                          onTranslateKey: (p0) {
                            return data[p0] ?? 'unknown';
                          },
                        );
                      } else {
                        return CircularProgressIndicator();
                      }
                    },
                  ),
                ),
                IconButton(
                  iconSize: 48.0,
                  icon: const Icon(Icons.refresh),
                  onPressed: () => setState(
                      () => _avatar = Avataaar.random(baseUrl: baseUrl)),
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}
28
likes
0
pub points
38%
popularity

Publisher

verified publisherfj-anleo.es

Fork of Flutter wrapper widget for Avataaars API allowing to generate and display avatar images.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

cached_network_image, flutter, flutter_material_pickers, flutter_svg, http, universal_io, uuid

More

Packages that depend on flutter_avataaar