Skip to content

Commit 825c037

Browse files
Merge pull request #52 from funwithflutter/develop
chore: update version
2 parents e680336 + c457f96 commit 825c037

File tree

10 files changed

+74
-41
lines changed

10 files changed

+74
-41
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/bin/bash
2+
3+
# Setup flutter
4+
FLUTTER=`which flutter`
5+
if [ $? -eq 0 ]
6+
then
7+
# Flutter is installed
8+
FLUTTER=`which flutter`
9+
else
10+
# Get flutter
11+
git clone https://github.com/flutter/flutter.git
12+
FLUTTER=flutter/bin/flutter
13+
fi
14+
15+
# Setup FVM
16+
FVM=`which fvm`
17+
if [ $? -eq 0 ]
18+
then
19+
# FVM is installed
20+
FVM=`which fvm`
21+
else
22+
# Get FVC
23+
echo "Getting fvm"
24+
$FLUTTER pub global activate fvm
25+
export PATH="$PATH":"$HOME/.pub-cache/bin"
26+
fi
27+
28+
29+
fvm install
30+
31+
fvm flutter pub get
32+
33+
cd example
34+
35+
fvm flutter build web
36+
37+
echo "OK"

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
## [0.6.0]
2+
🔄 Changed
3+
- Removed the random_color package and replaced with custom logic. Random colors may now be slightly different.
4+
- Updated dependencies
5+
6+
🐞 Fixed
7+
- Unmounted exception (https://github.com/funwithflutter/flutter_confetti/issues/36). Thanks Iiropel.
8+
- Moved `.super` call to the top of `initState`.
9+
110
## [0.6.0-nullsafety]
211
Now with null safety :) - Thanks Ali1Ammar!
312

