-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #98 from funwithflutter/develop
feat: release 0.8.0
- Loading branch information
Showing
16 changed files
with
710 additions
and
217 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,45 @@ | ||
# This file tracks properties of this Flutter project. | ||
# Used by Flutter tool to assess capabilities and perform upgrades etc. | ||
# | ||
# This file should be version controlled and should not be manually edited. | ||
# This file should be version controlled. | ||
|
||
version: | ||
revision: ee032f67c734e607d8ea5c870ba744daf4bf56e7 | ||
channel: master | ||
revision: b8f7f1f9869bb2d116aa6a70dbeac61000b52849 | ||
channel: stable | ||
|
||
project_type: app | ||
|
||
# Tracks metadata for the flutter migrate command | ||
migration: | ||
platforms: | ||
- platform: root | ||
create_revision: b8f7f1f9869bb2d116aa6a70dbeac61000b52849 | ||
base_revision: b8f7f1f9869bb2d116aa6a70dbeac61000b52849 | ||
- platform: android | ||
create_revision: b8f7f1f9869bb2d116aa6a70dbeac61000b52849 | ||
base_revision: b8f7f1f9869bb2d116aa6a70dbeac61000b52849 | ||
- platform: ios | ||
create_revision: b8f7f1f9869bb2d116aa6a70dbeac61000b52849 | ||
base_revision: b8f7f1f9869bb2d116aa6a70dbeac61000b52849 | ||
- platform: linux | ||
create_revision: b8f7f1f9869bb2d116aa6a70dbeac61000b52849 | ||
base_revision: b8f7f1f9869bb2d116aa6a70dbeac61000b52849 | ||
- platform: macos | ||
create_revision: b8f7f1f9869bb2d116aa6a70dbeac61000b52849 | ||
base_revision: b8f7f1f9869bb2d116aa6a70dbeac61000b52849 | ||
- platform: web | ||
create_revision: b8f7f1f9869bb2d116aa6a70dbeac61000b52849 | ||
base_revision: b8f7f1f9869bb2d116aa6a70dbeac61000b52849 | ||
- platform: windows | ||
create_revision: b8f7f1f9869bb2d116aa6a70dbeac61000b52849 | ||
base_revision: b8f7f1f9869bb2d116aa6a70dbeac61000b52849 | ||
|
||
# User provided section | ||
|
||
# List of Local paths (relative to this file) that should be | ||
# ignored by the migrate tool. | ||
# | ||
# Files that are not part of the templates will be ignored by default. | ||
unmanaged_files: | ||
- 'lib/main.dart' | ||
- 'ios/Runner.xcodeproj/project.pbxproj' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
import 'dart:math'; | ||
|
||
import 'package:flutter/material.dart'; | ||
|
||
import 'package:confetti/confetti.dart'; | ||
|
||
void main() => runApp(const ConfettiPerformanceTestSample()); | ||
|
||
class ConfettiPerformanceTestSample extends StatelessWidget { | ||
const ConfettiPerformanceTestSample({Key? key}) : super(key: key); | ||
|
||
@override | ||
Widget build(BuildContext context) => MaterialApp( | ||
title: 'Confetti Performance Test', | ||
showPerformanceOverlay: true, | ||
home: Scaffold( | ||
backgroundColor: Colors.grey[900], | ||
body: MyApp(), | ||
), | ||
); | ||
} | ||
|
||
class MyApp extends StatefulWidget { | ||
@override | ||
_MyAppState createState() => _MyAppState(); | ||
} | ||
|
||
class _MyAppState extends State<MyApp> { | ||
late ConfettiController _confettiController; | ||
|
||
final ConfettiStats stats = ConfettiStats(); | ||
|
||
@override | ||
void initState() { | ||
super.initState(); | ||
_confettiController = ConfettiController( | ||
duration: const Duration(seconds: 10), | ||
|
||
/// The following can be used to retrieve stats on the particles. | ||
particleStatsCallback: (pStats) => stats.setStats(pStats), | ||
); | ||
} | ||
|
||
@override | ||
void dispose() { | ||
_confettiController.dispose(); | ||
super.dispose(); | ||
} | ||
|
||
/// A custom Path to paint stars. | ||
Path drawStar(Size size) { | ||
// Method to convert degrees to radians | ||
double degToRad(double deg) => deg * (pi / 180.0); | ||
|
||
const numberOfPoints = 5; | ||
final halfWidth = size.width / 2; | ||
final externalRadius = halfWidth; | ||
final internalRadius = halfWidth / 2.5; | ||
final degreesPerStep = degToRad(360 / numberOfPoints); | ||
final halfDegreesPerStep = degreesPerStep / 2; | ||
final path = Path(); | ||
final fullAngle = degToRad(360); | ||
path.moveTo(size.width, halfWidth); | ||
|
||
for (double step = 0; step < fullAngle; step += degreesPerStep) { | ||
path.lineTo(halfWidth + externalRadius * cos(step), | ||
halfWidth + externalRadius * sin(step)); | ||
path.lineTo(halfWidth + internalRadius * cos(step + halfDegreesPerStep), | ||
halfWidth + internalRadius * sin(step + halfDegreesPerStep)); | ||
} | ||
path.close(); | ||
return path; | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return SafeArea( | ||
child: Stack( | ||
children: <Widget>[ | ||
Align( | ||
alignment: Alignment.center, | ||
child: ConfettiWidget( | ||
emissionFrequency: 1, | ||
numberOfParticles: 100, | ||
confettiController: _confettiController, | ||
blastDirectionality: BlastDirectionality.explosive, | ||
shouldLoop: true, | ||
createParticlePath: drawStar, | ||
), | ||
), | ||
Align( | ||
alignment: Alignment.center, | ||
child: Row( | ||
mainAxisSize: MainAxisSize.min, | ||
children: [ | ||
TextButton( | ||
onPressed: () { | ||
_confettiController.play(); | ||
}, | ||
child: _text('start'), | ||
), | ||
TextButton( | ||
onPressed: () { | ||
_confettiController.stop(); | ||
}, | ||
child: _text('stop'), | ||
), | ||
TextButton( | ||
onPressed: () { | ||
_confettiController.dispose(); | ||
}, | ||
child: _text('dispose'), | ||
), | ||
], | ||
), | ||
), | ||
|
||
/// Display stats of confetti | ||
Align( | ||
alignment: Alignment.topCenter, | ||
child: AnimatedBuilder( | ||
animation: stats, | ||
builder: (context, _) => Column( | ||
children: [ | ||
Text( | ||
'Particles: ${stats.stats.numberOfParticles}', | ||
style: TextStyle(color: Colors.white, fontSize: 22), | ||
), | ||
Text( | ||
'Active Particles: ${stats.stats.activeNumberOfParticles}', | ||
style: TextStyle(color: Colors.white, fontSize: 22), | ||
), | ||
], | ||
), | ||
), | ||
), | ||
], | ||
), | ||
); | ||
} | ||
|
||
Text _text(String text) => Text( | ||
text, | ||
style: const TextStyle(color: Colors.white, fontSize: 20), | ||
); | ||
} | ||
|
||
/// Demonstration showing how to use the `particleStatsCallback` to retrieve | ||
/// [ParticleStats]. | ||
class ConfettiStats extends ChangeNotifier { | ||
ParticleStats stats; | ||
ConfettiStats() : stats = ParticleStats.empty(); | ||
|
||
void setStats(ParticleStats value) { | ||
stats = value; | ||
notifyListeners(); | ||
} | ||
} |
Oops, something went wrong.