パッケージ、リポジトリ、アプリカテゴリを検索

textstyle_extensions のカバー
パッケージ詳細v1.1.0

textstyle_extensions

TextStyle を簡単に編集するための構文的糖衣。.bold、.italic、.size() などの textStyle のバリエーションを迅速に作成できます。

30日間ダウンロード
2360
いいね数
22
Pub ポイント
40

パッケージをインストール

flutter pub add textstyle_extensions

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

TextStylesを簡単に変更するための構文シュガーを提供するFlutterパッケージです。.bold、.italic、.size()などの直感的な拡張メソッドを使用して、スタイリッシュなテキストバリアントを作成でき、テキストの外観をカスタマイズするプロセスを簡素化します。TextStyleにフラuentメソッドを拡張することで、コードの可読性を高め、ボイラープレートを削減します。UIが重視されるアプリケーションなど、頻繁にテキストスタイルを調整する必要があるプロジェクトに最適です。

用途

  • 太字または斜体スタイルをすばやく適用する
  • サイズ調整されたテキストバリアントを作成する
  • 繰り返しの TextStyle 変更を簡素化する
  • コンポーネント間のUIの一貫性を向上させる
  • テキストが多く含まれるウィジェットでのコードの可読性を向上させる

主な機能

  • TextStyle 用のフラuent拡張メソッド
  • .bold、.italic、.size() のサポート
  • テキストスタイルのボイラープレートを削減
  • コードの保守性を向上させる
  • 既存の TextStyle オブジェクトとの簡単な統合

適している対象

  • 豊富なテキストを使用するUI開発者
  • 頻繁なテキストスタイルのプロジェクト
  • 綺麗で読みやすいコードを重視するチーム
  • 動的なテキストフォーマットを備えた Flutter アプリ
  • 簡潔なテキスト操作を求める開発者

注意事項

  • 基本的な TextStyle 変更に限定
  • 拡張機能を超える高度なスタイルはサポートされていません
  • TextStyleの階層構造の理解が必要です
  • バンドルサイズがわずかに増加する可能性があります
  • 複雑なテキストレイアウトのシナリオには適していません

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

textstyle_extensions

Syntactic sugar for easily modifying TextStyles:

// Do this:
myTextStyle.bold.italic.size(16).letterSpace(1.6)

//Instead of this:
myTextStyle.copyWith(fontSize: 16, fontWeight: FontWeight.bold, fontStyle: FontStyle.italic, letterSpacing: 1.6,)

🔨 Installation

dependencies:
  textstyle_extensions: ^1.0.0
⚙ Import
import 'package:textstyle_extensions/textstyle_extensions.dart';

🕹️ Usage

The entire TextStyle API is represented, plus a convenience method for quick scaling:

Widget build(BuildContext context) {
  Text t(String v, TextStyle t) => Text(v, style: t);
  TextStyle style = TextStyle(fontSize: 12);
  return Center(
    child: Column(
      crossAxisAlignment: CrossAxisAlignment.center,
      children: <Widget>[
        t("Normal", style),
        t("Bigger", style.scale(1.1)),
        t("Smaller Bold / Italic / Clr", style.bold.italic.textColor(Colors.redAccent).size(10)),
        t("Weight", style.weight(FontWeight.w100)),
        t("Line Height", style.textHeight(2.5)),
        t("Word Spacing", style.wordSpace(5)),
        t("Letter Spacing", style.letterSpace(3)),
        t("Foreground Paint", style.textForeground(Paint()..color = Colors.orange)),
        t("Background Paint", style.textBackground(Paint()..color = Colors.orange)),
        t("Shadows", style.textShadows([Shadow(color: Colors.redAccent, blurRadius: 4)])),
        t(
          "Decoration",
          style.textDecoration(TextDecoration.underline,
              color: Colors.red, thickness: 4, style: TextDecorationStyle.dotted),
        ),
      ],
    ),
  );
}

Shortcut method names are introduced where it makes sense. This is done both for brevity, and to reduce conflicts with the underlying TextStyle properties.

🐞 Bugs/Requests

If you encounter any problems please open an issue. If you feel the library is missing a feature, please raise a ticket on Github and we'll look into it. Pull request are welcome.

📃 License

MIT License

カテゴリー

ソースリポジトリ

このパッケージを使用しているプロジェクト