From 1ca84e60b87dfde1c709b517fc2ed26f8387df1d Mon Sep 17 00:00:00 2001 From: Abhishek Ghaskata Date: Fri, 21 May 2021 23:04:08 +0530 Subject: [PATCH] Refactor layers example (#83070) --- examples/layers/services/isolate.dart | 23 +++++++------------- examples/layers/widgets/spinning_square.dart | 20 ++++++----------- 2 files changed, 15 insertions(+), 28 deletions(-) diff --git a/examples/layers/services/isolate.dart b/examples/layers/services/isolate.dart index 255d098067..fbd32bddfd 100644 --- a/examples/layers/services/isolate.dart +++ b/examples/layers/services/isolate.dart @@ -210,21 +210,14 @@ class IsolateExampleState extends State with SingleTickerProvide String _label = 'Start'; String _result = ' '; double _progress = 0.0; - late AnimationController _animation; - late CalculationManager _calculationManager; - - @override - void initState() { - super.initState(); - _animation = AnimationController( - duration: const Duration(milliseconds: 3600), - vsync: this, - )..repeat(); - _calculationManager = CalculationManager( - onProgressListener: _handleProgressUpdate, - onResultListener: _handleResult, - ); - } + late final AnimationController _animation = AnimationController( + duration: const Duration(milliseconds: 3600), + vsync: this, + )..repeat(); + late final CalculationManager _calculationManager = CalculationManager( + onProgressListener: _handleProgressUpdate, + onResultListener: _handleResult, + ); @override void dispose() { diff --git a/examples/layers/widgets/spinning_square.dart b/examples/layers/widgets/spinning_square.dart index 4a3dfb1b9d..0033179768 100644 --- a/examples/layers/widgets/spinning_square.dart +++ b/examples/layers/widgets/spinning_square.dart @@ -12,19 +12,13 @@ class SpinningSquare extends StatefulWidget { } class _SpinningSquareState extends State with SingleTickerProviderStateMixin { - late AnimationController _animation; - - @override - void initState() { - super.initState(); - // We use 3600 milliseconds instead of 1800 milliseconds because 0.0 -> 1.0 - // represents an entire turn of the square whereas in the other examples - // we used 0.0 -> math.pi, which is only half a turn. - _animation = AnimationController( - duration: const Duration(milliseconds: 3600), - vsync: this, - )..repeat(); - } + // We use 3600 milliseconds instead of 1800 milliseconds because 0.0 -> 1.0 + // represents an entire turn of the square whereas in the other examples + // we used 0.0 -> math.pi, which is only half a turn. + late final AnimationController _animation = AnimationController( + duration: const Duration(milliseconds: 3600), + vsync: this, + )..repeat(); @override void dispose() {