Skip to content

Commit

Permalink
Pending Fixes and Improvements #101
Browse files Browse the repository at this point in the history
  • Loading branch information
jogboms authored Aug 28, 2021
2 parents 54fbe6b + 3ec9c03 commit 71eb648
Show file tree
Hide file tree
Showing 34 changed files with 145 additions and 47 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@

A collection of loading indicators animated with flutter. Heavily inspired by @tobiasahlin's SpinKit.

## 5.1.0

- Renamed `SpinKitPouringHourglass` -> `SpinKitPouringHourGlass` for correctness
- Fix `SpinKitFoldingCube` animation
- Fix disposing of non-local animation controllers
- Introduced `strokeWidth` to pouring glass animation
- Introduced `SpinKitPouringHourGlassRefined`
- Introduced `SpinKitSpinningLines`
- Introduced `SpinKitPianoWave`
- Introduced `SpinKitDancingSquare`
- Introduced `SpinKitThreeInOut`

## 5.0.0

- Migrate to null safety
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ A collection of loading indicators animated with flutter. Heavily inspired by [@

```yaml
dependencies:
flutter_spinkit: ^5.0.0
flutter_spinkit: ^5.1.0
```
### ⚡️ Import
Expand Down
2 changes: 1 addition & 1 deletion example/lib/showcase.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class ShowCase extends StatelessWidget {
const SpinKitSpinningCircle(color: Colors.white, shape: BoxShape.rectangle),
const SpinKitFadingCircle(color: Colors.white),
const SpinKitHourGlass(color: Colors.white),
const SpinKitPouringHourglass(color: Colors.white),
const SpinKitPouringHourGlass(color: Colors.white),
const SpinKitPouringHourGlassRefined(color: Colors.white),
const SpinKitRipple(color: Colors.white),
const SpinKitDancingSquare(color: Colors.white),
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ packages:
path: ".."
relative: true
source: path
version: "5.0.0"
version: "5.1.0"
flutter_test:
dependency: "direct dev"
description: flutter
Expand Down
4 changes: 3 additions & 1 deletion lib/src/circle.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ class _SpinKitCircleState extends State<SpinKitCircle> with SingleTickerProvider

@override
void dispose() {
_controller.dispose();
if (widget.controller == null) {
_controller.dispose();
}
super.dispose();
}

Expand Down
4 changes: 3 additions & 1 deletion lib/src/cube_grid.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ class _SpinKitCubeGridState extends State<SpinKitCubeGrid> with SingleTickerProv

@override
void dispose() {
_controller.dispose();
if (widget.controller == null) {
_controller.dispose();
}
super.dispose();
}

Expand Down
4 changes: 3 additions & 1 deletion lib/src/dancing_square.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ class _SpinKitDancingSquareState extends State<SpinKitDancingSquare> with Single

@override
void dispose() {
_controller.dispose();
if (widget.controller == null) {
_controller.dispose();
}
super.dispose();
}

Expand Down
4 changes: 3 additions & 1 deletion lib/src/double_bounce.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ class _SpinKitDoubleBounceState extends State<SpinKitDoubleBounce> with SingleTi

@override
void dispose() {
_controller.dispose();
if (widget.controller == null) {
_controller.dispose();
}
super.dispose();
}

Expand Down
4 changes: 3 additions & 1 deletion lib/src/dual_ring.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ class _SpinKitDualRingState extends State<SpinKitDualRing> with SingleTickerProv

@override
void dispose() {
_controller.dispose();
if (widget.controller == null) {
_controller.dispose();
}
super.dispose();
}

Expand Down
4 changes: 3 additions & 1 deletion lib/src/fading_circle.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ class _SpinKitFadingCircleState extends State<SpinKitFadingCircle> with SingleTi

@override
void dispose() {
_controller.dispose();
if (widget.controller == null) {
_controller.dispose();
}
super.dispose();
}

Expand Down
4 changes: 3 additions & 1 deletion lib/src/fading_cube.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ class _SpinKitFadingCubeState extends State<SpinKitFadingCube> with SingleTicker

@override
void dispose() {
_controller.dispose();
if (widget.controller == null) {
_controller.dispose();
}
super.dispose();
}

Expand Down
4 changes: 3 additions & 1 deletion lib/src/fading_four.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ class _SpinKitFadingFourState extends State<SpinKitFadingFour> with SingleTicker

@override
void dispose() {
_controller.dispose();
if (widget.controller == null) {
_controller.dispose();
}
super.dispose();
}

Expand Down
4 changes: 3 additions & 1 deletion lib/src/fading_grid.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ class _SpinKitFadingGridState extends State<SpinKitFadingGrid> with SingleTicker

@override
void dispose() {
_controller.dispose();
if (widget.controller == null) {
_controller.dispose();
}
super.dispose();
}

Expand Down
11 changes: 7 additions & 4 deletions lib/src/folding_cube.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'dart:async';

import 'package:flutter/widgets.dart';

class SpinKitFoldingCube extends StatefulWidget {
Expand Down Expand Up @@ -99,10 +100,12 @@ class _SpinKitFoldingCubeState extends State<SpinKitFoldingCube> with TickerProv
_timer2.cancel();
_timer3.cancel();
_timer4.cancel();
_controller1.dispose();
_controller2.dispose();
_controller3.dispose();
_controller4.dispose();
if (widget.controller == null) {
_controller1.dispose();
_controller2.dispose();
_controller3.dispose();
_controller4.dispose();
}

super.dispose();
}
Expand Down
4 changes: 3 additions & 1 deletion lib/src/hour_glass.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ class _SpinKitHourGlassState extends State<SpinKitHourGlass> with SingleTickerPr

@override
void dispose() {
_controller.dispose();
if (widget.controller == null) {
_controller.dispose();
}
super.dispose();
}

Expand Down
4 changes: 3 additions & 1 deletion lib/src/piano_wave.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ class _SpinKitPianoWaveState extends State<SpinKitPianoWave> with SingleTickerPr

@override
void dispose() {
_controller.dispose();
if (widget.controller == null) {
_controller.dispose();
}
super.dispose();
}

Expand Down
20 changes: 13 additions & 7 deletions lib/src/pouring_hour_glass.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,27 @@ import 'dart:ui';

import 'package:flutter/widgets.dart';

class SpinKitPouringHourglass extends StatefulWidget {
const SpinKitPouringHourglass({
class SpinKitPouringHourGlass extends StatefulWidget {
const SpinKitPouringHourGlass({
Key? key,
required this.color,
this.size = 50.0,
this.duration = const Duration(milliseconds: 2400),
this.strokeWidth,
this.controller,
}) : super(key: key);

final double size;
final Color color;
final Duration duration;
final double? strokeWidth;
final AnimationController? controller;

@override
_SpinKitPouringHourglassState createState() => _SpinKitPouringHourglassState();
_SpinKitPouringHourGlassState createState() => _SpinKitPouringHourGlassState();
}

class _SpinKitPouringHourglassState extends State<SpinKitPouringHourglass> with SingleTickerProviderStateMixin {
class _SpinKitPouringHourGlassState extends State<SpinKitPouringHourGlass> with SingleTickerProviderStateMixin {
late AnimationController _controller;
late Animation<double> _pouringAnimation;
late Animation<double> _rotationAnimation;
Expand All @@ -41,7 +43,9 @@ class _SpinKitPouringHourglassState extends State<SpinKitPouringHourglass> with

@override
void dispose() {
_controller.dispose();
if (widget.controller == null) {
_controller.dispose();
}
super.dispose();
}

Expand All @@ -56,6 +60,7 @@ class _SpinKitPouringHourglassState extends State<SpinKitPouringHourglass> with
painter: _HourGlassPaint(
poured: _pouringAnimation.value,
color: widget.color,
strokeWidth: widget.strokeWidth,
),
),
),
Expand All @@ -65,14 +70,15 @@ class _SpinKitPouringHourglassState extends State<SpinKitPouringHourglass> with
}

class _HourGlassPaint extends CustomPainter {
_HourGlassPaint({this.poured, required Color color})
_HourGlassPaint({this.strokeWidth, this.poured, required Color color})
: _paint = Paint()
..style = PaintingStyle.stroke
..color = color,
_powderPaint = Paint()
..style = PaintingStyle.fill
..color = color;

final double? strokeWidth;
final double? poured;
final Paint _paint;
final Paint _powderPaint;
Expand All @@ -86,7 +92,7 @@ class _HourGlassPaint extends CustomPainter {
final yPadding = gapWidth / 2;
final top = yPadding;
final bottom = size.height - yPadding;
_paint.strokeWidth = gapWidth;
_paint.strokeWidth = strokeWidth ?? gapWidth;

final hourglassPath = Path()
..moveTo(centerX - hourglassWidth, top)
Expand Down
12 changes: 9 additions & 3 deletions lib/src/pouring_hour_glass_refined.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ class SpinKitPouringHourGlassRefined extends StatefulWidget {
required this.color,
this.size = 50.0,
this.duration = const Duration(milliseconds: 2400),
this.strokeWidth,
this.controller,
}) : super(key: key);

final double size;
final Color color;
final Duration duration;
final double? strokeWidth;
final AnimationController? controller;

@override
Expand Down Expand Up @@ -42,7 +44,9 @@ class _SpinKitPouringHourGlassRefinedState extends State<SpinKitPouringHourGlass

@override
void dispose() {
_controller.dispose();
if (widget.controller == null) {
_controller.dispose();
}
super.dispose();
}

Expand All @@ -57,6 +61,7 @@ class _SpinKitPouringHourGlassRefinedState extends State<SpinKitPouringHourGlass
painter: _HourGlassPaint(
poured: _pouringAnimation.value,
color: widget.color,
strokeWidth: widget.strokeWidth,
),
),
),
Expand All @@ -66,14 +71,15 @@ class _SpinKitPouringHourGlassRefinedState extends State<SpinKitPouringHourGlass
}

class _HourGlassPaint extends CustomPainter {
_HourGlassPaint({this.poured, required Color color})
_HourGlassPaint({this.strokeWidth, this.poured, required Color color})
: _paint = Paint()
..style = PaintingStyle.stroke
..color = color,
_powderPaint = Paint()
..style = PaintingStyle.fill
..color = color;

final double? strokeWidth;
final double? poured;
final Paint _paint;
final Paint _powderPaint;
Expand All @@ -87,7 +93,7 @@ class _HourGlassPaint extends CustomPainter {
final yPadding = gapWidth / 2;
final top = yPadding;
final bottom = size.height - yPadding;
_paint.strokeWidth = gapWidth;
_paint.strokeWidth = strokeWidth ?? gapWidth;

final hourglassPath = Path()
..moveTo(centerX - hourglassWidth + 2, top)
Expand Down
4 changes: 3 additions & 1 deletion lib/src/pulse.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ class _SpinKitPulseState extends State<SpinKitPulse> with SingleTickerProviderSt

@override
void dispose() {
_controller.dispose();
if (widget.controller == null) {
_controller.dispose();
}
super.dispose();
}

Expand Down
4 changes: 3 additions & 1 deletion lib/src/pumping_heart.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ class _SpinKitPumpingHeartState extends State<SpinKitPumpingHeart> with SingleTi

@override
void dispose() {
_controller.dispose();
if (widget.controller == null) {
_controller.dispose();
}
super.dispose();
}

Expand Down
4 changes: 3 additions & 1 deletion lib/src/ring.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ class _SpinKitRingState extends State<SpinKitRing> with SingleTickerProviderStat

@override
void dispose() {
_controller.dispose();
if (widget.controller == null) {
_controller.dispose();
}
super.dispose();
}

Expand Down
4 changes: 3 additions & 1 deletion lib/src/ripple.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ class _SpinKitRippleState extends State<SpinKitRipple> with SingleTickerProvider

@override
void dispose() {
_controller.dispose();
if (widget.controller == null) {
_controller.dispose();
}
super.dispose();
}

Expand Down
4 changes: 3 additions & 1 deletion lib/src/rotating_circle.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ class _SpinKitRotatingCircleState extends State<SpinKitRotatingCircle> with Sing

@override
void dispose() {
_controller.dispose();
if (widget.controller == null) {
_controller.dispose();
}
super.dispose();
}

Expand Down
4 changes: 3 additions & 1 deletion lib/src/rotating_plain.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ class _SpinKitRotatingPlainState extends State<SpinKitRotatingPlain> with Single

@override
void dispose() {
_controller.dispose();
if (widget.controller == null) {
_controller.dispose();
}
super.dispose();
}

Expand Down
Loading

0 comments on commit 71eb648

Please sign in to comment.