Flutter将int变量转换为字符串 [英] Flutter convert int variable to string

查看:101
本文介绍了Flutter将int变量转换为字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Flutter的新手,我想知道(对我来说)要如何找到一个如何转换变量
var int counter = 0的解决方案有多难?
放入变量
var字符串$ counter = 0;

I'm new with Flutter and I wonder about how difficult is (for me) to find a solution on how to convert my variable var int counter = 0; into a variable var String $counter = "0";

我搜索了很多
,但是却发现了更多像
var myInt = int.parse('12345');

I searched a lot but more at all I only found something like var myInt = int.parse('12345');

不适用于
var myInt = int.parse( counter);

that doesn't work with var myInt = int.parse(counter);

推荐答案

使用 toString 和/或 toRadixString

  int intValue = 1;
  String stringValue = intValue.toString();
  String hexValue = intValue.toRadixString(16);

或者,如在纪念中一样

  String anotherValue = 'the value is $intValue';

这篇关于Flutter将int变量转换为字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