apptomate_custom_avatar 0.0.2
apptomate_custom_avatar: ^0.0.2 copied to clipboard
A highly customizable avatar widget with multiple display options and styling capabilities.
example/lib/main.dart
import 'package:apptomate_custom_avatar/apptomate_custom_avatar.dart';
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: MyHomePage(),
);
}
}
class MyHomePage extends StatelessWidget {
const MyHomePage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: Center(
child: Column(
children: [
CustomAvatar(
imageUrl: 'https://example.com/avatar.jpg',
size: 80,
borderColor: Colors.blue,
borderWidth: 2.0,
),
// Rounded square with badge
Padding(
padding: const EdgeInsets.symmetric(vertical: 16.0),
child: CustomAvatar(
initials: "JD",
size: 100,
shape: AvatarShape.roundedSquare,
borderRadius: 12.0,
//showBadge: true,
// badgeColor: Colors.green,
),
),
// With loading indicator
CustomAvatar(
imageUrl: 'https://example.com/large-avatar.jpg',
size: 120,
loadingBuilder: (context) => CircularProgressIndicator(
color: Colors.white,
),
),
// Example with all new features
Padding(
padding: EdgeInsets.symmetric(vertical: 16),
child: CustomAvatar(
imageUrl: 'https://avatars.githubusercontent.com/u/583231?v=4',
size: 100,
isNetworkImage: true,
backgroundColor: Colors.blue,
initials: "A",
onTap: () {
},
borderColor: Colors.black,
borderWidth: 2.0,
elevation: 5.0,
shape: AvatarShape.circle, // Try AvatarShape.roundedSquare
badgeColor: Colors.green,
badgePosition: BadgePosition.bottomRight,
showBadge: true,
loadingBuilder: (context) {
return CircularProgressIndicator(
color: Colors.grey,
);
},
),
),
const SizedBox(height: 20),
],
),
),
),
);
}
}