I am getting type String is not a subtype of type int in my flutter project

Viewed 49

I downloaded a flutter project and tried to run it, but I get this error

type 'String' is not a subtype of type 'int'

And the error is pointing me the this code

int? identified = _allBackEnds.getUser(IDENTIFIED);

IDENTIFIED is defined in a file called strings.dart like this

const IDENTIFIED = "identified";

as well as other strings such as

const FIRST_NAME = "firstName";
const LAST_NAME = "lastName";

I notice the problem causing the error is because IDENTIFIED is a string.

What I don't understand is, in the same file where there is an error there are other variables like this

   String fName = _allBackEnds.getUser(FIRST_NAME);
   String lName = _allBackEnds.getUser(LAST_NAME);

And they all return data in a text widget

  Text(
    fName.capitalize()! + " " + lName.capitalize()!,
  ), 

So I don't understand how the string is been used to return data and why I am getting an error

PS - This might sound confusing, and I hope you understand the question

1 Answers

Can you provide the signature of the _allBackEnds.getUser() method? I think that you need to change int? to String? in the first line of your question.

String? identified = _allBackEnds.getUser(IDENTIFIED);
Related