Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Null check operator used on a null value when either only width or height gets provided #34

Open
BujusKrachus opened this issue Sep 4, 2024 · 0 comments

Comments

@BujusKrachus
Copy link

Usually you can only pass one of both (width/height) and the other one will be set accordingly. However only passing one throws a null check error. Providing both works just fine but is annoying to keep the aspect correct.

For example:

Expanded(
                    child: AnimatedDrawing.svg(
                      'image.svg',
                      width: 100, // note: only width provided
                      run: svgAnimation01,
                      duration: const Duration(seconds: 3),
                      lineAnimation: LineAnimation.oneByOne,
                      animationCurve: Curves.linear,
                      onFinish: () => setState(() {
                        //run = false;
                      }),
                    ),
                  ),

will throw:

======== Exception caught by widgets library =======================================================
The following _TypeError was thrown building AnimatedDrawing(dirty, dependencies: [MediaQuery], state: AnimatedDrawingWithTickerState#2b228(ticker inactive)):
Null check operator used on a null value

The relevant error-causing widget was: 
  AnimatedDrawing AnimatedDrawing:file:///C:/Users/<user>/<path_to_file>.dart:<line>
When the exception was thrown, this was the stack: 
#0      AbstractAnimatedDrawingState.getCustomDimensions (package:drawing_animation/src/abstract_drawing_state.dart:214:22)
#1      AbstractAnimatedDrawingState.preparePathPainterBuilder (package:drawing_animation/src/abstract_drawing_state.dart:164:33)
#2      AbstractAnimatedDrawingState.buildForegroundPainter (package:drawing_animation/src/abstract_drawing_state.dart:149:19)
#3      AbstractAnimatedDrawingState.createCustomPaint (package:drawing_animation/src/abstract_drawing_state.dart:224:28)
#4      AnimatedDrawingWithTickerState.build (package:drawing_animation/src/drawing_state_with_ticker.dart:55:12)
#5      StatefulElement.build (package:flutter/src/widgets/framework.dart:5592:27)
#6      ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5480:15)
#7      StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:5643:11)
#8      Element.rebuild (package:flutter/src/widgets/framework.dart:5196:7)
#9      BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2904:19)
#10     WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:989:21)
#11     RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:448:5)
#12     SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1386:15)
#13     SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1311:9)
#14     SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:1169:5)
#15     _invoke (dart:ui/hooks.dart:312:13)
#16     PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:399:5)
#17     _drawFrame (dart:ui/hooks.dart:283:31)
====================================================================================================
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant