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

flutter_richtext_composer 封面
插件详情v0.2.3

flutter_richtext_composer

一个用于以国际化友好方式组合富文本的 Flutter 包

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
149
喜欢数
7
Pub 分数
150

安装插件

flutter pub add flutter_richtext_composer

插件介绍

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

一个专为简化富文本创建而设计的 Flutter 包,支持国际化(i18n)。它使开发者能够以清晰、易读的方式组合具有多种样式、链接和表情符号的格式化文本,同时确保正确的本地化。该包可无缝集成到所有主要平台的 Flutter 应用中,非常适合动态内容,如通知、消息或指导性 UI。其 API 直观,专注于可维护性和可扩展性。

适合场景

  • 构建本地化聊天界面
  • 显示样式化用户生成内容
  • 创建多语言说明文本
  • 生成动态通知消息
  • 实现丰富格式的工具提示

主要特点

  • 友好的国际化富文本组合
  • 支持多种文本样式和链接
  • 与 Flutter 的 Text 小部件轻松集成
  • 跨平台兼容性
  • 简洁的声明式 API
  • 表情符号和特殊字符处理

适合对象

  • 开发多语言应用程序的开发者
  • 需要可维护的富文本逻辑的团队
  • 具有动态或用户生成内容的应用程序
  • 需要格式化文本和本地化的 UI
  • 强调可读性和可扩展性的项目

使用建议

  • 需要仔细处理翻译键
  • 可能会略微增加捆绑大小,尤其是格式化较多时
  • 仅限文本内容,不包括图片或复杂布局
  • 依赖于父应用程序中正确的国际化设置
  • 不适用于大规模高性能文本渲染

原始 README

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

flutter_richtext_composer

Latest version on pub.dev

A Flutter package for composing RichText in a i18n friendly way.

Getting Started

Import the library with

import 'package:flutter_richtext_composer/flutter_richtext_composer.dart';

Example

Then you can start composing RichText like this:

RichTextComposer(
  'Hi {name}, I am {my_name}! {icon}',
  style: TextStyle(fontSize: 30),
  placeholders: {
    'name': TextSpan(
          text: 'Son',
          style: TextStyle(fontWeight: FontWeight.bold),
    ),
    'my_name': TextSpan(
          text: 'Dad',
          style: TextStyle(
            color: Colors.red,
            decoration: TextDecoration.underline,
          ),
    ),
    'icon': WidgetSpan(
      child: GestureDetector(
        child: Icon(Icons.person),
        onTap: () {
          ScaffoldMessenger.of(context).showSnackBar(SnackBar(
            content: Text('Icon has been clicked'),
          ));
        },
      ),
    ),
  },
),

To escape the placeholder, prefix with \, e.g \{placeholder}:

RichTextComposer(
  'Hi \\{dad}, I am {batman}!',
  style: TextStyle(fontSize: 25),
  placeholders: {
    'batman': TextSpan(
          text: 'Batman',
          style: TextStyle(
            color: Colors.red,
            decoration: TextDecoration.underline,
          ),
    ),
  },
),

Example

所属分类

源码仓库

使用此插件的项目

暂无相关数据。