avatar_maker 0.2.0
avatar_maker: ^0.2.0 copied to clipboard
A light-weight and highly customizable SVG avatar library for Flutter apps. Provides a Customizer Widget, CircleAvatar and other utility functions that are ready-to-use.
import "dart:math";
import "package:flutter/material.dart";
import "package:avatar_maker/avatar_maker.dart";
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Avatar Maker Demo',
debugShowCheckedModeBanner: false,
theme: ThemeData.light(),
// darkTheme: ThemeData.dark(),
home: MyHomePage(title: 'Avatar Maker'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key? key, this.title}) : super(key: key);
final String? title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title!),
centerTitle: true,
),
body: ListView(
physics: BouncingScrollPhysics(),
children: <Widget>[
SizedBox(
height: 25,
),
Padding(
padding: const EdgeInsets.all(16.0),
child: Text(
"Use your Avatar Maker anywhere\nwith the below widget",
style: TextStyle(fontWeight: FontWeight.w600, fontSize: 20),
textAlign: TextAlign.center,
),
),
SizedBox(
height: 25,
),
AvatarMakerAvatar(
backgroundColor: Colors.grey[200],
radius: 100,
),
SizedBox(
height: 25,
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
"and create your own page to customize them using our widgets",
style: TextStyle(fontWeight: FontWeight.w600, fontSize: 20),
textAlign: TextAlign.center,
),
),
SizedBox(
height: 50,
),
Row(
children: [
Spacer(flex: 2),
Expanded(
flex: 3,
child: Container(
height: 35,
child: ElevatedButton.icon(
icon: Icon(Icons.edit),
label: Text("Customize"),
onPressed: () => Navigator.push(context,
new MaterialPageRoute(builder: (context) => NewPage())),
),
),
),
Spacer(flex: 2),
],
),
SizedBox(
height: 100,
),
],
),
);
}
}
class NewPage extends StatelessWidget {
const NewPage({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
var _width = MediaQuery.of(context).size.width;
return Scaffold(
appBar: AppBar(),
body: Center(
child: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsets.symmetric(vertical: 30),
child: AvatarMakerAvatar(
radius: 100,
backgroundColor: Colors.grey[200],
),
),
SizedBox(
width: min(600, _width * 0.85),
child: Row(
children: [
Text(
"Customize:",
style: Theme.of(context).textTheme.titleLarge,
),
Spacer(),
AvatarMakerSaveWidget(),
AvatarMakerRandomWidget(),
AvatarMakerResetWidget(),
],
),
),
Padding(
padding:
const EdgeInsets.symmetric(horizontal: 8.0, vertical: 30),
child: AvatarMakerCustomizer(
scaffoldWidth: min(600, _width * 0.85),
autosave: false,
theme: AvatarMakerThemeData(
boxDecoration: BoxDecoration(boxShadow: [BoxShadow()])),
),
),
],
),
),
),
);
}
}