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

'Icon' was called on null #1

Open
aissahadjsaid opened this issue Feb 14, 2020 · 18 comments
Open

'Icon' was called on null #1

aissahadjsaid opened this issue Feb 14, 2020 · 18 comments

Comments

@aissahadjsaid
Copy link

════════ Exception caught by widgets library ═══════════════════════════════════════════════════════
The following NoSuchMethodError was thrown building CurvedDrawer(dirty, dependencies: [Directionality, MediaQuery], state: _CurvedDrawerState#8b6a1(ticker inactive)):
The getter 'icon' was called on null.
Receiver: null
Tried calling: icon

The relevant error-causing widget was:
CurvedDrawer file:///D:/workspace/flutter/projects/kf_drawer/lib/main.dart:75:18
When the exception was thrown, this was the stack:
#0 Object.noSuchMethod (dart:core-patch/object_patch.dart:53:5)
#1 _CurvedDrawerState.build. (package:curved_drawer/curved_drawer.dart:180:34)
#2 MappedListIterable.elementAt (dart:_internal/iterable.dart:417:29)
#3 ListIterable.toList (dart:_internal/iterable.dart:221:19)
#4 _CurvedDrawerState.build (package:curved_drawer/curved_drawer.dart:182:22)

@suo801
Copy link

suo801 commented Mar 27, 2020

i had the same question,and had emil writer

@suo801
Copy link

suo801 commented Mar 27, 2020

by the way have you resolved this ?

@undrbridge
Copy link
Owner

undrbridge commented Mar 27, 2020 via email

@suo801
Copy link

suo801 commented Mar 28, 2020

Thank you. I will keep an eye on the results. And I'm working on it myself

@suo801
Copy link

suo801 commented Mar 28, 2020

wow,i just resolved.i made it! 我去掉了列表赋值
// _items = widget.items.map((item) {
// DrawerNavItem(
// icon: item.icon,
// label: item.label,
// color: widget.labelColor,
// background: widget.buttonBackgroundColor,
// size: widget.width / 3,
// );
// }).toList();
下面直接用widget.items,而不用_items,因为这里循环赋值有问题。

@AbdulrhmanAlani96
Copy link

Hi there , it's not work @suo801 , do you have another solve for it ?

@vilain-corentin
Copy link

In curved_drawer.dart,
List<DrawerNavItem> _items = [];

replace to map by :

widget.items.forEach((item) {
      _items.add(DrawerNavItem(
        icon: item.icon,
        label: item.label,
        color: widget.labelColor,
        background: widget.buttonBackgroundColor,
        size: widget.width / 3,
      ));
    });

@MarcoSchneider123
Copy link

Thank you vilain-corentin, i had the same issue and this resolved my issue

@sheen404
Copy link

It isn't working. Is there any other way to solve this?

@tanzilzubair
Copy link

It isn't working, is there another way to solve this?

@Sankalp1902
Copy link

None of them are working :(

@sonOfwidgets
Copy link

#5 Put a return statement or replace it with arrow function

@sollylabs
Copy link

Please write the whole updated code.

@sollylabs
Copy link

In curved_drawer.dart,
List<DrawerNavItem> _items = [];

replace to map by :

widget.items.forEach((item) {
      _items.add(DrawerNavItem(
        icon: item.icon,
        label: item.label,
        color: widget.labelColor,
        background: widget.buttonBackgroundColor,
        size: widget.width / 3,
      ));
    });

Please write the whole code

@kamal0s
Copy link

kamal0s commented Feb 6, 2021

just change code in the line just like this photo that will resolve problem
https://ibb.co/h20k2cc

@Vishesht
Copy link

This flutter dependency is showing error.
Use the Custom Curve Drawer in Flutter
Git hub Link :- https://github.com/Vishesht/Curved-Drawer-Flutter

@5hanth
Copy link

5hanth commented Mar 8, 2021

+1 #1 (comment) works well on local. can we expect this patch to get released? currently, this plugin is unusable on CI builds that download packages on app center which won't have this patch.

@gopaltalaviya
Copy link

Fixed with simple solution is that
Code:

 _items = widget.items.map((item) {
      DrawerNavItem(
        icon: item.icon,
        label: item.label,
        color: widget.labelColor,
        background: widget.buttonBackgroundColor,
        size: widget.width / 3,
      );
    }).toList();

Replace with 👍
Add return statement

_items = widget.items.map((item) {
      return DrawerNavItem(
        icon: item.icon,
        label: item.label,
        color: widget.labelColor,
        background: widget.buttonBackgroundColor,
        size: widget.width / 3,
      );
    }).toList();

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