简体   繁体   中英

The argument type 'ImageIcon' can't be assigned to the parameter type 'IconData?'. (Documentation)

I am using a library that requires an icon of type package:flutter/src/widgets/icon_data.dart aka IconData . I'd like to use my own.png file asset as an icon. I googled for solutions and everybody points out to the usage of ImageIcon . However when using this - the following error appears:

        CircularMenuItem(
            iconColor: GuiColors.textLight,
            color: GuiColors.primary,
            icon: ImageIcon(AssetImage("assets/icons/sword.png")),
            onTap: () {
              //callback
            }),

The error is:

The argument type 'ImageIcon' can't be assigned to the parameter type 'IconData?'. (Documentation)

I don't have the package that contains CircularMenuItem but my guess is icon parameter expects Icon whereas ImageIcon has a return type ImageIcon . In this scenerio i don't think you can use your own icon with this package

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM