搜尋套件、儲存庫與 APP 分類

套件詳情v2.3.0

typeset

WhatsApp 風格的文字樣式給您!-- 粗體、斜體、底線等 -- 透過後端驅動您的文字樣式!

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
5310
喜歡數
108
Pub 分數
150

安裝套件

flutter pub add typeset

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

Typeset 是一個 Flutter 套件,可實現類似 WhatsApp 的豐富文字樣式,支援粗體、斜體、底線等。它允許開發者透過後端設定動態驅動文字格式化,非常適合訊息應用程式或內容導向介面。該套件在所有主要平台——Android、iOS、Web、macOS、Windows 和 Linux 上皆提供無縫支援,簡化樣式文字的實作,無需複雜的自訂元件。只需簡單的 pub add 命令即可輕鬆整合,並提供彈性且可擴展的樣式選項。

適用情境

  • 支援豐富文字的消息應用程式
  • 從後端動態呈現內容
  • 使用者產生的格式化文字
  • 社群媒體風格的文字顯示
  • 互動式教育應用

主要特色

  • 後端驅動的文字樣式
  • 支援粗體、斜體、底線
  • 跨平台相容性
  • 透過 pub 實現輕鬆整合
  • 最小化樣板程式碼
  • 即時樣式更新

適合對象

  • 開發聊天介面的開發者
  • 需要動態文字格式化的應用
  • 透過 API 管理內容的團隊
  • 需要在跨平台環境中保持一致的富文本的項目
  • 尋求輕量級樣式解決方案的前端開發人員

使用建議

  • 需要正確的後端結構來定義樣式
  • 可能需要對用戶輸入進行額外驗證
  • 未針對極大型文本塊進行優化
  • 僅限基本文字樣式(無進階排版)
  • 依賴於正確的 JSON 解析以應用樣式規則

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。


✨ TypeSet ✨

Powerful Text Styling for Flutter

style: very good analysis pub package pub points build status

Transform Your Text Experience

TypeSet brings WhatsApp, Telegram-like text styling to your Flutter apps with a powerful twist. Create rich, dynamic text experiences that can be driven by your backend or controlled directly in your UI.

With TypeSet, you can seamlessly integrate bold, italic, strikethrough, underlined text, monospace, hyperlinks, and even dynamic font sizing without complex widgets or convoluted styling code.

📱 See It In Action

TypeSet Widget TypeSetEditingController
TypeSet Widget TypeSetEditingController

Craft the perfect user experience with text styling that feels natural to your users. TypeSet makes it easy to implement rich text features that would otherwise require complex custom solutions.

🚀 Getting Started

Installation

Add TypeSet to your project by including it in your pubspec.yaml:

dependencies:
  typeset: ^2.3.0  # Check pub.dev for the latest version

Then run:

flutter pub get

💎 Usage

TypeSet is designed to be as simple as using Flutter's built-in Text widget:

import 'package:typeset/typeset.dart';

// Just drop in your formatted text
TypeSet('Hello *Flutter* developers!');
Text Formatting Syntax
Style Syntax Result
Bold *text* text
Italic _text_ text
Strikethrough ~text~ text
Underline #text# text
Monospace `text` text
Link §Link text|https://url§ Link text
Font Size text<size> Renders text at specified size
Advanced Examples
// Hyperlink with custom tap action
TypeSet(
  '§Visit Flutter\|https://flutter.dev§',
  linkRecognizerBuilder: (linkText, url) =>
    TapGestureRecognizer()..onTap = () {
      // Your custom action here
    },
);

// Dynamic font sizing
TypeSet('Regular text with *bigger<24>* words');

// Escape formatting characters
TypeSet('Use the ¦* symbol to show *asterisks*');

💬 Interactive Text Editing

TypeSetEditingController

New in v2.3.0! Add WhatsApp-like styling to your text input fields with real-time formatting preview:

import 'package:typeset/typeset.dart';
import 'package:flutter/material.dart';

// Create a controller with optional styling parameters
final controller = TypeSetEditingController(
  // Initial text with formatting
  text: 'This is *bold* and _italic_',
  // Style for the formatting markers
  markerColor: Colors.grey.shade400,
  // Style for links
  linkStyle: const TextStyle(color: Colors.blue),
  // Style for bold text
  boldStyle: const TextStyle(fontWeight: FontWeight.bold),
  // Style for monospace text
  monospaceStyle: const TextStyle(fontFamily: 'Courier'),
);

// Use it with a TextField
TextField(
  controller: controller,
  maxLines: 3,
  decoration: const InputDecoration(
    border: OutlineInputBorder(),
    hintText: 'Type formatted text here...',
  ),
);
Context Menu Integration

Add formatting options to the text selection context menu with getTypesetContextMenus():

import 'package:typeset/typeset.dart';
import 'package:flutter/material.dart';

TextField(
  controller: TypeSetEditingController(),
  contextMenuBuilder: (context, editableTextState) {
    return AdaptiveTextSelectionToolbar.buttonItems(
      anchors: editableTextState.contextMenuAnchors,
      buttonItems: [
        // Add TypeSet formatting options to the context menu
        ...getTypesetContextMenus(
          editableTextState: editableTextState,
          // Optional: specify which formatting options to include
          // styleTypes: [StyleTypeEnum.bold, StyleTypeEnum.italic],
        ),
        // Keep the default context menu items
        ...editableTextState.contextMenuButtonItems,
      ],
    );
  },
);

This adds formatting buttons (Bold, Italic, Strikethrough, etc.) to the text selection menu, allowing users to easily format selected text.

✨ Key Features

  • WhatsApp-like Formatting - Familiar syntax that users already understand
  • Backend-driven Styling - Update text formatting from your server without app updates
  • TypeSetEditingController - Add rich text capabilities to input fields
  • Dynamic Font Sizing - Adjust text size inline for emphasis or hierarchy
  • Context Menus - Built-in support for copy/paste with formatting
  • Highly Customizable - Style each formatting type independently
  • Lightweight - Minimal dependencies for a smaller app footprint
  • Well-tested - 95%+ test coverage for production reliability

🤝 Community & Support

Contributing

Contributions are welcome! Check out our contribution guidelines to get started.

Support the Project

If TypeSet has been helpful for your projects, consider:

  • ⭐ Starring the repository
  • 🔄 Sharing with other developers
  • 💬 Providing feedback and suggestions
  • 🐛 Reporting bugs and issues

📝 License

TypeSet is available under the Apache License, Version 2.0.


所屬分類

依賴

依賴清單 1 項

原始碼儲存庫

使用此套件的專案