搜尋套件、儲存庫與 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

所屬分類

原始碼儲存庫

使用此套件的專案

暫無相關資料。