diff --git a/CHANGELOG.md b/CHANGELOG.md index cda79f6..fc0946c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## [2.0.0] + +- Migrated to null safety + ## [1.2.0] - Changed blob generator logic diff --git a/example/lib/common/app_shell.dart b/example/lib/common/app_shell.dart index 5d47110..25b3192 100644 --- a/example/lib/common/app_shell.dart +++ b/example/lib/common/app_shell.dart @@ -2,8 +2,8 @@ import 'package:flutter/material.dart'; class AppShell extends StatelessWidget { final String title; - final Widget child; - const AppShell({Key key, this.title, this.child}) : super(key: key); + final Widget? child; + const AppShell({Key? key, required this.title, this.child}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/example/lib/common/button.dart b/example/lib/common/button.dart index f1b1c2c..51a3107 100644 --- a/example/lib/common/button.dart +++ b/example/lib/common/button.dart @@ -2,8 +2,8 @@ import 'package:flutter/material.dart'; class Button extends StatelessWidget { final String label; - final Function onTap; - const Button(this.label, {Key key, this.onTap}) : super(key: key); + final VoidCallback? onTap; + const Button(this.label, {Key? key, this.onTap}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/example/lib/examples/animated/animated_basic.dart b/example/lib/examples/animated/animated_basic.dart index fc428c3..91aca98 100644 --- a/example/lib/examples/animated/animated_basic.dart +++ b/example/lib/examples/animated/animated_basic.dart @@ -5,7 +5,7 @@ import '../../common/app_shell.dart'; import '../../common/button.dart'; class AnimatedBasicExample extends StatelessWidget { - const AnimatedBasicExample({Key key}) : super(key: key); + const AnimatedBasicExample({Key? key}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/example/lib/examples/animated/animated_child.dart b/example/lib/examples/animated/animated_child.dart index d36aa28..efea8bb 100644 --- a/example/lib/examples/animated/animated_child.dart +++ b/example/lib/examples/animated/animated_child.dart @@ -4,7 +4,7 @@ import '../../common/app_shell.dart'; import '../../common/button.dart'; class AnimatedChildExample extends StatelessWidget { - const AnimatedChildExample({Key key}) : super(key: key); + const AnimatedChildExample({Key? key}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/example/lib/examples/animated/animated_color.dart b/example/lib/examples/animated/animated_color.dart index ad9734e..6362589 100644 --- a/example/lib/examples/animated/animated_color.dart +++ b/example/lib/examples/animated/animated_color.dart @@ -4,7 +4,7 @@ import '../../common/button.dart'; import 'package:flutter/material.dart'; class AnimatedColorExample extends StatelessWidget { - const AnimatedColorExample({Key key}) : super(key: key); + const AnimatedColorExample({Key? key}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/example/lib/examples/animated/animated_debug.dart b/example/lib/examples/animated/animated_debug.dart index 8e60a96..0b1b54a 100644 --- a/example/lib/examples/animated/animated_debug.dart +++ b/example/lib/examples/animated/animated_debug.dart @@ -4,7 +4,7 @@ import '../../common/button.dart'; import 'package:flutter/material.dart'; class AnimatedDebugExample extends StatelessWidget { - const AnimatedDebugExample({Key key}) : super(key: key); + const AnimatedDebugExample({Key? key}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/example/lib/examples/animated/animated_gradient.dart b/example/lib/examples/animated/animated_gradient.dart index 2ed790f..19bbb37 100644 --- a/example/lib/examples/animated/animated_gradient.dart +++ b/example/lib/examples/animated/animated_gradient.dart @@ -4,7 +4,7 @@ import '../../common/button.dart'; import 'package:flutter/material.dart'; class AnimatedGradientExample extends StatelessWidget { - const AnimatedGradientExample({Key key}) : super(key: key); + const AnimatedGradientExample({Key? key}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/example/lib/examples/animated/animated_hash.dart b/example/lib/examples/animated/animated_hash.dart index d0a5d63..89ec6ff 100644 --- a/example/lib/examples/animated/animated_hash.dart +++ b/example/lib/examples/animated/animated_hash.dart @@ -4,7 +4,7 @@ import '../../common/button.dart'; import 'package:flutter/material.dart'; class AnimatedHashExample extends StatelessWidget { - const AnimatedHashExample({Key key}) : super(key: key); + const AnimatedHashExample({Key? key}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/example/lib/examples/animated/animated_multiple_hash.dart b/example/lib/examples/animated/animated_multiple_hash.dart index 210907e..be36a9f 100644 --- a/example/lib/examples/animated/animated_multiple_hash.dart +++ b/example/lib/examples/animated/animated_multiple_hash.dart @@ -3,7 +3,7 @@ import '../../common/app_shell.dart'; import 'package:flutter/material.dart'; class AnimatedMultipleHashExample extends StatefulWidget { - const AnimatedMultipleHashExample({Key key}) : super(key: key); + const AnimatedMultipleHashExample({Key? key}) : super(key: key); @override _AnimatedMultipleHashExampleState createState() => @@ -12,7 +12,7 @@ class AnimatedMultipleHashExample extends StatefulWidget { class _AnimatedMultipleHashExampleState extends State { - Color clr; + Color? clr; @override Widget build(BuildContext context) { BlobController blobCtrl = BlobController(); diff --git a/example/lib/examples/animated/animated_stroke.dart b/example/lib/examples/animated/animated_stroke.dart index c5daf20..5c91ac4 100644 --- a/example/lib/examples/animated/animated_stroke.dart +++ b/example/lib/examples/animated/animated_stroke.dart @@ -4,7 +4,7 @@ import '../../common/button.dart'; import 'package:flutter/material.dart'; class AnimatedStrokeExample extends StatelessWidget { - const AnimatedStrokeExample({Key key}) : super(key: key); + const AnimatedStrokeExample({Key? key}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/example/lib/examples/animated/annimated_loop.dart b/example/lib/examples/animated/annimated_loop.dart index 5ee7f36..3bc08a8 100644 --- a/example/lib/examples/animated/annimated_loop.dart +++ b/example/lib/examples/animated/annimated_loop.dart @@ -3,7 +3,7 @@ import '../../common/app_shell.dart'; import 'package:flutter/material.dart'; class AnimatedLoopExample extends StatelessWidget { - const AnimatedLoopExample({Key key}) : super(key: key); + const AnimatedLoopExample({Key? key}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/example/lib/examples/examples.dart b/example/lib/examples/examples.dart index 7c769e8..5454ecd 100644 --- a/example/lib/examples/examples.dart +++ b/example/lib/examples/examples.dart @@ -24,7 +24,7 @@ import 'inspirations/frame.dart'; import 'inspirations/bottomclip.dart'; class Examples extends StatelessWidget { - const Examples({Key key}) : super(key: key); + const Examples({Key? key}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/example/lib/examples/inspirations/bottomclip.dart b/example/lib/examples/inspirations/bottomclip.dart index 5b49752..ec65790 100644 --- a/example/lib/examples/inspirations/bottomclip.dart +++ b/example/lib/examples/inspirations/bottomclip.dart @@ -3,7 +3,7 @@ import '../../common/app_shell.dart'; import 'package:flutter/material.dart'; class BottomClipInspirationExample extends StatelessWidget { - const BottomClipInspirationExample({Key key}) : super(key: key); + const BottomClipInspirationExample({Key? key}) : super(key: key); @override Widget build(BuildContext context) { @@ -52,7 +52,7 @@ class MyClipper extends CustomClipper { var sqPath = Path() ..addRect(Rect.fromLTWH(0, 0, size.width, size.height / 2)); - var blobPath = connectPoints(blobData.curves); + var blobPath = connectPoints(blobData.curves!); return Path.combine(PathOperation.union, blobPath, sqPath); } diff --git a/example/lib/examples/inspirations/frame.dart b/example/lib/examples/inspirations/frame.dart index aea3d2d..9ea968a 100644 --- a/example/lib/examples/inspirations/frame.dart +++ b/example/lib/examples/inspirations/frame.dart @@ -3,7 +3,7 @@ import '../../common/app_shell.dart'; import 'package:flutter/material.dart'; class FrameInspirationExample extends StatelessWidget { - const FrameInspirationExample({Key key}) : super(key: key); + const FrameInspirationExample({Key? key}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/example/lib/examples/inspirations/rotate.dart b/example/lib/examples/inspirations/rotate.dart index 574429b..fc0de67 100644 --- a/example/lib/examples/inspirations/rotate.dart +++ b/example/lib/examples/inspirations/rotate.dart @@ -4,7 +4,7 @@ import 'package:flutter/material.dart'; import '../../common/app_shell.dart'; class RotateInpirationExample extends StatefulWidget { - const RotateInpirationExample({Key key}) : super(key: key); + const RotateInpirationExample({Key? key}) : super(key: key); @override _RotateInpirationExampleState createState() => @@ -13,8 +13,8 @@ class RotateInpirationExample extends StatefulWidget { class _RotateInpirationExampleState extends State with SingleTickerProviderStateMixin { - AnimationController _animationController; - Animation animation; + late AnimationController _animationController; + late Animation animation; @override void initState() { diff --git a/example/lib/examples/static/static_basic.dart b/example/lib/examples/static/static_basic.dart index 6b10cd4..2efc66b 100644 --- a/example/lib/examples/static/static_basic.dart +++ b/example/lib/examples/static/static_basic.dart @@ -3,7 +3,7 @@ import '../../common/app_shell.dart'; import 'package:flutter/material.dart'; class StaticBasicExample extends StatelessWidget { - const StaticBasicExample({Key key}) : super(key: key); + const StaticBasicExample({Key? key}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/example/lib/examples/static/static_child.dart b/example/lib/examples/static/static_child.dart index 37dbb97..607f397 100644 --- a/example/lib/examples/static/static_child.dart +++ b/example/lib/examples/static/static_child.dart @@ -4,7 +4,7 @@ import '../../common/button.dart'; import 'package:flutter/material.dart'; class StaticChildExample extends StatelessWidget { - const StaticChildExample({Key key}) : super(key: key); + const StaticChildExample({Key? key}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/example/lib/examples/static/static_clipper.dart b/example/lib/examples/static/static_clipper.dart index ba3d92d..015264e 100644 --- a/example/lib/examples/static/static_clipper.dart +++ b/example/lib/examples/static/static_clipper.dart @@ -4,7 +4,7 @@ import '../../common/button.dart'; import 'package:flutter/material.dart'; class StaticClipperExample extends StatefulWidget { - const StaticClipperExample({Key key}) : super(key: key); + const StaticClipperExample({Key? key}) : super(key: key); @override _StaticClipperExampleState createState() => _StaticClipperExampleState(); diff --git a/example/lib/examples/static/static_color.dart b/example/lib/examples/static/static_color.dart index d847842..1eb5ed6 100644 --- a/example/lib/examples/static/static_color.dart +++ b/example/lib/examples/static/static_color.dart @@ -3,7 +3,7 @@ import '../../common/app_shell.dart'; import 'package:flutter/material.dart'; class StaticColorExample extends StatelessWidget { - const StaticColorExample({Key key}) : super(key: key); + const StaticColorExample({Key? key}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/example/lib/examples/static/static_debug.dart b/example/lib/examples/static/static_debug.dart index 5034bc7..02a5a4c 100644 --- a/example/lib/examples/static/static_debug.dart +++ b/example/lib/examples/static/static_debug.dart @@ -3,7 +3,7 @@ import '../../common/app_shell.dart'; import 'package:flutter/material.dart'; class StaticDebugExample extends StatelessWidget { - const StaticDebugExample({Key key}) : super(key: key); + const StaticDebugExample({Key? key}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/example/lib/examples/static/static_gradient.dart b/example/lib/examples/static/static_gradient.dart index 188cb97..783eefa 100644 --- a/example/lib/examples/static/static_gradient.dart +++ b/example/lib/examples/static/static_gradient.dart @@ -3,7 +3,7 @@ import '../../common/app_shell.dart'; import 'package:flutter/material.dart'; class StaticGradientExample extends StatelessWidget { - const StaticGradientExample({Key key}) : super(key: key); + const StaticGradientExample({Key? key}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/example/lib/examples/static/static_hash.dart b/example/lib/examples/static/static_hash.dart index 42bc349..bcd4174 100644 --- a/example/lib/examples/static/static_hash.dart +++ b/example/lib/examples/static/static_hash.dart @@ -4,7 +4,7 @@ import '../../common/button.dart'; import 'package:flutter/material.dart'; class StaticHashExample extends StatelessWidget { - const StaticHashExample({Key key}) : super(key: key); + const StaticHashExample({Key? key}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/example/lib/examples/static/static_multiple_hash.dart b/example/lib/examples/static/static_multiple_hash.dart index e21a0bf..ba7a70d 100644 --- a/example/lib/examples/static/static_multiple_hash.dart +++ b/example/lib/examples/static/static_multiple_hash.dart @@ -4,7 +4,7 @@ import '../../common/button.dart'; import 'package:flutter/material.dart'; class StaticMultipleHashExample extends StatelessWidget { - const StaticMultipleHashExample({Key key}) : super(key: key); + const StaticMultipleHashExample({Key? key}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/example/lib/examples/static/static_stroke.dart b/example/lib/examples/static/static_stroke.dart index ace0b46..ed91592 100644 --- a/example/lib/examples/static/static_stroke.dart +++ b/example/lib/examples/static/static_stroke.dart @@ -3,7 +3,7 @@ import '../../common/app_shell.dart'; import 'package:flutter/material.dart'; class StaticStrokeExample extends StatelessWidget { - const StaticStrokeExample({Key key}) : super(key: key); + const StaticStrokeExample({Key? key}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/example/lib/main.dart b/example/lib/main.dart index 58172e8..acdccb0 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -26,7 +26,7 @@ class MyApp extends StatelessWidget { } class BasicExample extends StatelessWidget { - const BasicExample({Key key}) : super(key: key); + const BasicExample({Key? key}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/example/pubspec.lock b/example/pubspec.lock index c7e48f8..a575457 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -1,76 +1,90 @@ # 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: path: ".." relative: true source: path - version: "1.2.0" + version: "2.0.0" 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" + version: "1.15.0" crypto: dependency: transitive description: name: crypto url: "https://pub.dartlang.org" source: hosted - version: "2.1.4" + version: "3.0.1" cupertino_icons: dependency: "direct main" description: name: cupertino_icons url: "https://pub.dartlang.org" source: hosted - version: "0.1.3" + version: "1.0.3" + fake_async: + dependency: transitive + description: + name: fake_async + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.0" + ffi: + dependency: transitive + description: + name: ffi + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.0" + file: + dependency: transitive + description: + name: file + url: "https://pub.dartlang.org" + source: hosted + version: "6.1.0" flutter: dependency: "direct main" description: flutter @@ -87,105 +101,105 @@ packages: name: google_fonts url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "2.0.0" http: dependency: transitive description: name: http url: "https://pub.dartlang.org" source: hosted - version: "0.12.1" + version: "0.13.3" http_parser: dependency: transitive description: name: http_parser 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" + version: "4.0.0" 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: name: path_provider url: "https://pub.dartlang.org" source: hosted - version: "1.6.8" + version: "2.0.1" + path_provider_linux: + dependency: transitive + description: + name: path_provider_linux + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" path_provider_macos: dependency: transitive description: name: path_provider_macos url: "https://pub.dartlang.org" source: hosted - version: "0.0.4+2" + version: "2.0.0" path_provider_platform_interface: dependency: transitive description: name: path_provider_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.0.2" - pedantic: + version: "2.0.1" + path_provider_windows: dependency: transitive description: - name: pedantic + name: path_provider_windows url: "https://pub.dartlang.org" source: hosted - version: "1.9.0" - petitparser: + version: "2.0.1" + pedantic: dependency: transitive description: - name: petitparser + name: pedantic url: "https://pub.dartlang.org" source: hosted - version: "2.4.0" + version: "1.11.0" platform: dependency: transitive description: name: platform url: "https://pub.dartlang.org" source: hosted - version: "2.2.1" + version: "3.0.0" plugin_platform_interface: dependency: transitive description: name: plugin_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.0.2" - quiver: + version: "2.0.0" + process: dependency: transitive description: - name: quiver + name: process url: "https://pub.dartlang.org" source: hosted - version: "2.1.3" + version: "4.2.1" sky_engine: dependency: transitive description: flutter @@ -197,63 +211,70 @@ 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: + version: "2.1.0" + win32: + dependency: transitive + description: + name: win32 + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.5" + xdg_directories: dependency: transitive description: - name: xml + name: xdg_directories url: "https://pub.dartlang.org" source: hosted - version: "3.6.1" + version: "0.2.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.20.0" diff --git a/example/pubspec.yaml b/example/pubspec.yaml index fbe13bd..fe08f26 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -18,15 +18,15 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev version: 1.0.0+1 environment: - sdk: ">=2.7.0 <3.0.0" + sdk: '>=2.12.0 <3.0.0' dependencies: flutter: sdk: flutter blobs: path: .. - cupertino_icons: ^0.1.3 - google_fonts: ^1.1.0 + cupertino_icons: ^1.0.3 + google_fonts: ^2.0.0 dev_dependencies: flutter_test: diff --git a/lib/src/clipper/clipper.dart b/lib/src/clipper/clipper.dart index 81c184a..8cbd195 100644 --- a/lib/src/clipper/clipper.dart +++ b/lib/src/clipper/clipper.dart @@ -4,7 +4,7 @@ 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({ @@ -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/config.dart b/lib/src/config.dart index 2f9f98c..b4cdc06 100644 --- a/lib/src/config.dart +++ b/lib/src/config.dart @@ -4,8 +4,8 @@ import 'package:flutter/material.dart'; class BlobConfig { static const Color color = Color(0xff3c40c6); static const BlobFillType fillType = BlobFillType.fill; - static const num edgesCount = 6; - static const num minGrowth = 6; - static const num animDurationMs = 500; + static const int edgesCount = 6; + static const int minGrowth = 6; + static const int animDurationMs = 500; static const int strokeWidth = 3; } diff --git a/lib/src/models.dart b/lib/src/models.dart index 4babb5e..399be50 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; + double? 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..58692d3 100644 --- a/lib/src/painter/painter.dart +++ b/lib/src/painter/painter.dart @@ -5,25 +5,25 @@ import 'package:flutter/material.dart'; class BlobPainter extends CustomPainter { final BlobData blobData; final bool debug; - final BlobStyles styles; + final BlobStyles? styles; BlobPainter({ - this.blobData, + required this.blobData, this.styles, this.debug = false, }); @override void paint(Canvas c, Size s) { - drawBlob(c, blobData.path, styles); + 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..276bd2b 100644 --- a/lib/src/painter/tools.dart +++ b/lib/src/painter/tools.dart @@ -2,7 +2,7 @@ import 'package:blobs/src/config.dart'; import 'package:blobs/src/models.dart'; import 'package:flutter/material.dart'; -circle(Canvas canvas, Size size, num radius) { +circle(Canvas canvas, Size size, double radius) { var paint = Paint() ..color = const Color(0xffef5777) ..strokeWidth = 3 @@ -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..e3a1257 100644 --- a/lib/src/services/blob_animator.dart +++ b/lib/src/services/blob_animator.dart @@ -6,7 +6,7 @@ class BlobAnimator { List> tweens = []; List> anims = []; - BlobAnimator({this.pathPoints, this.animationController}); + BlobAnimator({required this.pathPoints, required this.animationController}); init(Function(List) callback) { Animation animation = CurvedAnimation( diff --git a/lib/src/services/blob_controller.dart b/lib/src/services/blob_controller.dart index 80d4611..cea9585 100644 --- a/lib/src/services/blob_controller.dart +++ b/lib/src/services/blob_controller.dart @@ -1,7 +1,7 @@ import 'package:blobs/src/models.dart'; class BlobController { - BlobData Function() _listener; + BlobData Function()? _listener; BlobController(); onChange(BlobData Function() ex) { _listener = ex; @@ -9,7 +9,7 @@ class BlobController { 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..790c465 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, ); @@ -60,9 +60,9 @@ class BlobGenerator { ); } - num _toRad(num deg) => deg * (pi / 180.0); + double _toRad(double deg) => deg * (pi / 180.0); - List _divide(num count) { + List _divide(int count) { double deg = 360 / count; return List.generate(count, (i) => i * deg).toList(); } @@ -77,13 +77,12 @@ class BlobGenerator { mz = (36969 * (mz & 65535) + ((mz & mask) >> 16)) & mask; mw = (18000 * (mw & 65535) + ((mw & mask) >> 16)) & mask; - num result = (((mz << 16) + (mw & 65535)) & mask) >> 0; - result /= 4294967296; + final result = ((((mz << 16) + (mw & 65535)) & mask) >> 0) / 4294967296; return result; }; } - double _magicPoint(double value, num min, num max) { + double _magicPoint(double value, double min, double max) { double radius = min + (value * (max - min)); if (radius > max) { radius = radius - min; @@ -93,21 +92,21 @@ class BlobGenerator { return radius; } - Offset _point(Offset origin, double radius, num degree) { + Offset _point(Offset origin, double radius, double degree) { double x = origin.dx + (radius * cos(_toRad(degree))); double y = origin.dy + (radius * sin(_toRad(degree))); 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) { + double outerRad = size!.width / 2; + double 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); @@ -134,11 +133,11 @@ 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); + double outerRad = size!.width / 2; + double innerRad = minGrowth! * (outerRad / 10); + Offset center = Offset(size!.width / 2, size!.height / 2); - List slices = _divide(edgesCount); + List slices = _divide(edgesCount!); List originPoints = []; diff --git a/lib/src/widgets/animated_blob.dart b/lib/src/widgets/animated_blob.dart index 8f51ac8..9546be8 100644 --- a/lib/src/widgets/animated_blob.dart +++ b/lib/src/widgets/animated_blob.dart @@ -8,18 +8,18 @@ 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 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, this.fromBlobData, - this.toBlobData, + required this.toBlobData, this.debug = false, this.styles, this.ctrl, @@ -34,9 +34,9 @@ class AnimatedBlob extends StatefulWidget { class _AnimatedBlobState extends State with SingleTickerProviderStateMixin { - AnimationController _animationController; - BlobAnimator animator; - BlobData data; + late AnimationController _animationController; + late BlobAnimator animator; + late BlobData data; @override void didUpdateWidget(AnimatedBlob oldWidget) { @@ -51,7 +51,7 @@ 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( @@ -65,7 +65,7 @@ class _AnimatedBlobState extends State } setNewValue() { - animator.morphTo(widget.toBlobData.points.destPoints); + animator.morphTo(widget.toBlobData.points!.destPoints!); } @override @@ -81,7 +81,7 @@ class _AnimatedBlobState extends State @override void dispose() { - if (widget.ctrl != null) widget.ctrl.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..a009184 100644 --- a/lib/src/widgets/blob.dart +++ b/lib/src/widgets/blob.dart @@ -11,20 +11,20 @@ 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, + required this.size, this.edgesCount = BlobConfig.edgesCount, this.minGrowth = BlobConfig.minGrowth, this.debug = false, @@ -36,7 +36,7 @@ class Blob extends StatefulWidget { duration = null, isAnimated = false; Blob.animatedRandom({ - @required this.size, + required this.size, this.edgesCount = BlobConfig.edgesCount, this.minGrowth = BlobConfig.minGrowth, this.debug = false, @@ -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,8 +64,8 @@ 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( @@ -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); } } @@ -121,7 +121,7 @@ class _BlobState extends State { Widget build(BuildContext context) { if (!widget.isAnimated) { return SimpleBlob( - blobData: blobData, + blobData: blobData!, size: widget.size, styles: widget.styles, debug: widget.debug, @@ -130,7 +130,7 @@ class _BlobState extends State { } return AnimatedBlob( fromBlobData: fromBlobData, - toBlobData: blobData, + toBlobData: blobData!, size: widget.size, styles: widget.styles, debug: widget.debug, @@ -145,13 +145,13 @@ class _BlobState extends State { } blobData = widget._randomBlobData(); setState(() {}); - return blobData; + return blobData!; } @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..dc71d6f 100644 --- a/lib/src/widgets/simple_blob.dart +++ b/lib/src/widgets/simple_blob.dart @@ -4,16 +4,16 @@ import 'package:blobs/src/painter/painter.dart'; import 'package:flutter/material.dart'; class SimpleBlob extends StatelessWidget { - final double size; + final double? size; final BlobData blobData; final bool debug; - final Widget child; - final BlobStyles styles; + final Widget? child; + final BlobStyles? styles; const SimpleBlob({ - this.blobData, + required this.blobData, this.size, - this.debug, + this.debug = false, this.styles, this.child, }); diff --git a/pubspec.lock b/pubspec.lock index b40eda5..5b3fb9d 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,55 +60,34 @@ 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: name: pedantic 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" + version: "1.11.0" 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..3bf29c4 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,10 +1,10 @@ name: blobs description: Create beautiful blobs - fixed/random blob generation, animations, svgs and more -version: 1.2.0 +version: 2.0.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: @@ -14,4 +14,4 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - pedantic: ^1.4.0 + pedantic: ^1.11.0