Aydan
Aydan

Reputation: 93

"The return type 'String?' isn't a 'void', as required by the closure's context."

The error I am receiving states "The return type 'String?' isn't a 'void', as required by the closure's context." the variable "_desc" is a string.

                    decoration: InputDecoration(labelText: 'Caption'),
                    validator: (value) {
                      return value!.isEmpty ? 'Description is required' : null;
                    },
                    onSaved: (value) {
                      return _desc = value;
                    },

Any help would be highly appreciated!

Upvotes: 0

Views: 4455

Answers (1)

Kevin Moore
Kevin Moore

Reputation: 6161

Ditch the return. Just assign _desc.

Upvotes: 5

Related Questions