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

loading_btn 封面
插件详情v1.0.3

loading_btn

一个动画加载按钮包,可让您创建具有多种自定义属性的精美加载按钮。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
308
喜欢数
28
Pub 分数
140

安装插件

flutter pub add loading_btn

插件介绍

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

loading_btn 是一个 Flutter 包,提供可自定义样式和行为的动画加载按钮。它使开发者能够创建在正常状态和加载状态之间平滑过渡的视觉上吸引人的按钮,非常适合需要用户反馈的表单或操作。通过广泛的自定义选项(包括颜色、形状、动画和文本),它提升了跨平台的用户体验。该包支持所有主要的 Flutter 平台,使其适用于跨平台应用。

适合场景

  • 表单提交
  • 用户身份验证流程
  • 数据获取操作
  • 交互式 UI 元素
  • 加载状态指示器

主要特点

  • 可自定义的动画持续时间
  • 支持多种加载样式
  • 可配置的按钮颜色和形状
  • 响应式设计支持
  • 与现有控件的轻松集成
  • 跨平台兼容性

适合对象

  • 开发交互式应用的开发者
  • 注重设计的UI实现
  • 需要明确加载反馈的应用程序
  • 注重用户体验的团队
  • 频繁表单交互的项目

使用建议

  • 可能需要额外的样式设置以实现复杂设计
  • 大量实例带来的性能影响
  • 有限的内置错误处理
  • 依赖外部动画库
  • 不适用于非交互式按钮用例

原始 README

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

Loading Btn

Create animated loading button using loading_btn package with lots of properties.

Getting started

Loading Btn package helps you create beautiful loading animation in your buttons with customized loader. Loading Btn is basically an ElevatedButton widget that means you can use the usual parameters with a few extra functionalities.

Demo

Usage

Loading Button with CircularProgress widget
LoadingBtn(
    height: 50,
    borderRadius: 8,
    animate: true,
    color: Colors.green,
    width: MediaQuery.of(context).size.width * 0.45,
    loader: Container(
        padding: const EdgeInsets.all(10),
        width: 40,
        height: 40,
        child: const CircularProgressIndicator(
            valueColor: AlwaysStoppedAnimation<Color>(Colors.white),
        ),
    ),
    child: const Text("Login"),
    onTap: (startLoading, stopLoading, btnState) async {
        if (btnState == ButtonState.idle) {
            startLoading();
            // call your network api
            await Future.delayed(const Duration(seconds: 5));
            stopLoading();
        }
    },
),
Loading Button with custom Text
LoadingBtn(
    height: 50,
    borderRadius: 8,
    roundLoadingShape: false,
    color: Colors.blueAccent,
    width: MediaQuery.of(context).size.width * 0.45,
    minWidth: MediaQuery.of(context).size.width * 0.30,
    loader: const Text("Loading..."),
    child: const Text("Login"),
    onTap: (startLoading, stopLoading, btnState) async {
        if (btnState == ButtonState.idle) {
            startLoading();
            // call your network api
            await Future.delayed(const Duration(seconds: 5));
            stopLoading();
        }
    },
),
Loading Button with custom loading
LoadingBtn(
    height: 50,
    borderRadius: 8,
    animate: true,
    color: Colors.deepOrange,
    width: MediaQuery.of(context).size.width * 0.45,
    loader: Container(
      padding: const EdgeInsets.all(10),
      child: const Center(
          child: SpinKitDoubleBounce(
            color: Colors.white,
          ),
      ),
    ),
    child: const Text("Login"),
    onTap: (startLoading, stopLoading, btnState) async {
        if (btnState == ButtonState.idle) {
            startLoading();
            // call your network api
            await Future.delayed(const Duration(seconds: 5));
            stopLoading();
        }
    },
),

Properties

  • animate(Default false) : It uses width to animate while click on button
  • roundLoadingShape(Default true) : It uses borderRadius to creates a round button while in Busy/Loading state
  • width : Width of the button when in Idle state
  • minWidth : Width of the button when in Busy/Loading state. Default value is equal to height in order to create a completely round loading button
  • borderRadius : Border Radius of the button
  • borderSide : BorderSide in order to give border color and width to the button
  • child : Contents of button when in Idle state
  • loader : Contents of button when in Busy/Loading state
  • onTap : (startLoading, stopLoading, btnState) : Function that is called when you click on the button
  • duration : Duration of the animation
  • curve : Curve of animation
  • reverseCurve : Curve of reverse animation

MIT License

Copyright (c) 2022 Yasin Mohammadi

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

所属分类

源码仓库

使用此插件的项目

暂无相关数据。