flutter_progress_button

flutter_progress_button 是一个免费开源(MIT 许可证)的 Material Flutter 按钮,支持各种按钮样式需求。它旨在易于使用且可定制。

flutter_progress_buttonX

开始

依赖它

将此添加到您的 package 的 pubspec.yaml 文件中

flutter_progress_button: '^0.6.2'

安装它

您可以从命令行安装包

$ flutter pub get

或者,您的编辑器可能支持 flutter pub get。

导入它

现在,在您的 Dart 代码中,您可以使用

import 'package:flutter_progress_button/flutter_progress_button.dart';

如何使用

ProgressButton 添加到您的 widget 树中

ProgressButton(
    normalWidget: const Text('I am a button'),
    progressWidget: const CircularProgressIndicator(),
    width: 196,
    height: 40,
    onPressed: () async {
        int score = await Future.delayed(
            const Duration(milliseconds: 3000), () => 42);
        // After [onPressed], it will trigger animation running backwards, from end to beginning
        return () {
        // Optional returns is returning a function that can be called
        // after the animation is stopped at the beginning.
        // A best practice would be to do time-consuming task in [onPressed],
        // and do page navigation in the returned function.
        // So that user won't missed out the reverse animation.
        };
    },
),

来源

该库的源代码和示例可在 git 上找到

$ git clone https://github.com/jiangyang5157/flutter_progress_button.git

GitHub

https://github.com/jiangyang5157/flutter_progress_button