flutter_collapsible_sidebar icon indicating copy to clipboard operation
flutter_collapsible_sidebar copied to clipboard

The method 'toDouble' was called on null.

Open JatinJD14296 opened this issue 5 years ago • 5 comments

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), ], ),

JatinJD14296 avatar Sep 12 '20 03:09 JatinJD14296

Please send entire code where the error occurs.

DrunkOnBytes avatar Sep 12 '20 15:09 DrunkOnBytes

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

dariolr avatar Jan 14 '21 09:01 dariolr

I have the same issue. Any solution?

ReniDelonzek avatar Mar 31 '21 00:03 ReniDelonzek

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.

DrunkOnBytes avatar Mar 31 '21 10:03 DrunkOnBytes

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

ReniDelonzek avatar Apr 06 '21 01:04 ReniDelonzek

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.

DrunkOnBytes avatar Nov 02 '22 20:11 DrunkOnBytes