error_progress_button 0.2.1

error_progress_button #

A Flutter custom button with progress and error message by simply nesting two AnimatedCrossFade widgets and alternating between them.

Getting Started #

Usage #

To use this package add the dependency to your pubspec.yaml file.

  dependencies:
    flutter:
      sdk: flutter
    error_progress_button: 0.2.1

Example #

import 'dart:async';

import 'package:error_progress_button/error_progress_button.dart';
import 'package:flutter/material.dart';

class ExampleApp extends StatefulWidget {
  @override
  ExampleAppState createState() => ExampleAppState();
}

class ExampleAppState extends State<ExampleApp> {
  Text buttonText = Text(
    "Button",
    style: const TextStyle(
      color: Colors.white,
    ),
  );

  Text errorText = Text(
    "Failed with error",
    textAlign: TextAlign.center,
    style: const TextStyle(color: Colors.red, fontSize: 14),
  );

  ErrorButtonState state = ErrorButtonState.normal;

  Duration duration = Duration(milliseconds: 500);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: ErrorProgressButton(
          buttonColor: Colors.green,
          buttonText: buttonText,
          buttonOnPress: () => onButtonPress(),
          errorText: errorText,
          state: state,
        ),
      ),
    );
  }

  onButtonPress() async {
    setState(() {
      state = ErrorButtonState.loading;
    });
    Timer(const Duration(milliseconds: 4000), () {
      setState(() {
        state = ErrorButtonState.error;
      });
    });
  }
}

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

[0.1.0] - 20 June 2019

Simply using the flutter internal widget AnimatedCrossFade

[0.2.0] - 20 June 2019

Adding progress color property

[0.2.1] - 20 June 2019

fixing the progress color property type

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  error_progress_button: ^0.2.1

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:error_progress_button/error_progress_button.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
34
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
85
Overall:
Weighted score of the above. [more]
64
Learn more about scoring.

We analyzed this package on Aug 19, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.4.0
  • pana: 0.12.19
  • Flutter: 1.7.8+hotfix.4

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health suggestions

Fix lib/error_progress_button.dart. (-0.50 points)

Analysis of lib/error_progress_button.dart reported 1 hint:

line 4 col 7: This class (or a class which this class inherits from) is marked as '@immutable', but one or more of its instance fields are not final: ErrorProgressButton.buttonText, ErrorProgressButton.buttonColor, ErrorProgressButton.buttonOnPress, ErrorProgressButton.state, ErrorProgressButton.errorText, ErrorProgressButton.progressColor

Maintenance suggestions

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package.

Common filename patterns include main.dart, example.dart, and error_progress_button.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.

The package description is too short. (-5 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.6 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test