Skip to content
This repository was archived by the owner on Jun 16, 2024. It is now read-only.

Added Unsound null safety and Fix Flutter Warning #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 27
compileSdkVersion 28

lintOptions {
disable 'InvalidPackage'
Expand Down
2 changes: 2 additions & 0 deletions example/android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
28 changes: 14 additions & 14 deletions lib/button_stagger_animation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@ import 'package:flutter/material.dart';

class ButtonStaggerAnimation extends StatelessWidget {
// Animation fields
final AnimationController controller;
final controller;

// Display fields
final Color color;
final Color progressIndicatorColor;
final double progressIndicatorSize;
final BorderRadius borderRadius;
final Color? color;
final Color? progressIndicatorColor;
final double? progressIndicatorSize;
final BorderRadius? borderRadius;
final double strokeWidth;
final Function(AnimationController) onPressed;
final Widget child;
final Function(AnimationController)? onPressed;
final Widget? child;

ButtonStaggerAnimation({
Key key,
Key? key,
this.controller,
this.color,
this.progressIndicatorColor,
this.progressIndicatorSize,
this.borderRadius,
this.onPressed,
this.strokeWidth,
this.strokeWidth = 0.0,
this.child,
}) : super(key: key);

Expand All @@ -30,16 +30,16 @@ class ButtonStaggerAnimation extends StatelessWidget {
return LayoutBuilder(builder: _progressAnimatedBuilder);
}

Widget _buttonChild() {
if (controller.isAnimating) {
Widget? _buttonChild() {
if (controller!.isAnimating) {
return Container();
} else if (controller.isCompleted) {
} else if (controller!.isCompleted) {
return OverflowBox(
maxWidth: progressIndicatorSize,
maxHeight: progressIndicatorSize,
child: CircularProgressIndicator(
strokeWidth: strokeWidth,
valueColor: AlwaysStoppedAnimation<Color>(progressIndicatorColor),
valueColor: AlwaysStoppedAnimation<Color>(progressIndicatorColor!),
),
);
}
Expand Down Expand Up @@ -83,7 +83,7 @@ class ButtonStaggerAnimation extends StatelessWidget {
color: color,
child: _buttonChild(),
onPressed: () {
this.onPressed(controller);
this.onPressed!(controller);
},
),
);
Expand Down
9 changes: 5 additions & 4 deletions lib/progress_button.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
library progress_button;

import 'package:flutter/material.dart';
import 'package:progress_indicator_button/button_stagger_animation.dart';

import 'button_stagger_animation.dart';

class ProgressButton extends StatefulWidget {
/// The background color of the button.
Expand All @@ -21,9 +22,9 @@ class ProgressButton extends StatefulWidget {
///
/// This will grant access to its [AnimationController] so
/// that the animation can be controlled based on the need.
final Function(AnimationController) onPressed;
final Function(AnimationController)? onPressed;
/// The child to display on the button.
final Widget child;
final Widget? child;

ProgressButton({
@required this.child,
Expand All @@ -42,7 +43,7 @@ class ProgressButton extends StatefulWidget {

class _ProgressButtonState extends State<ProgressButton>
with TickerProviderStateMixin {
AnimationController _controller;
var _controller;

@override
void initState() {
Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: progress_indicator_button
description: A simple button which can transform and show a progress indicator.
version: 0.0.3
version: 0.0.4
author: Pascal Brosinski<[email protected]>
homepage: https://github.com/PascalAC/progress_button

environment:
sdk: ">=2.0.0-dev.68.0 <3.0.0"
sdk: ">=2.12.0 <3.0.0"

dependencies:
flutter:
Expand Down