搜索插件、代码仓与 APP 分类

flutter_skeleton_ui 封面
插件详情v0.0.6

flutter_skeleton_ui

一个用于构建自定义骨架屏组件的 Flutter 包,可在加载时模拟页面布局。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
1.2万
喜欢数
43
Pub 分数
150

安装插件

flutter pub add flutter_skeleton_ui

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

flutter_skeleton_ui 是一个 Flutter 包,可让开发者在加载状态期间创建可自定义的骨架占位符 UI 元素。它模拟实际内容的布局,在数据完全加载之前展示页面结构,从而提供流畅的用户体验。该包支持多种控件,如卡片、列表和文本占位符,并提供动画和样式选项。非常适合提升感知性能并减少应用中的视觉卡顿。

适合场景

  • 加载屏幕占位符
  • 防止数据获取期间的布局偏移
  • 增强网络延迟期间的用户体验
  • 在原型中模拟内容结构
  • 提高感知的应用响应速度
  • 在各个屏幕之间创建一致的加载状态

主要特点

  • 可自定义的骨架形状
  • 内置的动态闪烁效果
  • 支持列表和网格布局
  • 与现有小部件的轻松集成
  • 可配置的颜色和尺寸
  • 响应式设计兼容性

适合对象

  • 寻求更好加载用户体验的开发者
  • 频繁获取数据的应用
  • 原型设计交互式用户界面
  • 注重视觉效果的团队
  • 前端聚焦的 Flutter 项目
  • 需要一致占位符设计的项目

使用建议

  • 可能会略微增加初始包大小
  • 需要手动设置复杂布局
  • 动画性能取决于设备
  • 不适用于静态内容
  • 超出基本样式的定制功能有限
  • 最好与适当的加载状态管理一起使用

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

Flutter Skeletons

Clone of skeletons

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

Installation

flutter pub add flutter_skeleton_ui

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:flutter_skeleton_ui/flutter_skeleton_ui.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.

所属分类

源码仓库

使用此插件的项目

暂无相关数据。