Skip to content

"getInstalledWidgets" WidgetConfigurationIntent error - can't parse list of AppEntity #376

@galacticgibbon

Description

@galacticgibbon

What happened?

I have an intent that looks like this

import AppIntents

@available(iOS 17.0, *)
struct EntryTypeEntity: AppEntity, Identifiable, Codable {
    var id: String
    var displayString: String
    
    static var typeDisplayRepresentation = TypeDisplayRepresentation(name: "Entry Type")
    static var defaultQuery = EntryTypeQuery()
    
    var displayRepresentation: DisplayRepresentation {
        DisplayRepresentation(title: "\(displayString)")
    }
    
    static let task = EntryTypeEntity(id: "task", displayString: "Task")
    static let note = EntryTypeEntity(id: "note", displayString: "Note")
    static let event = EntryTypeEntity(id: "event", displayString: "Event")
    
    static let all = [task, note, event]
}

@available(iOS 17.0, *)
struct EntryTypeQuery: EntityQuery {
    func entities(for identifiers: [String]) async throws -> [EntryTypeEntity] {
        return EntryTypeEntity.all.filter { identifiers.contains($0.id) }
    }
    
    func suggestedEntities() async throws -> [EntryTypeEntity] {
        return EntryTypeEntity.all
    }
    
    func defaultResult() async -> EntryTypeEntity? {
        return .task
    }
}

And a widget config intent like this

import AppIntents
import WidgetKit

@available(iOS 17.0, *)
struct AppWidgetConfigIntent: WidgetConfigurationIntent {
    static var title: LocalizedStringResource = "Configure Widget"
    static var description = IntentDescription("Choose what to display in your widget")
    
    @Parameter(title: "List")
    var list: ListEntity?
    
    @Parameter(title: "Entry Types")
    var entryTypes: [EntryTypeEntity]?
    
    @Parameter(title: "Show Overdue Count", default: false)
    var showOverdueCount: Bool
    
    @Parameter(title: "Button Destination")
    var buttonDestination: ButtonDestinationEntity?
    
    init() {
        self.entryTypes = []
        self.showOverdueCount = false
    }
}

What do you expect?

getInstalledWidgets to work

Relevant log output

Flutter: 

Unsupported value: Runner.EntryTypeEntity(id: "task", displayString: "Task") of type __SwiftValue

Swift:

An abort signal terminated the process. Such crashes often happen because of an uncaught exception or unrecoverable error or calling the abort() function.


At line "result(widgetInfoList)"

Execute in a terminal and put output into the code block below

Output of: flutter doctor -v

On which Platform do you experience this issue?

iOS

Other information

No response

Are you interested in working on a PR for this?

  • I want to work on this

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingp:iOSiOS Home Screen Widgets

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions