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

skeletons 封面
套件詳情v0.0.3

skeletons

一個用於建立自訂骨架螢幕元件的 Flutter 套件,可在載入時模擬頁面佈局。

近 30 天下載
1320
喜歡數
343
Pub 分數
60

安裝套件

flutter pub add skeletons

套件介紹

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

skeletons 套件提供了一種在 Flutter 中建立自訂骨架載入元件的簡單方式,讓開發人員能在內容載入時模擬頁面佈局。它透過顯示反映最終 UI 的佔位結構來改善使用者體驗,減少感知載入時間。此套件輕巧且彈性,支援各種形狀與動畫的佔位符。非常適合複雜佈局的螢幕,確保從載入到內容顯示的順暢過渡。

適用情境

  • 加載畫面佔位符
  • 數據獲取期間的內容預覽
  • 提升感知效能
  • 複雜使用者介面佈局模擬
  • 入門畫面
  • 動態列表佔位符

主要特色

  • 可自定義的骨架形狀
  • 內建動畫支援
  • 與現有小部件的輕鬆整合
  • 靈活的佈局匹配
  • 輕量且高效
  • 支援嵌套骨架

適合對象

  • UI/UX 設計師
  • 前端開發人員
  • 載入大量資料的應用程式
  • 原型設計互動式螢幕
  • 需要流暢加載狀態的移動應用

使用建議

  • 僅限視覺佔位符
  • 無內建資料擷取
  • 需要手動佈局對齊
  • 不適合非視覺加載指示器
  • 依賴於準確的佈局預測

原始 README

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

Skeletons

A Flutter package for building custom skeleton widgets to mimic the page's layout while loading.

Examples

Items ListView (Default)
items paragraphs listview_default
ListView (Custom) ListView (Complex Cards) SkeletonTheme
listview_custom listview_cards skeleton_theme
Light/Dark modes Right-To-Left Custom Shimmer
light_dark_modes rtl custom_shimmer

All examples can be found here examples.

How To Use

Can be used by encapsulating the child widget in a Skeleton widget:

import 'package:skeletons/skeletons.dart';

Skeleton(
        isLoading: _isLoading,
        skeleton: SkeletonListView(),
        child: Container(child: Center(child: Text("Content"))),
      )

or directly:

Container(
    child: _isLoading 
    ? SkeletonListView() 
    : Container(child: Center(
                       child: Text("Content"))),
)

a SkeletonTheme can be used to set the default configs for all skeleton descendants in the tree.

SkeletonTheme(
    // themeMode: ThemeMode.light,
    shimmerGradient: LinearGradient(
        colors: [
          Color(0xFFD8E3E7),
          Color(0xFFC8D5DA),
          Color(0xFFD8E3E7),
        ],
        stops: [
          0.1,
          0.5,
          0.9,
        ],
      ),
      darkShimmerGradient: LinearGradient(
        colors: [
          Color(0xFF222222),
          Color(0xFF242424),
          Color(0xFF2B2B2B),
          Color(0xFF242424),
          Color(0xFF222222),
        ],
        stops: [
          0.0,
          0.2,
          0.5,
          0.8,
          1,
        ],
        begin: Alignment(-2.4, -0.2),
        end: Alignment(2.4, 0.2),
        tileMode: TileMode.clamp,
      ),
        child: MateriaApp(
            ...
        ),
      ),

More Customization:

ListView (Complex Cards)
listview_cards

for more complex shapes you can build your skeleton inside a SkeletonItem widget:

ListView.builder(
  physics: NeverScrollableScrollPhysics(),
  itemCount: 5,
  itemBuilder: (context, index) => Padding(
    padding: const EdgeInsets.all(8.0),
    child: Container(
      padding: const EdgeInsets.all(8.0),
      decoration: BoxDecoration(color: Colors.white),
      child: SkeletonItem(
          child: Column(
        children: [
          Row(
            children: [
              SkeletonAvatar(
                style: SkeletonAvatarStyle(
                    shape: BoxShape.circle, width: 50, height: 50),
              ),
              SizedBox(width: 8),
              Expanded(
                child: SkeletonParagraph(
                  style: SkeletonParagraphStyle(
                      lines: 3,
                      spacing: 6,
                      lineStyle: SkeletonLineStyle(
                        randomLength: true,
                        height: 10,
                        borderRadius: BorderRadius.circular(8),
                        minLength: MediaQuery.of(context).size.width / 6,
                        maxLength: MediaQuery.of(context).size.width / 3,
                      )),
                ),
              )
            ],
          ),
          SizedBox(height: 12),
          SkeletonParagraph(
            style: SkeletonParagraphStyle(
                lines: 3,
                spacing: 6,
                lineStyle: SkeletonLineStyle(
                  randomLength: true,
                  height: 10,
                  borderRadius: BorderRadius.circular(8),
                  minLength: MediaQuery.of(context).size.width / 2,
                )),
          ),
          SizedBox(height: 12),
          SkeletonAvatar(
            style: SkeletonAvatarStyle(
              width: double.infinity,
              minHeight: MediaQuery.of(context).size.height / 8,
              maxHeight: MediaQuery.of(context).size.height / 3,
            ),
          ),
          SizedBox(height: 8),
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              Row(
                children: [
                  SkeletonAvatar(
                      style: SkeletonAvatarStyle(width: 20, height: 20)),
                  SizedBox(width: 8),
                  SkeletonAvatar(
                      style: SkeletonAvatarStyle(width: 20, height: 20)),
                  SizedBox(width: 8),
                  SkeletonAvatar(
                      style: SkeletonAvatarStyle(width: 20, height: 20)),
                ],
              ),
              SkeletonLine(
                style: SkeletonLineStyle(
                    height: 16,
                    width: 64,
                    borderRadius: BorderRadius.circular(8)),
              )
            ],
          )
        ],
      )),
    ),
  ),
);

Issues and feedback

For issues, please report here. Contributions are welcome.

所屬分類

原始碼儲存庫

使用此套件的專案