El Hombre Sin Nombre
El Hombre Sin Nombre

Reputation: 3092

Flutter - String to Int, then int to String

I want to do a simple conversion: Integer to String. Like this.

   String select= (int.parse(widget.data['object']['element'])+1).toString();

But return this error

Unhandled Exception: type 'int' is not a subtype of type 'String'

Anybody know what is the error?

Upvotes: 0

Views: 1123

Answers (2)

Aamil Silawat
Aamil Silawat

Reputation: 8229

Try this way

int data = int.parse(widget.data['object']['element'] + 1);

String select=data.toString();

Upvotes: 2

Bansook Nam
Bansook Nam

Reputation: 591

I think widget.data['object']['element'] value is already int.

Try

(widget.data['object']['element'] +1).toString();

Upvotes: 0

Related Questions