Centralize analysis options (#957)

pull/961/head
Brett Morgan 3 years ago committed by GitHub
parent bdf7ad36da
commit be34b0bf43
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,19 +1 @@
include: package:flutter_lints/flutter.yaml
analyzer:
strong-mode:
implicit-casts: false
implicit-dynamic: false
linter:
rules:
avoid_types_on_closure_parameters: true
avoid_void_async: true
cancel_subscriptions: true
close_sinks: true
directives_ordering: true
package_api_docs: true
package_prefixed_library_names: true
test_types_in_equals: true
throw_in_finally: true
unnecessary_statements: true
include: ../../../analysis_options.yaml

@ -1,19 +1 @@
include: package:flutter_lints/flutter.yaml
analyzer:
strong-mode:
implicit-casts: false
implicit-dynamic: false
linter:
rules:
avoid_types_on_closure_parameters: true
avoid_void_async: true
cancel_subscriptions: true
close_sinks: true
directives_ordering: true
package_api_docs: true
package_prefixed_library_names: true
test_types_in_equals: true
throw_in_finally: true
unnecessary_statements: true
include: ../../../analysis_options.yaml

@ -1,19 +1 @@
include: package:flutter_lints/flutter.yaml
analyzer:
strong-mode:
implicit-casts: false
implicit-dynamic: false
linter:
rules:
avoid_types_on_closure_parameters: true
avoid_void_async: true
cancel_subscriptions: true
close_sinks: true
directives_ordering: true
package_api_docs: true
package_prefixed_library_names: true
test_types_in_equals: true
throw_in_finally: true
unnecessary_statements: true
include: ../../../analysis_options.yaml

@ -1,19 +1 @@
include: package:flutter_lints/flutter.yaml
analyzer:
strong-mode:
implicit-casts: false
implicit-dynamic: false
linter:
rules:
avoid_types_on_closure_parameters: true
avoid_void_async: true
cancel_subscriptions: true
close_sinks: true
directives_ordering: true
package_api_docs: true
package_prefixed_library_names: true
test_types_in_equals: true
throw_in_finally: true
unnecessary_statements: true
include: ../../../analysis_options.yaml

@ -1,19 +1 @@
include: package:flutter_lints/flutter.yaml
analyzer:
strong-mode:
implicit-casts: false
implicit-dynamic: false
linter:
rules:
avoid_types_on_closure_parameters: true
avoid_void_async: true
cancel_subscriptions: true
close_sinks: true
directives_ordering: true
package_api_docs: true
package_prefixed_library_names: true
test_types_in_equals: true
throw_in_finally: true
unnecessary_statements: true
include: ../../../analysis_options.yaml

@ -1,19 +1 @@
include: package:flutter_lints/flutter.yaml
analyzer:
strong-mode:
implicit-casts: false
implicit-dynamic: false
linter:
rules:
avoid_types_on_closure_parameters: true
avoid_void_async: true
cancel_subscriptions: true
close_sinks: true
directives_ordering: true
package_api_docs: true
package_prefixed_library_names: true
test_types_in_equals: true
throw_in_finally: true
unnecessary_statements: true
include: ../../../analysis_options.yaml

@ -0,0 +1,19 @@
include: package:flutter_lints/flutter.yaml
analyzer:
strong-mode:
implicit-casts: false
implicit-dynamic: false
linter:
rules:
avoid_types_on_closure_parameters: true
avoid_void_async: true
cancel_subscriptions: true
close_sinks: true
directives_ordering: true
package_api_docs: true
package_prefixed_library_names: true
test_types_in_equals: true
throw_in_finally: true
unnecessary_statements: true

@ -1,19 +1 @@
include: package:flutter_lints/flutter.yaml
analyzer:
strong-mode:
implicit-casts: false
implicit-dynamic: false
linter:
rules:
avoid_types_on_closure_parameters: true
avoid_void_async: true
cancel_subscriptions: true
close_sinks: true
directives_ordering: true
package_api_docs: true
package_prefixed_library_names: true
test_types_in_equals: true
throw_in_finally: true
unnecessary_statements: true
include: ../analysis_options.yaml

@ -1,21 +1,6 @@
include: package:flutter_lints/flutter.yaml
analyzer:
strong-mode:
implicit-casts: false
implicit-dynamic: false
include: ../analysis_options.yaml
linter:
rules:
avoid_types_on_closure_parameters: true
avoid_void_async: true
cancel_subscriptions: true
close_sinks: true
directives_ordering: true
# Required because of the numbered sources in lib/src/basics
file_names: false
package_api_docs: true
package_prefixed_library_names: true
test_types_in_equals: true
throw_in_finally: true
unnecessary_statements: true

@ -1,19 +1 @@
include: package:flutter_lints/flutter.yaml
analyzer:
strong-mode:
implicit-casts: false
implicit-dynamic: false
linter:
rules:
avoid_types_on_closure_parameters: true
avoid_void_async: true
cancel_subscriptions: true
close_sinks: true
directives_ordering: true
package_api_docs: true
package_prefixed_library_names: true
test_types_in_equals: true
throw_in_finally: true
unnecessary_statements: true
include: ../../analysis_options.yaml

@ -1,19 +1 @@
include: package:flutter_lints/flutter.yaml
analyzer:
strong-mode:
implicit-casts: false
implicit-dynamic: false
linter:
rules:
avoid_types_on_closure_parameters: true
avoid_void_async: true
cancel_subscriptions: true
close_sinks: true
directives_ordering: true
package_api_docs: true
package_prefixed_library_names: true
test_types_in_equals: true
throw_in_finally: true
unnecessary_statements: true
include: ../../../analysis_options.yaml

@ -1,19 +1 @@
include: package:flutter_lints/flutter.yaml
analyzer:
strong-mode:
implicit-casts: false
implicit-dynamic: false
linter:
rules:
avoid_types_on_closure_parameters: true
avoid_void_async: true
cancel_subscriptions: true
close_sinks: true
directives_ordering: true
package_api_docs: true
package_prefixed_library_names: true
test_types_in_equals: true
throw_in_finally: true
unnecessary_statements: true
include: ../../../analysis_options.yaml

@ -1,19 +1 @@
include: package:flutter_lints/flutter.yaml
analyzer:
strong-mode:
implicit-casts: false
implicit-dynamic: false
linter:
rules:
avoid_types_on_closure_parameters: true
avoid_void_async: true
cancel_subscriptions: true
close_sinks: true
directives_ordering: true
package_api_docs: true
package_prefixed_library_names: true
test_types_in_equals: true
throw_in_finally: true
unnecessary_statements: true
include: ../../../analysis_options.yaml

@ -1,19 +1 @@
include: package:flutter_lints/flutter.yaml
analyzer:
strong-mode:
implicit-casts: false
implicit-dynamic: false
linter:
rules:
avoid_types_on_closure_parameters: true
avoid_void_async: true
cancel_subscriptions: true
close_sinks: true
directives_ordering: true
package_api_docs: true
package_prefixed_library_names: true
test_types_in_equals: true
throw_in_finally: true
unnecessary_statements: true
include: ../../../analysis_options.yaml

@ -1,19 +1 @@
include: package:flutter_lints/flutter.yaml
analyzer:
strong-mode:
implicit-casts: false
implicit-dynamic: false
linter:
rules:
avoid_types_on_closure_parameters: true
avoid_void_async: true
cancel_subscriptions: true
close_sinks: true
directives_ordering: true
package_api_docs: true
package_prefixed_library_names: true
test_types_in_equals: true
throw_in_finally: true
unnecessary_statements: true
include: ../../../analysis_options.yaml

@ -1,22 +1,6 @@
include: package:flutter_lints/flutter.yaml
include: ../../analysis_options.yaml
analyzer:
exclude:
- lib/model/rule.g.dart
- test/widget_test.mocks.dart
strong-mode:
implicit-casts: false
implicit-dynamic: false
linter:
rules:
avoid_types_on_closure_parameters: true
avoid_void_async: true
cancel_subscriptions: true
close_sinks: true
directives_ordering: true
package_api_docs: true
package_prefixed_library_names: true
test_types_in_equals: true
throw_in_finally: true
unnecessary_statements: true

@ -1,19 +1 @@
include: package:flutter_lints/flutter.yaml
analyzer:
strong-mode:
implicit-casts: false
implicit-dynamic: false
linter:
rules:
avoid_types_on_closure_parameters: true
avoid_void_async: true
cancel_subscriptions: true
close_sinks: true
directives_ordering: true
package_api_docs: true
package_prefixed_library_names: true
test_types_in_equals: true
throw_in_finally: true
unnecessary_statements: true
include: ../../analysis_options.yaml

@ -1,19 +1 @@
include: package:flutter_lints/flutter.yaml
analyzer:
strong-mode:
implicit-casts: false
implicit-dynamic: false
linter:
rules:
avoid_types_on_closure_parameters: true
avoid_void_async: true
cancel_subscriptions: true
close_sinks: true
directives_ordering: true
package_api_docs: true
package_prefixed_library_names: true
test_types_in_equals: true
throw_in_finally: true
unnecessary_statements: true
include: ../analysis_options.yaml

@ -1,19 +1 @@
include: package:flutter_lints/flutter.yaml
analyzer:
strong-mode:
implicit-casts: false
implicit-dynamic: false
linter:
rules:
avoid_types_on_closure_parameters: true
avoid_void_async: true
cancel_subscriptions: true
close_sinks: true
directives_ordering: true
package_api_docs: true
package_prefixed_library_names: true
test_types_in_equals: true
throw_in_finally: true
unnecessary_statements: true
include: ../analysis_options.yaml

@ -1,19 +1 @@
include: package:flutter_lints/flutter.yaml
analyzer:
strong-mode:
implicit-casts: false
implicit-dynamic: false
linter:
rules:
avoid_types_on_closure_parameters: true
avoid_void_async: true
cancel_subscriptions: true
close_sinks: true
directives_ordering: true
package_api_docs: true
package_prefixed_library_names: true
test_types_in_equals: true
throw_in_finally: true
unnecessary_statements: true
include: ../analysis_options.yaml

@ -1,19 +1 @@
include: package:flutter_lints/flutter.yaml
analyzer:
strong-mode:
implicit-casts: false
implicit-dynamic: false
linter:
rules:
avoid_types_on_closure_parameters: true
avoid_void_async: true
cancel_subscriptions: true
close_sinks: true
directives_ordering: true
package_api_docs: true
package_prefixed_library_names: true
test_types_in_equals: true
throw_in_finally: true
unnecessary_statements: true
include: ../analysis_options.yaml

@ -1,19 +1 @@
include: package:flutter_lints/flutter.yaml
analyzer:
strong-mode:
implicit-casts: false
implicit-dynamic: false
linter:
rules:
avoid_types_on_closure_parameters: true
avoid_void_async: true
cancel_subscriptions: true
close_sinks: true
directives_ordering: true
package_api_docs: true
package_prefixed_library_names: true
test_types_in_equals: true
throw_in_finally: true
unnecessary_statements: true
include: ../analysis_options.yaml

@ -1,22 +1,6 @@
include: package:flutter_lints/flutter.yaml
include: ../analysis_options.yaml
analyzer:
exclude:
- lib/json_serializable/*.g.dart
- lib/built_value/*.g.dart
strong-mode:
implicit-casts: false
implicit-dynamic: false
linter:
rules:
avoid_types_on_closure_parameters: true
avoid_void_async: true
cancel_subscriptions: true
close_sinks: true
directives_ordering: true
package_api_docs: true
package_prefixed_library_names: true
test_types_in_equals: true
throw_in_finally: true
unnecessary_statements: true

@ -1,19 +1 @@
include: package:flutter_lints/flutter.yaml
analyzer:
strong-mode:
implicit-casts: false
implicit-dynamic: false
linter:
rules:
avoid_types_on_closure_parameters: true
avoid_void_async: true
cancel_subscriptions: true
close_sinks: true
directives_ordering: true
package_api_docs: true
package_prefixed_library_names: true
test_types_in_equals: true
throw_in_finally: true
unnecessary_statements: true
include: ../analysis_options.yaml

@ -1,19 +1 @@
include: package:flutter_lints/flutter.yaml
analyzer:
strong-mode:
implicit-casts: false
implicit-dynamic: false
linter:
rules:
avoid_types_on_closure_parameters: true
avoid_void_async: true
cancel_subscriptions: true
close_sinks: true
directives_ordering: true
package_api_docs: true
package_prefixed_library_names: true
test_types_in_equals: true
throw_in_finally: true
unnecessary_statements: true
include: ../../analysis_options.yaml

@ -1,19 +1 @@
include: package:flutter_lints/flutter.yaml
analyzer:
strong-mode:
implicit-casts: false
implicit-dynamic: false
linter:
rules:
avoid_types_on_closure_parameters: true
avoid_void_async: true
cancel_subscriptions: true
close_sinks: true
directives_ordering: true
package_api_docs: true
package_prefixed_library_names: true
test_types_in_equals: true
throw_in_finally: true
unnecessary_statements: true
include: ../../analysis_options.yaml

@ -1,19 +1 @@
include: package:flutter_lints/flutter.yaml
analyzer:
strong-mode:
implicit-casts: false
implicit-dynamic: false
linter:
rules:
avoid_types_on_closure_parameters: true
avoid_void_async: true
cancel_subscriptions: true
close_sinks: true
directives_ordering: true
package_api_docs: true
package_prefixed_library_names: true
test_types_in_equals: true
throw_in_finally: true
unnecessary_statements: true
include: ../analysis_options.yaml

@ -1,19 +1 @@
include: package:flutter_lints/flutter.yaml
analyzer:
strong-mode:
implicit-casts: false
implicit-dynamic: false
linter:
rules:
avoid_types_on_closure_parameters: true
avoid_void_async: true
cancel_subscriptions: true
close_sinks: true
directives_ordering: true
package_api_docs: true
package_prefixed_library_names: true
test_types_in_equals: true
throw_in_finally: true
unnecessary_statements: true
include: ../analysis_options.yaml

@ -1,19 +1 @@
include: package:flutter_lints/flutter.yaml
analyzer:
strong-mode:
implicit-casts: false
implicit-dynamic: false
linter:
rules:
avoid_types_on_closure_parameters: true
avoid_void_async: true
cancel_subscriptions: true
close_sinks: true
directives_ordering: true
package_api_docs: true
package_prefixed_library_names: true
test_types_in_equals: true
throw_in_finally: true
unnecessary_statements: true
include: ../analysis_options.yaml

@ -1,19 +1 @@
include: package:flutter_lints/flutter.yaml
analyzer:
strong-mode:
implicit-casts: false
implicit-dynamic: false
linter:
rules:
avoid_types_on_closure_parameters: true
avoid_void_async: true
cancel_subscriptions: true
close_sinks: true
directives_ordering: true
package_api_docs: true
package_prefixed_library_names: true
test_types_in_equals: true
throw_in_finally: true
unnecessary_statements: true
include: ../analysis_options.yaml

@ -1,19 +1 @@
include: package:flutter_lints/flutter.yaml
analyzer:
strong-mode:
implicit-casts: false
implicit-dynamic: false
linter:
rules:
avoid_types_on_closure_parameters: true
avoid_void_async: true
cancel_subscriptions: true
close_sinks: true
directives_ordering: true
package_api_docs: true
package_prefixed_library_names: true
test_types_in_equals: true
throw_in_finally: true
unnecessary_statements: true
include: ../analysis_options.yaml

@ -1,19 +1 @@
include: package:flutter_lints/flutter.yaml
analyzer:
strong-mode:
implicit-casts: false
implicit-dynamic: false
linter:
rules:
avoid_types_on_closure_parameters: true
avoid_void_async: true
cancel_subscriptions: true
close_sinks: true
directives_ordering: true
package_api_docs: true
package_prefixed_library_names: true
test_types_in_equals: true
throw_in_finally: true
unnecessary_statements: true
include: ../analysis_options.yaml

@ -1,19 +1 @@
include: package:flutter_lints/flutter.yaml
analyzer:
strong-mode:
implicit-casts: false
implicit-dynamic: false
linter:
rules:
avoid_types_on_closure_parameters: true
avoid_void_async: true
cancel_subscriptions: true
close_sinks: true
directives_ordering: true
package_api_docs: true
package_prefixed_library_names: true
test_types_in_equals: true
throw_in_finally: true
unnecessary_statements: true
include: ../analysis_options.yaml

@ -1,19 +1 @@
include: package:flutter_lints/flutter.yaml
analyzer:
strong-mode:
implicit-casts: false
implicit-dynamic: false
linter:
rules:
avoid_types_on_closure_parameters: true
avoid_void_async: true
cancel_subscriptions: true
close_sinks: true
directives_ordering: true
package_api_docs: true
package_prefixed_library_names: true
test_types_in_equals: true
throw_in_finally: true
unnecessary_statements: true
include: ../analysis_options.yaml

@ -0,0 +1,11 @@
include: ../../analysis_options.yaml
analyzer:
strong-mode:
implicit-casts: true
implicit-dynamic: true
linter:
rules:
constant_identifier_names: false

@ -3,12 +3,14 @@ import 'dart:math';
import 'package:flutter/material.dart';
import 'package:particle_background/simple_animations_package.dart';
void main() => runApp(ParticleApp());
void main() => runApp(const ParticleApp());
class ParticleApp extends StatelessWidget {
const ParticleApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
return const MaterialApp(
home: Scaffold(
body: ParticleBackgroundPage(),
),
@ -17,10 +19,12 @@ class ParticleApp extends StatelessWidget {
}
class ParticleBackgroundPage extends StatelessWidget {
const ParticleBackgroundPage({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Stack(
children: [
children: const [
Positioned.fill(child: AnimatedBackground()),
Positioned.fill(child: Particles(30)),
Positioned.fill(child: CenteredText()),
@ -32,7 +36,7 @@ class ParticleBackgroundPage extends StatelessWidget {
class Particles extends StatefulWidget {
final int numberOfParticles;
Particles(this.numberOfParticles);
const Particles(this.numberOfParticles, {key}) : super(key: key);
@override
_ParticlesState createState() => _ParticlesState();
@ -54,7 +58,7 @@ class _ParticlesState extends State<Particles> {
@override
Widget build(BuildContext context) {
return Rendering(
startTime: Duration(seconds: 30),
startTime: const Duration(seconds: 30),
onTick: _simulateParticles,
builder: (context, time) {
return CustomPaint(
@ -65,14 +69,16 @@ class _ParticlesState extends State<Particles> {
}
_simulateParticles(Duration time) {
particles.forEach((particle) => particle.maintainRestart(time));
for (var particle in particles) {
particle.maintainRestart(time);
}
}
}
class ParticleModel {
Animatable tween;
double size;
AnimationProgress animationProgress;
late Animatable tween;
late double size;
late AnimationProgress animationProgress;
Random random;
ParticleModel(this.random) {
@ -113,13 +119,13 @@ class ParticlePainter extends CustomPainter {
void paint(Canvas canvas, Size size) {
final paint = Paint()..color = Colors.white.withAlpha(50);
particles.forEach((particle) {
for (var particle in particles) {
var progress = particle.animationProgress.progress(time);
final animation = particle.tween.transform(progress);
final position =
Offset(animation["x"] * size.width, animation["y"] * size.height);
canvas.drawCircle(position, size.width * 0.2 * particle.size, paint);
});
}
}
@override
@ -127,20 +133,24 @@ class ParticlePainter extends CustomPainter {
}
class AnimatedBackground extends StatelessWidget {
const AnimatedBackground({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
final tween = MultiTrackTween([
Track("color1").add(Duration(seconds: 3),
ColorTween(begin: Color(0xff8a113a), end: Colors.lightBlue.shade900)),
Track("color2").add(Duration(seconds: 3),
ColorTween(begin: Color(0xff440216), end: Colors.blue.shade600))
Track("color1").add(
const Duration(seconds: 3),
ColorTween(
begin: const Color(0xff8a113a), end: Colors.lightBlue.shade900)),
Track("color2").add(const Duration(seconds: 3),
ColorTween(begin: const Color(0xff440216), end: Colors.blue.shade600))
]);
return ControlledAnimation(
playback: Playback.MIRROR,
tween: tween,
duration: tween.duration,
builder: (context, animation) {
builder: (context, dynamic animation) {
return Container(
decoration: BoxDecoration(
gradient: LinearGradient(
@ -155,12 +165,12 @@ class AnimatedBackground extends StatelessWidget {
class CenteredText extends StatelessWidget {
const CenteredText({
Key key,
Key? key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Center(
return const Center(
child: Text(
"Welcome to Flutter for web",
style: TextStyle(color: Colors.white, fontWeight: FontWeight.w200),

@ -2,8 +2,9 @@
// https://pub.dev/packages/simple_animations
import 'dart:math';
import 'package:flutter/widgets.dart';
import 'package:flutter/scheduler.dart';
import 'package:flutter/widgets.dart';
/// Widget to easily create a continuous animation.
///
@ -22,16 +23,17 @@ import 'package:flutter/scheduler.dart';
/// [startTimeSimulationTicks] property.)
class Rendering extends StatefulWidget {
final Widget Function(BuildContext context, Duration timeElapsed) builder;
final Function(Duration timeElapsed) onTick;
final Function(Duration timeElapsed)? onTick;
final Duration startTime;
final int startTimeSimulationTicks;
Rendering(
{this.builder,
const Rendering(
{required this.builder,
this.onTick,
this.startTime = Duration.zero,
this.startTimeSimulationTicks = 20})
: assert(builder != null, "Builder needs to defined.");
this.startTimeSimulationTicks = 20,
Key? key})
: super(key: key);
@override
_RenderingState createState() => _RenderingState();
@ -39,8 +41,8 @@ class Rendering extends StatefulWidget {
class _RenderingState extends State<Rendering>
with SingleTickerProviderStateMixin {
Ticker _ticker;
Duration _timeElapsed = Duration(milliseconds: 0);
late Ticker _ticker;
Duration _timeElapsed = const Duration(milliseconds: 0);
@override
void initState() {
@ -57,7 +59,7 @@ class _RenderingState extends State<Rendering>
void _onRender(Duration effectiveElapsed) {
if (widget.onTick != null) {
widget.onTick(effectiveElapsed);
widget.onTick!(effectiveElapsed);
}
setState(() {
_timeElapsed = effectiveElapsed;
@ -66,14 +68,14 @@ class _RenderingState extends State<Rendering>
void _simulateStartTimeTicks() {
if (widget.onTick != null) {
Iterable.generate(widget.startTimeSimulationTicks + 1).forEach((i) {
for (var i in Iterable.generate(widget.startTimeSimulationTicks + 1)) {
final simulatedTime = Duration(
milliseconds: (widget.startTime.inMilliseconds *
i /
widget.startTimeSimulationTicks)
.round());
widget.onTick(simulatedTime);
});
widget.onTick!(simulatedTime);
}
}
}
@ -116,29 +118,28 @@ class _RenderingState extends State<Rendering>
/// );
/// ```
class MultiTrackTween extends Animatable<Map<String, dynamic>> {
final _tracksToTween = Map<String, _TweenData>();
final _tracksToTween = <String, _TweenData>{};
var _maxDuration = 0;
MultiTrackTween(List<Track> tracks)
: assert(tracks != null && tracks.length > 0,
"Add a List<Track> to configure the tween."),
assert(tracks.where((track) => track.items.length == 0).length == 0,
: assert(tracks.isNotEmpty, "Add a List<Track> to configure the tween."),
assert(tracks.where((track) => track.items.isEmpty).isEmpty,
"Each Track needs at least one added Tween by using the add()-method.") {
_computeMaxDuration(tracks);
_computeTrackTweens(tracks);
}
void _computeMaxDuration(List<Track> tracks) {
tracks.forEach((track) {
for (var track in tracks) {
final trackDuration = track.items
.map((item) => item.duration.inMilliseconds)
.reduce((sum, item) => sum + item);
_maxDuration = max(_maxDuration, trackDuration);
});
}
}
void _computeTrackTweens(List<Track> tracks) {
tracks.forEach((track) {
for (var track in tracks) {
final trackDuration = track.items
.map((item) => item.duration.inMilliseconds)
.reduce((sum, item) => sum + item);
@ -159,7 +160,7 @@ class MultiTrackTween extends Animatable<Map<String, dynamic>> {
_tracksToTween[track.name] =
_TweenData(tween: sequence, maxTime: trackDuration / _maxDuration);
});
}
}
/// Returns the highest duration specified by [Track]s.
@ -186,10 +187,10 @@ class MultiTrackTween extends Animatable<Map<String, dynamic>> {
@override
Map<String, dynamic> transform(double t) {
final Map<String, dynamic> result = Map();
final Map<String, dynamic> result = {};
_tracksToTween.forEach((name, tweenData) {
final double tTween = max(0, min(t, tweenData.maxTime - 0.0001));
result[name] = tweenData.tween.transform(tTween);
final double tTween = max(0, min(t, tweenData.maxTime! - 0.0001));
result[name] = tweenData.tween!.transform(tTween);
});
return result;
}
@ -200,7 +201,7 @@ class Track<T> {
final String name;
final List<_TrackItem> items = [];
Track(this.name) : assert(name != null, "Track name must not be null.");
Track(this.name);
/// Adds a "piece of animation" to a [Track].
///
@ -209,7 +210,7 @@ class Track<T> {
///
/// Optionally you can set a named parameter [curve] that applies an easing
/// curve to the tween.
Track<T> add(Duration duration, Animatable<T> tween, {Curve curve}) {
Track<T> add(Duration duration, Animatable<T> tween, {Curve? curve}) {
items.add(_TrackItem(duration, tween, curve: curve));
return this;
}
@ -217,11 +218,9 @@ class Track<T> {
class _TrackItem<T> {
final Duration duration;
Animatable<T> tween;
late Animatable<T> tween;
_TrackItem(this.duration, Animatable<T> _tween, {Curve curve})
: assert(duration != null, "Please set a duration."),
assert(_tween != null, "Please set a tween.") {
_TrackItem(this.duration, Animatable<T> _tween, {Curve? curve}) {
if (curve != null) {
tween = _tween.chain(CurveTween(curve: curve));
} else {
@ -231,8 +230,8 @@ class _TrackItem<T> {
}
class _TweenData<T> {
final Animatable<T> tween;
final double maxTime;
final Animatable<T>? tween;
final double? maxTime;
_TweenData({this.tween, this.maxTime});
}
@ -305,31 +304,27 @@ class ControlledAnimation<T> extends StatefulWidget {
final Animatable<T> tween;
final Curve curve;
final Duration duration;
final Duration delay;
final Widget Function(BuildContext buildContext, T animatedValue) builder;
final Widget Function(BuildContext, Widget child, T animatedValue)
final Duration? delay;
final Widget Function(BuildContext buildContext, T animatedValue)? builder;
final Widget Function(BuildContext, Widget? child, T animatedValue)?
builderWithChild;
final Widget child;
final AnimationStatusListener animationControllerStatusListener;
final Widget? child;
final AnimationStatusListener? animationControllerStatusListener;
final double startPosition;
ControlledAnimation(
const ControlledAnimation(
{this.playback = Playback.PLAY_FORWARD,
this.tween,
required this.tween,
this.curve = Curves.linear,
this.duration,
required this.duration,
this.delay,
this.builder,
this.builderWithChild,
this.child,
this.animationControllerStatusListener,
this.startPosition = 0.0,
Key key})
: assert(duration != null,
"Please set property duration. Example: Duration(milliseconds: 500)"),
assert(tween != null,
"Please set property tween. Example: Tween(from: 0.0, to: 100.0)"),
assert(
Key? key})
: assert(
(builderWithChild != null && child != null && builder == null) ||
(builder != null && builderWithChild == null && child == null),
"Either use just builder and keep buildWithChild and child null. "
@ -346,8 +341,8 @@ class ControlledAnimation<T> extends StatefulWidget {
class _ControlledAnimationState<T> extends State<ControlledAnimation>
with SingleTickerProviderStateMixin {
AnimationController _controller;
Animation<T> _animation;
late AnimationController _controller;
late Animation<T?> _animation;
bool _isDisposed = false;
bool _waitForDelay = true;
bool _isCurrentlyMirroring = false;
@ -362,19 +357,19 @@ class _ControlledAnimationState<T> extends State<ControlledAnimation>
_animation = widget.tween
.chain(CurveTween(curve: widget.curve))
.animate(_controller);
.animate(_controller) as Animation<T?>;
if (widget.animationControllerStatusListener != null) {
_controller.addStatusListener(widget.animationControllerStatusListener);
_controller.addStatusListener(widget.animationControllerStatusListener!);
}
initialize();
super.initState();
}
void initialize() async {
Future<void> initialize() async {
if (widget.delay != null) {
await Future.delayed(widget.delay);
await Future.delayed(widget.delay!);
}
_waitForDelay = false;
executeInstruction();
@ -387,7 +382,7 @@ class _ControlledAnimationState<T> extends State<ControlledAnimation>
super.didUpdateWidget(oldWidget);
}
void executeInstruction() async {
Future<void> executeInstruction() async {
if (_isDisposed || _waitForDelay) {
return;
}
@ -423,9 +418,9 @@ class _ControlledAnimationState<T> extends State<ControlledAnimation>
@override
Widget build(BuildContext context) {
if (widget.builder != null) {
return widget.builder(context, _animation.value);
return widget.builder!(context, _animation.value);
} else if (widget.builderWithChild != null && widget.child != null) {
return widget.builderWithChild(context, widget.child, _animation.value);
return widget.builderWithChild!(context, widget.child, _animation.value);
}
_controller.stop(canceled: true);
throw FlutterError(
@ -452,10 +447,7 @@ class AnimationProgress {
final Duration startTime;
/// Creates an [AnimationProgress].
AnimationProgress({this.duration, this.startTime})
: assert(duration != null, "Please specify an animation duration."),
assert(
startTime != null, "Please specify a start time of the animation.");
AnimationProgress({required this.duration, required this.startTime});
/// Queries the current progress value based on the specified [startTime] and
/// [duration] as a value between `0.0` and `1.0`. It will automatically

@ -20,6 +20,20 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
flutter_lints:
dependency: "direct main"
description:
name: flutter_lints
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.4"
lints:
dependency: transitive
description:
name: lints
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.1"
meta:
dependency: transitive
description:

@ -3,11 +3,12 @@ description: Example for the simple_animations package
homepage: https://github.com/felixblaschke/simple_animations
environment:
sdk: ">=2.2.0 <3.0.0"
sdk: '>=2.12.0 <3.0.0'
dependencies:
flutter:
sdk: flutter
flutter_lints: ^1.0.4
flutter:
assets:
- preview.png

Loading…
Cancel
Save