3

type '() => Null' is not a subtype of type '(() => Map<String, dynamic>)?' of 'orElse'

How to get out from this error?

and this is the my code snippet as below.

      FutureBuilder<ActivityCheckPoints>(
              future: apiGetCheckPointsName(),
              builder: (context, snapshot) {
                if(snapshot.hasData)
                return Container(
              child: 
                MultiSelectFormField(
                chipBackGroundColor: Colors.blue,
                chipLabelStyle: TextStyle(fontWeight: FontWeight.bold),
                dialogTextStyle: TextStyle(fontWeight: FontWeight.bold),
                checkBoxActiveColor: Colors.blue,
                checkBoxCheckColor: Colors.white,
                dialogShapeBorder: RoundedRectangleBorder(
                borderRadius: BorderRadius.all(Radius.circular(12.0))),
                title: Text(_actpoints,
                      style: TextStyle(fontSize: 16),
                ),
                dataSource: snapshot.data!.listactiviticheckpoints!.map((value){
                      return {'display': '$value','value': value};
                }).toList(),
                textField: 'display',
                valueField: 'value',
                okButtonLabel: 'OK',
                cancelButtonLabel: 'CANCEL',
                hintWidget: Text(_actpointsdisplay,
                ),
               initialValue: _listActivityPointNames,
                onSaved: (value)  {
                if (value == null) return;
                setState(() { 
                _listActivityPointNames = value;
                });
          },
        ),
      );
      return Container();
              }
            ),
James Z
  • 12,209
  • 10
  • 24
  • 44

1 Answers1

0

I think this widget wasn't totally migrate to null-safety. So I separate it into a StatelessWidget and added the following annotation in the first line:

// @dart = 2.9

It must have the '//'.

Remember to add --no-sound-null-safety when running.

flutter run --no-sound-null-safety

For more about unsound null safety: https://dart.dev/null-safety/unsound-null-safety

Thank you @Nitrodon, for help me linking the issue (github.com/cetorres/multiselect_formfield/issues/38)