flutter_avatars_bottts 1.0.3 copy "flutter_avatars_bottts: ^1.0.3" to clipboard
flutter_avatars_bottts: ^1.0.3 copied to clipboard

Flutter Avatar - Bottts (high performance svg avatars rendering widget)

example/lib/main.dart

import 'package:BotttsExample/settings.dart';
import 'package:flutter/material.dart';
import 'package:flutter_avatars_bottts/flutter_avatars_bottts.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      themeMode: ThemeMode.dark,
      theme: ThemeData(
        primarySwatch: Colors.blue,
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  final Bottt sourceBot;

  MyHomePage({Key key, this.sourceBot}) : super(key: key);

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  Bottt _bottt;

  @override
  void initState() {
    super.initState();
    _initializeAvatar();
  }

  void _initializeAvatar() {
    //take from constructor parameter, otherwise use default values
    setState(() {
      if (widget.sourceBot != null) {
        _bottt = widget.sourceBot;
      } else {
        _bottt = Bottt(
          color: Colors.red,
          eye: EyeType.Glow,
          face: FaceType.Square03,
          mouth: MouthType.Bite,
          side: SideType.Round,
          texture: TextureType.Dirty01,
          top: TopType.Horns,
        );
      }
    });
  }

  void _randomizeAvatar() {
    setState(() {
      _bottt = Bottt.random();
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Flutter Avatars - Bottts'),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            CircleAvatar(
              radius: 90,
              child: CircleAvatar(
                radius: 85,
                backgroundColor: Color.fromARGB(255, 100, 100, 100),
                child: Padding(
                  padding: EdgeInsets.all(20),
                  child: BotttAvatar(_bottt),
                ),
              ),
            ),
            IconButton(
              iconSize: 48.0,
              icon: Icon(Icons.refresh),
              onPressed: _randomizeAvatar,
            ),
            IconButton(
              iconSize: 48.0,
              icon: Icon(Icons.settings),
              onPressed: () => Navigator.pushReplacement(
                context,
                MaterialPageRoute(builder: (context) {
                  return AvatarSettings(_bottt);
                }),
              ),
            ),
          ],
        ),
      ),
    );
  }
}
12
likes
30
points
26
downloads

Publisher

unverified uploader

Weekly Downloads

Flutter Avatar - Bottts (high performance svg avatars rendering widget)

Homepage
Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

flutter, flutter_svg, random_color

More

Packages that depend on flutter_avatars_bottts