The default value of an optional parameter must be constant

前端 未结 1 1330
情话喂你
情话喂你 2021-01-23 09:42

So Im creating this Event Tracker app and I have two screens which are the map and the events list. I am trying to get the place list to be equal to my places in my App state. B

相关标签:
1条回答
  • 2021-01-23 09:44

    A common workaround to requiring constant values for default arguments is to instead provide a sentinel argument as the default that can be const. Typically that sentinel argument can be null:

    class AppState {
       AppState({
        List<Place> places,
        ...
       }) : places = places ?? PlaceMapState.placeList,
            assert(places != null),
            assert(selectedCategory != null);
    
    0 讨论(0)
提交回复
热议问题