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 #3

Open
ghost opened this issue May 19, 2021 · 4 comments
Open

Null check operator used on a null value #3

ghost opened this issue May 19, 2021 · 4 comments

Comments

@ghost
Copy link

ghost commented May 19, 2021

I get this error sometimes

Null check operator used on a null value
The relevant error-causing widget was

Swiper
lib/views/cards_view.dart:36
When the exception was thrown, this was the stack
#0      _StackViewState._updateValues
package:flutter_card_swipper/src/swiper.dart:864

#1      _StackViewState.didUpdateWidget
package:flutter_card_swipper/src/swiper.dart:874
#2      StatefulElement.update
package:flutter/…/widgets/framework.dart:4682
#3      Element.updateChild
package:flutter/…/widgets/framework.dart:3293
#4      ComponentElement.performRebuild
package:flutter/…/widgets/framework.dart:4520

This is the offending function, I suppose _swiperWidth is null:

void _updateValues() {
  if (widget.scrollDirection == Axis.horizontal) {
    final double space = (_swiperWidth! - widget.itemWidth!) / 2;
    offsets = [-space, -space / 3 * 2, -space / 3, 0.0, _swiperWidth];
  } else {
    final double space = (_swiperHeight! - widget.itemHeight!) / 2;
    offsets = [-space, -space / 3 * 2, -space / 3, 0.0, _swiperHeight];
  }
}
flutter doctor -v
[✓] Flutter (Channel stable, 2.0.6, on macOS 11.2.3 20D91 darwin-x64, locale en-GB)
    • Flutter version 2.0.6 at /Users/dennis/flutter
    • Framework revision 1d9032c7e1 (3 weeks ago), 2021-04-29 17:37:58 -0700
    • Engine revision 05e680e202
    • Dart version 2.12.3

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at /Users/dennis/Library/Android/sdk
    • Platform android-30, build-tools 30.0.3
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.5, Build version 12E262
    • CocoaPods version 1.10.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)

[✓] Connected device (4 available)
    • iPhone 8 Plus (mobile) • 16007D4D-626C-4001-8AAA-D2FE317EE7E7 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-14-5 (simulator)
    • iPhone 11 (mobile)     • 200809FD-F24E-44C7-8886-05EFF2DD3CDA • ios            • com.apple.CoreSimulator.SimRuntime.iOS-14-5 (simulator)
    • macOS (desktop)        • macos                                • darwin-x64     • macOS 11.2.3 20D91 darwin-x64
    • Chrome (web)           • chrome                               • web-javascript • Google Chrome 90.0.4430.212
@amondnet
Copy link

@DenisBarzanov
I have the same issue. So I changed it to the package below.

flutter_swiper:
  git:
    url: [email protected]:Arkangel12/flutter_swiper.git
    ref: master

best-flutter/flutter_swiper#264

@SalahAdDin
Copy link

Well, i have this one too:

======== Exception caught by widgets library =======================================================
The following assertion was thrown building Swiper(dirty, state: _SwiperState#d8d2c):
'package:flutter_card_swipper/src/swiper.dart': Failed assertion: line 704 pos 16: 'itemWidth != null && itemHeight != null': is not true.

The relevant error-causing widget was: 
  Swiper file:///home/luisalaguna/Projects/cancer/thesis_cancer/lib/features/content/presentation/widgets/post.dart:28:15
When the exception was thrown, this was the stack: 
#2      new _TinderSwiper (package:flutter_card_swipper/src/swiper.dart:704:16)
#3      _SwiperState._buildSwiper (package:flutter_card_swipper/src/swiper.dart:526:14)
#4      _SwiperState.build (package:flutter_card_swipper/src/swiper.dart:587:27)
#5      StatefulElement.build (package:flutter/src/widgets/framework.dart:4691:27)
#6      ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4574:15)
...
====================================================================================================

@SalahAdDin
Copy link

It is not logical to have and assertion if we are working with null safety, I think.

@pzentenoe
Copy link
Owner

I'm sorry guys I've been too busy in my work I haven't been able to evolve this package, for now I see it difficult, can you send me a pull request, I'll be happy to review it.
Best regards

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

3 participants