From 3b89876272690be2e222fbec2a44e30c0189a65a Mon Sep 17 00:00:00 2001 From: Akshay Sharma Date: Tue, 1 Jun 2021 16:20:45 +0530 Subject: [PATCH] Migrated To Null Safety --- example/ios/Flutter/Debug.xcconfig | 1 + example/ios/Flutter/Release.xcconfig | 1 + example/ios/Podfile | 41 ++++++++++ example/pubspec.lock | 97 +++++++++-------------- lib/src/clipper/clipper.dart | 8 +- lib/src/models.dart | 34 ++++---- lib/src/painter/painter.dart | 18 ++--- lib/src/painter/tools.dart | 8 +- lib/src/services/blob_animator.dart | 18 ++--- lib/src/services/blob_controller.dart | 8 +- lib/src/services/blob_error_handler.dart | 2 +- lib/src/services/blob_generator.dart | 48 ++++++------ lib/src/widgets/animated_blob.dart | 32 ++++---- lib/src/widgets/blob.dart | 60 +++++++------- lib/src/widgets/simple_blob.dart | 10 +-- pubspec.lock | 99 ++++++++---------------- pubspec.yaml | 2 +- 17 files changed, 237 insertions(+), 250 deletions(-) create mode 100644 example/ios/Podfile diff --git a/example/ios/Flutter/Debug.xcconfig b/example/ios/Flutter/Debug.xcconfig index 592ceee..ec97fc6 100644 --- a/example/ios/Flutter/Debug.xcconfig +++ b/example/ios/Flutter/Debug.xcconfig @@ -1 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" #include "Generated.xcconfig" diff --git a/example/ios/Flutter/Release.xcconfig b/example/ios/Flutter/Release.xcconfig index 592ceee..c4855bf 100644 --- a/example/ios/Flutter/Release.xcconfig +++ b/example/ios/Flutter/Release.xcconfig @@ -1 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" #include "Generated.xcconfig" diff --git a/example/ios/Podfile b/example/ios/Podfile new file mode 100644 index 0000000..1e8c3c9 --- /dev/null +++ b/example/ios/Podfile @@ -0,0 +1,41 @@ +# Uncomment this line to define a global platform for your project +# platform :ios, '9.0' + +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' + +project 'Runner', { + 'Debug' => :debug, + 'Profile' => :release, + 'Release' => :release, +} + +def flutter_root + generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) + unless File.exist?(generated_xcode_build_settings_path) + raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" + end + + File.foreach(generated_xcode_build_settings_path) do |line| + matches = line.match(/FLUTTER_ROOT\=(.*)/) + return matches[1].strip if matches + end + raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" +end + +require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) + +flutter_ios_podfile_setup + +target 'Runner' do + use_frameworks! + use_modular_headers! + + flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) +end + +post_install do |installer| + installer.pods_project.targets.each do |target| + flutter_additional_ios_build_settings(target) + end +end diff --git a/example/pubspec.lock b/example/pubspec.lock index c7e48f8..1b670e6 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -1,27 +1,13 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: - archive: - dependency: transitive - description: - name: archive - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.13" - args: - dependency: transitive - description: - name: args - url: "https://pub.dartlang.org" - source: hosted - version: "1.6.0" async: dependency: transitive description: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.4.1" + version: "2.6.1" blobs: dependency: "direct main" description: @@ -35,21 +21,35 @@ packages: name: boolean_selector url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.1.0" + characters: + dependency: transitive + description: + name: characters + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.1.3" + version: "1.2.0" + clock: + dependency: transitive + description: + name: clock + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.14.12" + version: "1.15.0" convert: dependency: transitive description: @@ -71,6 +71,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.1.3" + fake_async: + dependency: transitive + description: + name: fake_async + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.0" flutter: dependency: "direct main" description: flutter @@ -102,34 +109,27 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "3.1.4" - image: - dependency: transitive - description: - name: image - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.12" matcher: dependency: transitive description: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.6" + version: "0.12.10" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.1.8" + version: "1.3.0" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.6.4" + version: "1.8.0" path_provider: dependency: transitive description: @@ -158,13 +158,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.9.0" - petitparser: - dependency: transitive - description: - name: petitparser - url: "https://pub.dartlang.org" - source: hosted - version: "2.4.0" platform: dependency: transitive description: @@ -179,13 +172,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.0.2" - quiver: - dependency: transitive - description: - name: quiver - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.3" sky_engine: dependency: transitive description: flutter @@ -197,63 +183,56 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.7.0" + version: "1.8.1" stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.9.3" + version: "1.10.0" stream_channel: dependency: transitive description: name: stream_channel url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.1.0" string_scanner: dependency: transitive description: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.0.5" + version: "1.1.0" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.2.0" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.15" + version: "0.3.0" typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.1.6" + version: "1.3.0" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.0.8" - xml: - dependency: transitive - description: - name: xml - url: "https://pub.dartlang.org" - source: hosted - version: "3.6.1" + version: "2.1.0" sdks: - dart: ">=2.7.0 <3.0.0" - flutter: ">=1.17.0 <2.0.0" + dart: ">=2.12.0 <3.0.0" + flutter: ">=1.17.0" diff --git a/lib/src/clipper/clipper.dart b/lib/src/clipper/clipper.dart index 81c184a..4a0b092 100644 --- a/lib/src/clipper/clipper.dart +++ b/lib/src/clipper/clipper.dart @@ -4,13 +4,13 @@ import 'package:blobs/src/services/blob_generator.dart'; import 'package:flutter/material.dart'; class BlobClipper extends CustomClipper { - final String id; + final String? id; final int edgesCount; final int minGrowth; BlobClipper({ this.id, - this.edgesCount = BlobConfig.edgesCount, - this.minGrowth = BlobConfig.minGrowth, + this.edgesCount = BlobConfig.edgesCount as int, + this.minGrowth = BlobConfig.minGrowth as int, }); @override @@ -21,7 +21,7 @@ class BlobClipper extends CustomClipper { minGrowth: minGrowth, size: size, ).generate(); - return connectPoints(blobData.curves); + return connectPoints(blobData.curves!); } @override diff --git a/lib/src/models.dart b/lib/src/models.dart index 4babb5e..cd0c606 100644 --- a/lib/src/models.dart +++ b/lib/src/models.dart @@ -1,14 +1,14 @@ import 'package:flutter/material.dart'; class BlobData { - int growth; - num size; - int edges; - BlobPoints points; - String id; - Path path; - String svgPath; - BlobCurves curves; + int? growth; + num? size; + int? edges; + BlobPoints? points; + String? id; + Path? path; + String? svgPath; + BlobCurves? curves; BlobData({ this.growth, @@ -32,10 +32,10 @@ class BlobCurves { enum BlobFillType { fill, stroke } class BlobStyles { - Color color; - Shader gradient; - int strokeWidth; - BlobFillType fillType; + Color? color; + Shader? gradient; + int? strokeWidth; + BlobFillType? fillType; BlobStyles({ this.color, this.gradient, @@ -45,11 +45,11 @@ class BlobStyles { } class BlobPoints { - List originPoints; - List destPoints; - Offset center; - double innerRad; - String id; + List? originPoints; + List? destPoints; + Offset? center; + double? innerRad; + String? id; BlobPoints({ this.originPoints, this.destPoints, diff --git a/lib/src/painter/painter.dart b/lib/src/painter/painter.dart index 88930d6..aca5221 100644 --- a/lib/src/painter/painter.dart +++ b/lib/src/painter/painter.dart @@ -3,9 +3,9 @@ import 'package:blobs/src/painter/tools.dart'; import 'package:flutter/material.dart'; class BlobPainter extends CustomPainter { - final BlobData blobData; - final bool debug; - final BlobStyles styles; + final BlobData? blobData; + final bool? debug; + final BlobStyles? styles; BlobPainter({ this.blobData, @@ -15,15 +15,15 @@ class BlobPainter extends CustomPainter { @override void paint(Canvas c, Size s) { - drawBlob(c, blobData.path, styles); - if (debug) { + drawBlob(c, blobData!.path!, styles); + if (debug!) { circle(c, s, (s.width / 2)); // outer circle - circle(c, s, blobData.points.innerRad); // inner circle + circle(c, s, blobData!.points!.innerRad!); // inner circle point(c, Offset(s.width / 2, s.height / 2)); // center point - List originPoints = blobData.points.originPoints; - List destPoints = blobData.points.destPoints; + List originPoints = blobData!.points!.originPoints!; + List? destPoints = blobData!.points!.destPoints; originPoints.asMap().forEach( - (i, p) => drawLines(c, p, destPoints[i]), + (i, p) => drawLines(c, p, destPoints![i]), ); // line from inner circle to blob point } } diff --git a/lib/src/painter/tools.dart b/lib/src/painter/tools.dart index 22ce016..f1f2647 100644 --- a/lib/src/painter/tools.dart +++ b/lib/src/painter/tools.dart @@ -11,7 +11,7 @@ circle(Canvas canvas, Size size, num radius) { var path = Path(); path.addOval(Rect.fromCircle( center: Offset(size.width / 2, size.height / 2), - radius: radius, + radius: radius as double, )); canvas.drawPath(path, paint); } @@ -55,7 +55,7 @@ point(Canvas canvas, Offset center) { canvas.drawPath(path, paint); } -Paint createPaint(BlobStyles styles) { +Paint createPaint(BlobStyles? styles) { Map fillType = { BlobFillType.fill: PaintingStyle.fill, BlobFillType.stroke: PaintingStyle.stroke @@ -66,7 +66,7 @@ Paint createPaint(BlobStyles styles) { paint.color = styles.color ?? BlobConfig.color; paint.shader = styles.gradient; paint.strokeWidth = (styles.strokeWidth ?? BlobConfig.strokeWidth).toDouble(); - paint.style = fillType[styles.fillType ?? BlobConfig.fillType]; + paint.style = fillType[styles.fillType ?? BlobConfig.fillType]!; return paint; } @@ -82,7 +82,7 @@ Path connectPoints(BlobCurves curves) { return path; } -void drawBlob(Canvas canvas, Path path, BlobStyles styles) { +void drawBlob(Canvas canvas, Path path, BlobStyles? styles) { Paint paint = createPaint(styles); // canvas.drawShadow(path, Colors.red.withOpacity(0.8), 10, true); canvas.drawPath(path, paint); diff --git a/lib/src/services/blob_animator.dart b/lib/src/services/blob_animator.dart index c748ed9..b2812fd 100644 --- a/lib/src/services/blob_animator.dart +++ b/lib/src/services/blob_animator.dart @@ -1,8 +1,8 @@ import 'package:flutter/material.dart'; class BlobAnimator { - List pathPoints; - AnimationController animationController; + List? pathPoints; + AnimationController? animationController; List> tweens = []; List> anims = []; @@ -10,10 +10,10 @@ class BlobAnimator { init(Function(List) callback) { Animation animation = CurvedAnimation( - parent: animationController, + parent: animationController!, curve: Curves.linear, ); - pathPoints.asMap().forEach((i, p) { + pathPoints!.asMap().forEach((i, p) { tweens.insert(i, []); anims.insert(i, []); @@ -23,7 +23,7 @@ class BlobAnimator { tweens[i].add(Tween(begin: 0, end: 0)); anims[i].add(tweens[i][1].animate(animation)); }); - animationController.addListener(() { + animationController!.addListener(() { List transitionPoints = []; anims.asMap().forEach((i, value) { transitionPoints.add(Offset( @@ -36,15 +36,15 @@ class BlobAnimator { morphTo(pathPoints); } - morphTo(List newPathPoints) { + morphTo(List? newPathPoints) { tweens.asMap().forEach((i, tween) { tween[0].begin = tween[0].end; - tween[0].end = newPathPoints[i].dx + 5; + tween[0].end = newPathPoints![i].dx + 5; tween[1].begin = tween[1].end; tween[1].end = newPathPoints[i].dy + 5; }); - animationController.reset(); - animationController.forward(); + animationController!.reset(); + animationController!.forward(); } } diff --git a/lib/src/services/blob_controller.dart b/lib/src/services/blob_controller.dart index 80d4611..a9f5edb 100644 --- a/lib/src/services/blob_controller.dart +++ b/lib/src/services/blob_controller.dart @@ -1,15 +1,15 @@ import 'package:blobs/src/models.dart'; class BlobController { - BlobData Function() _listener; + BlobData? Function()? _listener; BlobController(); - onChange(BlobData Function() ex) { + onChange(BlobData? Function() ex) { _listener = ex; } - BlobData change() { + BlobData? change() { if (_listener == null) return BlobData(); - return _listener(); + return _listener!(); } dispose() { diff --git a/lib/src/services/blob_error_handler.dart b/lib/src/services/blob_error_handler.dart index 694e258..f548204 100644 --- a/lib/src/services/blob_error_handler.dart +++ b/lib/src/services/blob_error_handler.dart @@ -1,5 +1,5 @@ class InvalidIDException implements Exception { - final String id; + final String? id; InvalidIDException(this.id); @override diff --git a/lib/src/services/blob_generator.dart b/lib/src/services/blob_generator.dart index 4791f2e..a919366 100644 --- a/lib/src/services/blob_generator.dart +++ b/lib/src/services/blob_generator.dart @@ -6,11 +6,11 @@ import 'package:flutter/material.dart'; import 'package:blobs/src/models.dart'; class BlobGenerator { - final Size size; - int edgesCount; - int minGrowth; + final Size? size; + int? edgesCount; + int? minGrowth; String svgPath = ''; - String id; + String? id; List> dots = []; BlobGenerator({ @@ -22,15 +22,15 @@ class BlobGenerator { BlobData generate() { if (id != null) { - var datum = id.split('-'); + var datum = id!.split('-'); if (datum.length != 3) throw InvalidIDException(id); edgesCount = int.parse(datum[0]); minGrowth = int.parse(datum[1]); id = datum[2]; } - if (edgesCount <= 2) throw InvalidEdgesCountException(); - var points = _createPoints(id != null ? int.parse(id) : null); - BlobCurves curves = _createCurves(points.destPoints); + if (edgesCount! <= 2) throw InvalidEdgesCountException(); + var points = _createPoints(id != null ? int.parse(id!) : null); + BlobCurves curves = _createCurves(points.destPoints!); Path path = connectPoints(curves); return BlobData( edges: edgesCount, @@ -38,7 +38,7 @@ class BlobGenerator { id: points.id, path: path, points: points, - size: size.width, + size: size!.width, svgPath: svgPath, curves: curves, ); @@ -64,7 +64,7 @@ class BlobGenerator { List _divide(num count) { double deg = 360 / count; - return List.generate(count, (i) => i * deg).toList(); + return List.generate(count as int, (i) => i * deg).toList(); } // https://stackoverflow.com/a/29450606/3096740 @@ -79,7 +79,7 @@ class BlobGenerator { num result = (((mz << 16) + (mw & 65535)) & mask) >> 0; result /= 4294967296; - return result; + return result as double; }; } @@ -99,15 +99,15 @@ class BlobGenerator { return Offset(x.round().toDouble(), y.round().toDouble()); } - BlobPoints _createPoints(int seedValue) { - num outerRad = size.width / 2; - num innerRad = minGrowth * (outerRad / 10); - Offset center = Offset(size.width / 2, size.height / 2); + BlobPoints _createPoints(int? seedValue) { + num outerRad = size!.width / 2; + num innerRad = minGrowth! * (outerRad / 10); + Offset center = Offset(size!.width / 2, size!.height / 2); - List slices = _divide(edgesCount); - int randomInt; + List slices = _divide(edgesCount!); + int? randomInt; if (id != null) { - seedValue = int.parse(id); + seedValue = int.parse(id!); } else { int maxRandomValue = ([99, 999, 9999, 99999, 999999]..shuffle()).first; randomInt = Random().nextInt(maxRandomValue); @@ -119,7 +119,7 @@ class BlobGenerator { slices.forEach((degree) { double O = _magicPoint(randVal(), innerRad, outerRad); - Offset start = _point(center, innerRad, degree); + Offset start = _point(center, innerRad as double, degree); Offset end = _point(center, O, degree); originPoints.add(start); destPoints.add(end); @@ -134,16 +134,16 @@ class BlobGenerator { } BlobPoints _createPointsFromDest(List destPoints) { - num outerRad = size.width / 2; - num innerRad = minGrowth * (outerRad / 10); - Offset center = Offset(size.width / 2, size.height / 2); + num outerRad = size!.width / 2; + num innerRad = minGrowth! * (outerRad / 10); + Offset center = Offset(size!.width / 2, size!.height / 2); - List slices = _divide(edgesCount); + List slices = _divide(edgesCount!); List originPoints = []; slices.forEach((degree) { - Offset start = _point(center, innerRad, degree); + Offset start = _point(center, innerRad as double, degree); originPoints.add(start); }); return BlobPoints( diff --git a/lib/src/widgets/animated_blob.dart b/lib/src/widgets/animated_blob.dart index 8f51ac8..f00f8c3 100644 --- a/lib/src/widgets/animated_blob.dart +++ b/lib/src/widgets/animated_blob.dart @@ -8,13 +8,13 @@ import 'package:flutter/material.dart'; class AnimatedBlob extends StatefulWidget { final double size; final bool debug; - final BlobStyles styles; - final String id; - final BlobController ctrl; - final Widget child; - final Duration duration; - final BlobData fromBlobData; - final BlobData toBlobData; + final BlobStyles? styles; + final String? id; + final BlobController? ctrl; + final Widget? child; + final Duration? duration; + final BlobData? fromBlobData; + final BlobData? toBlobData; const AnimatedBlob({ this.size = 200, @@ -34,9 +34,9 @@ class AnimatedBlob extends StatefulWidget { class _AnimatedBlobState extends State with SingleTickerProviderStateMixin { - AnimationController _animationController; - BlobAnimator animator; - BlobData data; + AnimationController? _animationController; + late BlobAnimator animator; + BlobData? data; @override void didUpdateWidget(AnimatedBlob oldWidget) { @@ -51,12 +51,12 @@ class _AnimatedBlobState extends State AnimationController(duration: widget.duration, vsync: this); animator = BlobAnimator( animationController: _animationController, - pathPoints: widget.toBlobData.points.destPoints); + pathPoints: widget.toBlobData!.points!.destPoints); animator.init((o) { setState(() { data = BlobGenerator( - edgesCount: widget.toBlobData.edges, - minGrowth: widget.toBlobData.growth, + edgesCount: widget.toBlobData!.edges, + minGrowth: widget.toBlobData!.growth, size: Size(widget.size, widget.size), ).generateFromPoints(o); }); @@ -65,7 +65,7 @@ class _AnimatedBlobState extends State } setNewValue() { - animator.morphTo(widget.toBlobData.points.destPoints); + animator.morphTo(widget.toBlobData!.points!.destPoints); } @override @@ -81,8 +81,8 @@ class _AnimatedBlobState extends State @override void dispose() { - if (widget.ctrl != null) widget.ctrl.dispose(); - _animationController.dispose(); + if (widget.ctrl != null) widget.ctrl!.dispose(); + _animationController!.dispose(); super.dispose(); } } diff --git a/lib/src/widgets/blob.dart b/lib/src/widgets/blob.dart index 9b831ac..84c5635 100644 --- a/lib/src/widgets/blob.dart +++ b/lib/src/widgets/blob.dart @@ -11,22 +11,22 @@ import 'package:flutter/material.dart'; class Blob extends StatefulWidget { final double size; final bool debug; - final BlobStyles styles; - final BlobController controller; - final Widget child; - final int edgesCount; - final int minGrowth; - final List id; - final Duration duration; + final BlobStyles? styles; + final BlobController? controller; + final Widget? child; + final int? edgesCount; + final int? minGrowth; + final List? id; + final Duration? duration; final bool loop; final bool isAnimated; static int count = 0; Blob.random({ - @required this.size, - this.edgesCount = BlobConfig.edgesCount, - this.minGrowth = BlobConfig.minGrowth, + required this.size, + this.edgesCount = BlobConfig.edgesCount as int?, + this.minGrowth = BlobConfig.minGrowth as int?, this.debug = false, this.styles, this.controller, @@ -36,13 +36,13 @@ class Blob extends StatefulWidget { duration = null, isAnimated = false; Blob.animatedRandom({ - @required this.size, - this.edgesCount = BlobConfig.edgesCount, - this.minGrowth = BlobConfig.minGrowth, + required this.size, + this.edgesCount = BlobConfig.edgesCount as int?, + this.minGrowth = BlobConfig.minGrowth as int?, this.debug = false, this.styles, this.duration = const Duration( - milliseconds: BlobConfig.animDurationMs, + milliseconds: BlobConfig.animDurationMs as int, ), this.loop = false, this.controller, @@ -51,8 +51,8 @@ class Blob extends StatefulWidget { id = null; Blob.fromID({ - @required this.id, - @required this.size, + required this.id, + required this.size, this.debug = false, this.styles, this.controller, @@ -64,12 +64,12 @@ class Blob extends StatefulWidget { isAnimated = false; Blob.animatedFromID({ - @required this.id, - @required this.size, + required this.id, + required this.size, this.debug = false, this.styles, this.duration = const Duration( - milliseconds: BlobConfig.animDurationMs, + milliseconds: BlobConfig.animDurationMs as int, ), this.loop = false, this.controller, @@ -82,7 +82,7 @@ class Blob extends StatefulWidget { _BlobState createState() => _BlobState(); BlobData _randomBlobData() { - String randomID = (id == null || id.isEmpty) ? null : _randomID(); + String? randomID = (id == null || id!.isEmpty) ? null : _randomID(); return BlobGenerator( edgesCount: edgesCount, minGrowth: minGrowth, @@ -93,15 +93,15 @@ class Blob extends StatefulWidget { String _randomID() { Blob.count++; - if (id.length == 1) return id[0]; - return id[Blob.count % id.length]; + if (id!.length == 1) return id![0]; + return id![Blob.count % id!.length]; } } class _BlobState extends State { - BlobData blobData; - BlobData fromBlobData; - Timer timer; + BlobData? blobData; + BlobData? fromBlobData; + Timer? timer; @override void initState() { @@ -109,11 +109,11 @@ class _BlobState extends State { _updateBlob(); if (widget.loop) { timer = Timer.periodic( - Duration(milliseconds: widget.duration.inMilliseconds), + Duration(milliseconds: widget.duration!.inMilliseconds), (_) => _updateBlob(), ); } else if (widget.controller != null) { - widget.controller.onChange(_updateBlob); + widget.controller!.onChange(_updateBlob); } } @@ -139,7 +139,7 @@ class _BlobState extends State { ); } - BlobData _updateBlob() { + BlobData? _updateBlob() { if (widget.isAnimated) { fromBlobData = blobData; } @@ -150,8 +150,8 @@ class _BlobState extends State { @override void dispose() { - if (timer != null) timer.cancel(); - if (widget.controller != null) widget.controller.dispose(); + if (timer != null) timer!.cancel(); + if (widget.controller != null) widget.controller!.dispose(); super.dispose(); } } diff --git a/lib/src/widgets/simple_blob.dart b/lib/src/widgets/simple_blob.dart index 7d37024..e559bc6 100644 --- a/lib/src/widgets/simple_blob.dart +++ b/lib/src/widgets/simple_blob.dart @@ -4,11 +4,11 @@ import 'package:blobs/src/painter/painter.dart'; import 'package:flutter/material.dart'; class SimpleBlob extends StatelessWidget { - final double size; - final BlobData blobData; - final bool debug; - final Widget child; - final BlobStyles styles; + final double? size; + final BlobData? blobData; + final bool? debug; + final Widget? child; + final BlobStyles? styles; const SimpleBlob({ this.blobData, diff --git a/pubspec.lock b/pubspec.lock index b40eda5..e82a447 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1,62 +1,55 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: - archive: - dependency: transitive - description: - name: archive - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.13" - args: - dependency: transitive - description: - name: args - url: "https://pub.dartlang.org" - source: hosted - version: "1.6.0" async: dependency: transitive description: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.4.1" + version: "2.6.1" boolean_selector: dependency: transitive description: name: boolean_selector url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.1.0" + characters: + dependency: transitive + description: + name: characters + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.1.3" - collection: + version: "1.2.0" + clock: dependency: transitive description: - name: collection + name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.14.12" - convert: + version: "1.1.0" + collection: dependency: transitive description: - name: convert + name: collection url: "https://pub.dartlang.org" source: hosted - version: "2.1.1" - crypto: + version: "1.15.0" + fake_async: dependency: transitive description: - name: crypto + name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "2.1.4" + version: "1.2.0" flutter: dependency: "direct main" description: flutter @@ -67,34 +60,27 @@ packages: description: flutter source: sdk version: "0.0.0" - image: - dependency: transitive - description: - name: image - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.12" matcher: dependency: transitive description: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.6" + version: "0.12.10" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.1.8" + version: "1.3.0" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.6.4" + version: "1.8.0" pedantic: dependency: "direct dev" description: @@ -102,20 +88,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.9.0" - petitparser: - dependency: transitive - description: - name: petitparser - url: "https://pub.dartlang.org" - source: hosted - version: "2.4.0" - quiver: - dependency: transitive - description: - name: quiver - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.3" sky_engine: dependency: transitive description: flutter @@ -127,63 +99,56 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.7.0" + version: "1.8.1" stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.9.3" + version: "1.10.0" stream_channel: dependency: transitive description: name: stream_channel url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.1.0" string_scanner: dependency: transitive description: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.0.5" + version: "1.1.0" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.2.0" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.15" + version: "0.3.0" typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.1.6" + version: "1.3.0" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.0.8" - xml: - dependency: transitive - description: - name: xml - url: "https://pub.dartlang.org" - source: hosted - version: "3.6.1" + version: "2.1.0" sdks: - dart: ">=2.7.0 <3.0.0" - flutter: ">=0.2.5 <2.0.0" + dart: ">=2.12.0 <3.0.0" + flutter: ">=0.2.5" diff --git a/pubspec.yaml b/pubspec.yaml index 668bd2f..9a27ea2 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -4,7 +4,7 @@ version: 1.2.0 homepage: https://github.com/lokesh-coder/flutter_blobs environment: - sdk: ">=2.7.0 <3.0.0" + sdk: '>=2.12.0 <3.0.0' flutter: ">=0.2.5 <2.0.0" dependencies: