Skip to content

Commit

Permalink
fix: safe area
Browse files Browse the repository at this point in the history
  • Loading branch information
Gordon Hayes committed Mar 6, 2021
1 parent 7e9452f commit 9fa2bed
Show file tree
Hide file tree
Showing 2 changed files with 122 additions and 120 deletions.
240 changes: 121 additions & 119 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -83,130 +83,132 @@ class _MyAppState extends State<MyApp> {

@override
Widget build(BuildContext context) {
return Stack(
children: <Widget>[
//CENTER -- Blast
Align(
alignment: Alignment.center,
child: ConfettiWidget(
confettiController: _controllerCenter,
blastDirectionality: BlastDirectionality
.explosive, // don't specify a direction, blast randomly
shouldLoop:
true, // start again as soon as the animation is finished
colors: const [
Colors.green,
Colors.blue,
Colors.pink,
Colors.orange,
Colors.purple
], // manually specify the colors to be used
createParticlePath: drawStar, // define a custom shape/path.
return SafeArea(
child: Stack(
children: <Widget>[
//CENTER -- Blast
Align(
alignment: Alignment.center,
child: ConfettiWidget(
confettiController: _controllerCenter,
blastDirectionality: BlastDirectionality
.explosive, // don't specify a direction, blast randomly
shouldLoop:
true, // start again as soon as the animation is finished
colors: const [
Colors.green,
Colors.blue,
Colors.pink,
Colors.orange,
Colors.purple
], // manually specify the colors to be used
createParticlePath: drawStar, // define a custom shape/path.
),
),
),
Align(
alignment: Alignment.center,
child: TextButton(
onPressed: () {
_controllerCenter.play();
},
child: _display('blast\nstars')),
),

//CENTER RIGHT -- Emit left
Align(
alignment: Alignment.centerRight,
child: ConfettiWidget(
confettiController: _controllerCenterRight,
blastDirection: pi, // radial value - LEFT
particleDrag: 0.05, // apply drag to the confetti
emissionFrequency: 0.05, // how often it should emit
numberOfParticles: 20, // number of particles to emit
gravity: 0.05, // gravity - or fall speed
shouldLoop: false,
colors: const [
Colors.green,
Colors.blue,
Colors.pink
], // manually specify the colors to be used
Align(
alignment: Alignment.center,
child: TextButton(
onPressed: () {
_controllerCenter.play();
},
child: _display('blast\nstars')),
),
),
Align(
alignment: Alignment.centerRight,
child: TextButton(
onPressed: () {
_controllerCenterRight.play();
},
child: _display('pump left')),
),

//CENTER LEFT - Emit right
Align(
alignment: Alignment.centerLeft,
child: ConfettiWidget(
confettiController: _controllerCenterLeft,
blastDirection: 0, // radial value - RIGHT
emissionFrequency: 0.6,
minimumSize: const Size(10,
10), // set the minimum potential size for the confetti (width, height)
maximumSize: const Size(50,
50), // set the maximum potential size for the confetti (width, height)
numberOfParticles: 1,
gravity: 0.1,

//CENTER RIGHT -- Emit left
Align(
alignment: Alignment.centerRight,
child: ConfettiWidget(
confettiController: _controllerCenterRight,
blastDirection: pi, // radial value - LEFT
particleDrag: 0.05, // apply drag to the confetti
emissionFrequency: 0.05, // how often it should emit
numberOfParticles: 20, // number of particles to emit
gravity: 0.05, // gravity - or fall speed
shouldLoop: false,
colors: const [
Colors.green,
Colors.blue,
Colors.pink
], // manually specify the colors to be used
),
),
Align(
alignment: Alignment.centerRight,
child: TextButton(
onPressed: () {
_controllerCenterRight.play();
},
child: _display('pump left')),
),

//CENTER LEFT - Emit right
Align(
alignment: Alignment.centerLeft,
child: ConfettiWidget(
confettiController: _controllerCenterLeft,
blastDirection: 0, // radial value - RIGHT
emissionFrequency: 0.6,
minimumSize: const Size(10,
10), // set the minimum potential size for the confetti (width, height)
maximumSize: const Size(50,
50), // set the maximum potential size for the confetti (width, height)
numberOfParticles: 1,
gravity: 0.1,
),
),
Align(
alignment: Alignment.centerLeft,
child: TextButton(
onPressed: () {
_controllerCenterLeft.play();
},
child: _display('singles')),
),

//TOP CENTER - shoot down
Align(
alignment: Alignment.topCenter,
child: ConfettiWidget(
confettiController: _controllerTopCenter,
blastDirection: pi / 2,
maxBlastForce: 5, // set a lower max blast force
minBlastForce: 2, // set a lower min blast force
emissionFrequency: 0.05,
numberOfParticles: 50, // a lot of particles at once
gravity: 1,
),
),
Align(
alignment: Alignment.topCenter,
child: TextButton(
onPressed: () {
_controllerTopCenter.play();
},
child: _display('goliath')),
),
),
Align(
alignment: Alignment.centerLeft,
child: TextButton(
onPressed: () {
_controllerCenterLeft.play();
},
child: _display('singles')),
),

//TOP CENTER - shoot down
Align(
alignment: Alignment.topCenter,
child: ConfettiWidget(
confettiController: _controllerTopCenter,
blastDirection: pi / 2,
maxBlastForce: 5, // set a lower max blast force
minBlastForce: 2, // set a lower min blast force
emissionFrequency: 0.05,
numberOfParticles: 50, // a lot of particles at once
gravity: 1,
//BOTTOM CENTER
Align(
alignment: Alignment.bottomCenter,
child: ConfettiWidget(
confettiController: _controllerBottomCenter,
blastDirection: -pi / 2,
emissionFrequency: 0.01,
numberOfParticles: 20,
maxBlastForce: 100,
minBlastForce: 80,
gravity: 0.3,
),
),
),
Align(
alignment: Alignment.topCenter,
child: TextButton(
onPressed: () {
_controllerTopCenter.play();
},
child: _display('goliath')),
),
//BOTTOM CENTER
Align(
alignment: Alignment.bottomCenter,
child: ConfettiWidget(
confettiController: _controllerBottomCenter,
blastDirection: -pi / 2,
emissionFrequency: 0.01,
numberOfParticles: 20,
maxBlastForce: 100,
minBlastForce: 80,
gravity: 0.3,
Align(
alignment: Alignment.bottomCenter,
child: TextButton(
onPressed: () {
_controllerBottomCenter.play();
},
child: _display('hard and infrequent')),
),
),
Align(
alignment: Alignment.bottomCenter,
child: TextButton(
onPressed: () {
_controllerBottomCenter.play();
},
child: _display('hard and infrequent')),
),
],
],
),
);
}

Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ dev_dependencies:
sdk: flutter

flutter:
uses-material-design: true
uses-material-design: true

0 comments on commit 9fa2bed

Please sign in to comment.