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

The method 'toDouble' was called on null. #1

Closed
JatinJD14296 opened this issue Sep 12, 2020 · 6 comments
Closed

The method 'toDouble' was called on null. #1

JatinJD14296 opened this issue Sep 12, 2020 · 6 comments
Labels
bug Something isn't working question Further information is requested

Comments

@JatinJD14296
Copy link

The method 'toDouble' was called on null.
Receiver: null
Tried calling: toDouble()

The relevant error-causing widget was:
CollapsibleSidebar file:///Users/imac/Documents/workspace/fittrack_flutter/lib/features/home/presentation/pages/home_screen.dart:48:21
When the exception was thrown, this was the stack:
#0 Object.noSuchMethod (dart:core-patch/object_patch.dart:51:5)
#1 double.* (dart:core-patch/double.dart:36:23)
#2 _CollapsibleSidebarState.build (package:collapsible_sidebar/collapsible_sidebar.dart:177:46)
#3 StatefulElement.build (package:flutter/src/widgets/framework.dart:4681:28)
#4 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4564:15)
...

ERROR MOVE ON THIS LINE...

Stack(
alignment: Alignment.topCenter,
children: [
CollapsibleItemSelection(
height: _maxOffsetY,
======> offsetY: _maxOffsetY * _selectedItemIndex,
color: widget.selectedIconBox,
duration: widget.duration,
curve: widget.curve,
),
Column(children: _items),
],
),

@DrunkOnBytes
Copy link
Owner

Please send entire code where the error occurs.

@DrunkOnBytes DrunkOnBytes added bug Something isn't working question Further information is requested labels Sep 18, 2020
@dariolr
Copy link

dariolr commented Jan 14, 2021

I had the same problem, maybe depend on the way you build CollapsibleItem list.

in my case...

List<CollapsibleItem> _buildCollapsibleItems(List<String> menuNames) {
    final List<CollapsibleItem> result = [];
    menuNames.asMap().forEach((index, value) => {
          result.add(CollapsibleItem(
              isSelected: _selectedIndex == index,
              text: value,
              icon: _iconByMenuName(value),
              onPressed: () => setState(() {
                    _headline = value;
                    _selectedIndex = index;
                  })))
        });

    return result;
}

_selectedIndex is set to zero on initState

@ReniDelonzek
Copy link

I have the same issue. Any solution?

@DrunkOnBytes
Copy link
Owner

Can you guys send the code and the line number as shown by the terminal where the error is occurring. @dariolr @ReniDelonzek

I'll try to see where this exception is coming from.

@ReniDelonzek
Copy link

Hello @RyuuKenshi , the error happens when no item is pre-selected. I fixed this on my fork, but I didn't submit it because I did a few more increments that may not be relevant here. But set _selectedItemIndex = 0; in initState should resolve

@DrunkOnBytes
Copy link
Owner

Hi @JatinJD14296, @dariolr, @ReniDelonzek, I have implemented some changes to this package.
Please check once if this problem has been resolved, and if yes then close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants