搜索插件、代码仓与 APP 分类

flutter_boring_avatars 封面
插件详情v2.1.0

flutter_boring_avatars

无聊的头像可以根据用户名和颜色调色板生成唯一的头像。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
2480
喜欢数
54
Pub 分数
160

安装插件

flutter pub add flutter_boring_avatars

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

Flutter Boring Avatars 从用户名和颜色调色板生成唯一且视觉上 distinct 的头像。它提供了一种简单、可自定义的方法,无需依赖外部图像源即可在应用中显示个人资料图片。这些头像通过算法创建,确保唯一性和跨平台的一致性。非常适合聊天界面、用户资料或任何需要简洁、极简头像解决方案的应用程序。支持所有主要的 Flutter 平台,包括 Android、iOS、Web、macOS、Windows 和 Linux。

适合场景

  • 用户资料展示
  • 聊天界面
  • 匿名用户表示
  • 极简主义用户界面设计
  • 多用户仪表板

主要特点

  • 基于用户名的头像生成
  • 可自定义配色方案
  • 跨平台支持
  • 独特的头像图案
  • 轻量且易于集成

适合对象

  • 简单的个人资料图片需要
  • 用户众多的应用程序
  • 注重设计的应用程序
  • 低带宽环境
  • 原型设计和最小可行产品

使用建议

  • 除了颜色和用户名外,自定义选项有限
  • 不适用于品牌化身
  • 无内置图像回退
  • 依赖于确定性算法以确保唯一性

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

Github

flutter_boring_avatars

Pub Version (including pre-releases)

English | 中文

Features

Boring avatars can generate unique avatars based on the username and color palette.

This project is a Flutter implementation of Boring Avatars.

It differs from the original project in its implementation, using Canvas for rendering and adding transition animations.

Check out the Web Demo to experience the effect.

Screenshots

preview1.png

Installation

Add the dependency in your pubspec.yaml file:

dependencies:
  flutter_boring_avatars: any # or the latest version on Pub

Usage

Get a simple avatar

BoringAvatar(name: "Maria Mitchell", type: BoringAvatarType.marble);

Get an animated avatar that has a nice transition animation when the name changes

AnimatedBoringAvatar(
  name: "Maria Mitchell",
  type: BoringAvatarType.marble,
  duration: const Duration(milliseconds: 300),
)

Get an avatar with a custom color palette

final colorPalette = BoringAvatarPalette(Color(0xffA3A948), Color(0xffEDB92E), Color(0xffF85931), Color(0xffCE1836), Color(0xff009989));

BoringAvatar(name: "Maria Mitchell", palette: colorPalette);

Set default type and palette, applicable only for BoringAvatar and AnimatedBoringAvatar

build(context) {
  return DefaultBoringAvatarStyle(
    type: BoringAvatarType.marble, 
    palette: colorPalette,
    child: Column(
      children: [
        BoringAvatar(name: "Maria Mitchell"),
        BoringAvatar(name: "Alexis Brooks"),
        BoringAvatar(name: "Justin Gray"),
      ]
    ),
  );
}

Use ShapeBorder to control the avatar shape and add a border

BoringAvatar(
  name: "Maria Mitchell",
  type: BoringAvatarType.marble,
  shape: OvalBorder(), // or RoundedRectangleBorder(borderRadius: BorderRadius.circular(16))
);

Use the avatar for Decoration, it also supports transition animations when used in AnimatedContainer

Container(
  decoration: BoringAvatarDecoration(
    avatarData: BoringAvatarData.generate(name: name),
  ),
);

Export the avatar as an image

final avatarData = BoringAvatarData.generate(name: name);
final image = await avatarData.toImage(size: const Size.square(256));
final pngByteData = await image.toByteData(format: ImageByteFormat.png);

Thanks

Thanks to the developers of Boring Avatars.

The example uses the beautiful palette project from Matt DesLauriers.

If you like this project, please give me a star.

所属分类

源码仓库

使用此插件的项目

暂无相关数据。