example/lib/main.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class _MyAppState extends State<MyApp> {
3333

3434
@override
3535
void initState() {
36+
super.initState();
3637
_controllerCenter =
3738
ConfettiController(duration: const Duration(seconds: 10));
3839
_controllerCenterRight =
@@ -43,7 +44,6 @@ class _MyAppState extends State<MyApp> {
4344
ConfettiController(duration: const Duration(seconds: 10));
4445
_controllerBottomCenter =
4546
ConfettiController(duration: const Duration(seconds: 10));
46-
super.initState();
4747
}
4848

4949
@override

example/pubspec.lock

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ packages:
4949
path: ".."
5050
relative: true
5151
source: path
52-
version: "0.6.0-nullsafety"
52+
version: "0.6.0"
5353
cupertino_icons:
5454
dependency: "direct main"
5555
description:
@@ -95,13 +95,6 @@ packages:
9595
url: "https://pub.dartlang.org"
9696
source: hosted
9797
version: "1.8.0"
98-
random_color:
99-
dependency: transitive
100-
description:
101-
name: random_color
102-
url: "https://pub.dartlang.org"
103-
source: hosted
104-
version: "1.0.6-nullsafety"
10598
sky_engine:
10699
dependency: transitive
107100
description: flutter

lib/src/confetti.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ class _ConfettiWidgetState extends State<ConfettiWidget>
144144

145145
@override
146146
void initState() {
147+
super.initState();
147148
widget.confettiController.addListener(_handleChange);
148149

149150
_particleSystem = ParticleSystem(
@@ -163,7 +164,6 @@ class _ConfettiWidgetState extends State<ConfettiWidget>
163164
_particleSystem.addListener(_particleSystemListener);
164165

165166
_initAnimation();
166-
super.initState();
167167
}
168168

169169
void _initAnimation() {

lib/src/helper.dart

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
1-
import 'dart:math';
2-
import 'dart:ui' as ui;
1+
import 'dart:math' show Random;
2+
import 'dart:ui' show lerpDouble;
3+
4+
import 'package:flutter/material.dart';
35

46
final _rand = Random();
57

6-
double randomize(double min, double max) {
7-
return ui.lerpDouble(min, max, _rand.nextDouble())!;
8+
class Helper {
9+
static double randomize(double min, double max) {
10+
return lerpDouble(min, max, _rand.nextDouble())!;
11+
}
12+
13+
static Color randomColor() {
14+
return Colors.primaries[Random().nextInt(Colors.primaries.length)];
15+
}
816
}

lib/src/particle.dart

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import 'dart:math';
22
import 'dart:ui';
33

44
import 'package:flutter/material.dart';
5-
import 'package:random_color/random_color.dart';
65
import 'package:vector_math/vector_math.dart' as vmath;
76

87
import 'package:confetti/src/helper.dart';
@@ -179,7 +178,7 @@ class ParticleSystem extends ChangeNotifier {
179178
if (_blastDirectionality == BlastDirectionality.explosive) {
180179
blastDirection = _randomBlastDirection;
181180
}
182-
final blastRadius = randomize(_minBlastForce, _maxBlastForce);
181+
final blastRadius = Helper.randomize(_minBlastForce, _maxBlastForce);
183182
final y = blastRadius * sin(blastDirection);
184183
final x = blastRadius * cos(blastDirection);
185184
return vmath.Vector2(x, y);
@@ -193,13 +192,13 @@ class ParticleSystem extends ChangeNotifier {
193192
final index = _rand.nextInt(_colors!.length);
194193
return _colors![index];
195194
}
196-
return RandomColor().randomColor();
195+
return Helper.randomColor();
197196
}
198197

199198
Size _randomSize() {
200199
return Size(
201-
randomize(_minimumSize.width, _maximumSize.width),
202-
randomize(_minimumSize.height, _maximumSize.height),
200+
Helper.randomize(_minimumSize.width, _maximumSize.width),
201+
Helper.randomize(_minimumSize.height, _maximumSize.height),
203202
);
204203
}
205204
}
@@ -209,18 +208,19 @@ class Particle {
209208
double particleDrag, Path Function(Size size)? createParticlePath)
210209
: _startUpForce = startUpForce,
211210
_color = color,
212-
_mass = randomize(1, 11),
211+
_mass = Helper.randomize(1, 11),
213212
_particleDrag = particleDrag,
214213
_location = vmath.Vector2.zero(),
215214
_acceleration = vmath.Vector2.zero(),
216-
_velocity = vmath.Vector2(randomize(-3, 3), randomize(-3, 3)),
215+
_velocity =
216+
vmath.Vector2(Helper.randomize(-3, 3), Helper.randomize(-3, 3)),
217217
// _size = size,
218218
_pathShape = createParticlePath != null
219219
? createParticlePath(size)
220220
: createPath(size),
221-
_aVelocityX = randomize(-0.1, 0.1),
222-
_aVelocityY = randomize(-0.1, 0.1),
223-
_aVelocityZ = randomize(-0.1, 0.1),
221+
_aVelocityX = Helper.randomize(-0.1, 0.1),
222+
_aVelocityY = Helper.randomize(-0.1, 0.1),
223+
_aVelocityZ = Helper.randomize(-0.1, 0.1),
224224
_gravity = lerpDouble(0.1, 5, gravity);
225225

226226
final vmath.Vector2 _startUpForce;

melos.yaml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,7 @@ scripts:
1515
description: |
1616
Run `dart analyze` in all packages.
1717
- Note: you can also rely on your IDEs Dart Analysis / Issues window.
18-
firebase:emulator:
19-
run: |
20-
cd .github/workflows/scripts && ./start-firebase-emulator.sh
21-
description: |
22-
Start the Firebase emulator suite. Used by Functions, Firestore, Auth and Storage
23-
integration testing.
24-
- Requires Node.js and NPM installed.
18+
2519
format:
2620
run: dart pub global run flutter_plugin_tools format
2721
description: |

pubspec.lock

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,6 @@ packages:
9595
url: "https://pub.dartlang.org"
9696
source: hosted
9797
version: "1.8.0"
98-
random_color:
99-
dependency: "direct main"
100-
description:
101-
name: random_color
102-
url: "https://pub.dartlang.org"
103-
source: hosted
104-
version: "1.0.6-nullsafety"
10598
sky_engine:
10699
dependency: transitive
107100
description: flutter

pubspec.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: confetti
22
description: Blast colorful confetti all over the screen. Celebrate in app
33
achievements with style. Control the velocity, angle, gravity and amount of
44
confetti.
5-
version: 0.6.0-nullsafety
5+
version: 0.6.0
66
homepage: https://github.com/funwithflutter/flutter_confetti
77

88
environment:
@@ -11,8 +11,7 @@ environment:
1111
dependencies:
1212
flutter:
1313
sdk: flutter
14-
random_color: ^1.0.6-nullsafety
15-
vector_math: ^2.1.0-nullsafety.3
14+
vector_math: ^2.1.0
1615

1716
dev_dependencies:
1817
flutter_test:

0 commit comments

Comments
 (0)