カテゴリー・パッケージ・リポジトリを検索

shimmer のカバー
パッケージ詳細v4.0.0

shimmer

パッケージは、Flutterプロジェクトにシャイマー効果を簡単に追加する方法を提供します

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
175万
いいね数
5460
Pub ポイント
160

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

flutter pub add shimmer

パッケージ概要

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

Shimmer は、UI コンポーネントにシャイマーのロード効果を簡単に追加できる Flutter パッケージです。滑らかでアニメーションされたプレースホルダーの外観を作成します。リスト、カード、または画像でのコンテンツ読み込み状態を模倣するのに最適であり、データ取得中のユーザー体験を向上させます。このパッケージは Android、iOS、Web、macOS、Windows、Linux といったすべての主要プラットフォームをサポートしており、デバイス間で一貫した動作を保証します。最小限のセットアップで、複雑なアニメーションを書くことなく、視覚的に魅力的なロードインジケーターを迅速に実装できます。

用途

  • リスト内のロードプレースホルダー
  • アニメーションカードのプレースホルダー
  • 画像ロードスケルトン
  • データ取得中のUXの改善
  • 動的コンテンツプレビュー

主な機能

  • シンプルなAPI統合
  • クロスプラットフォーム対応
  • カスタマイズ可能なシャイマー色
  • スムーズなアニメーション効果
  • 軽量でパフォーマンスに優れる

適している対象

  • ビジュアルの洗練を求めるUIデザイナー
  • 動的コンテンツ画面を開発する開発者
  • 頻繁にデータを読み込むアプリ
  • インタラクティブなインターフェースのプロトタイピング
  • 認識されるパフォーマンスの向上

注意事項

  • 静的コンテンツには適していません
  • ウィジェットツリー内での適切な配置が必要です
  • 過剰に使用するとパフォーマンスに影響する可能性があります
  • 基本的なスタイリングを超えるカスタマイズは限られている
  • 透明な背景と組み合わせて使用するのが最適です

元の README

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

Shimmer

pub package unit test codecov

A lightweight Flutter widget that paints a moving highlight over placeholder UI. Typical uses are skeleton screens while data loads, and a sliding highlight on a call to action.

Install

dependencies:
  shimmer: ^4.0.0
  material_ui: ^1.0.1

shimmer 4.0 uses Flutter's standalone material_ui package (Flutter 3.44+). Apps that still import package:flutter/material.dart can wrap those subtrees in MaterialUiCompatibilityBridge.

import 'package:material_ui/material_ui.dart';
import 'package:shimmer/shimmer.dart';

Usage

Skeleton placeholder

Shimmer.fromColors is the usual constructor. Build the child from solid shapes (Container, Row, Column). The gradient replaces those colors; transparent pixels stay transparent.

Shimmer.fromColors(
  baseColor: Colors.grey.shade300,
  highlightColor: Colors.grey.shade100,
  child: Column(
    children: [
      Container(height: 200, color: Colors.white),
      const SizedBox(height: 16),
      Container(height: 12, color: Colors.white),
      const SizedBox(height: 8),
      Container(height: 12, width: 200, color: Colors.white),
    ],
  ),
);

Dark theme:

Shimmer.fromColors(
  baseColor: Colors.grey.shade800,
  highlightColor: Colors.grey.shade600,
  child: placeholder,
);
Custom gradient

Use the default constructor when you need a RadialGradient, SweepGradient, or a LinearGradient that follows Theme.

Shimmer(
  gradient: LinearGradient(
    colors: [
      Theme.of(context).colorScheme.surfaceContainerHighest,
      Theme.of(context).colorScheme.surface,
      Theme.of(context).colorScheme.surfaceContainerHighest,
    ],
    stops: const [0.35, 0.5, 0.65],
  ),
  child: placeholder,
);
Direction, speed, and loops
Shimmer.fromColors(
  direction: ShimmerDirection.rtl,
  period: const Duration(milliseconds: 1200),
  loop: 0, // 0 = forever
  enabled: isLoading,
  baseColor: Colors.grey.shade300,
  highlightColor: Colors.grey.shade100,
  child: placeholder,
);
Parameter Default Role
child required Opaque area the highlight is blended onto
gradient required* Highlight colors (fromColors builds this for you)
direction ltr ltr, rtl, ttb, btt
period 1500ms Duration of one pass
loop 0 Passes before stopping; 0 repeats forever
enabled true false pauses the animation

*Required on Shimmer(...). Shimmer.fromColors takes baseColor and highlightColor instead.

Performance

  • Wrap a list of placeholders in one Shimmer, not one Shimmer per row.
  • Keep child simple and static. Fancy widgets (images, text with decoration, elevation) often look wrong because the shader replaces their colors.
  • Toggle enabled to false when loading finishes so the ticker stops.

Example

The example/ app shows a loading list and a “slide to unlock” highlight. From the repository root:

cd example && flutter run

How it works

Shimmer drives an AnimationController and paints a ShaderMaskLayer over the child (BlendMode.srcIn). The highlight rectangle is three times the child size so the band can travel fully across the widget.

Project internals, tests, and further optimization notes live in docs/overview.md and docs/optimization.md.

カテゴリー

依存関係

依存関係一覧 1 件

ソースリポジトリ

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

ランキング