Flutter String格式化
请看原文: http://tryenough.com/flutter-stringformat
在Android和iOS平台都有相应的方法进行字符串的格式化,但是在flutter中却没有直接提供
在flutter上可以借助一个插件来进行格式化:
import 'package:sprintf/sprintf.dart';
例子
import 'package:sprintf/sprintf.dart'; void main() { print(sprintf("%04i", [-42])); print(sprintf("%s %s", ["Hello", "World"])); print(sprintf("%#04x", [10])); double seconds = 5.0; String name = 'Dilki'; List<String> pets = ['Cats', 'Dogs']; String sentence1 = sprintf('Sends %2.2f seconds ago.', [seconds]); String sentence2 = sprintf('Harry likes %s, I think %s likes %s.', [pets[0], name, pets[1]]); print(sentence1); print(sentence2); }
请看原文: http://tryenough.com/flutter-stringformat
相关推荐
Lzs 2020-10-23
聚合室 2020-11-16
零 2020-09-18
Justhavefun 2020-10-22
jacktangj 2020-10-14
ChaITSimpleLove 2020-10-06
Andrea0 2020-09-18
周游列国之仕子 2020-09-15
afanti 2020-09-16
88234852 2020-09-15
YClimb 2020-09-15
风雨断肠人 2020-09-04
卖口粥湛蓝的天空 2020-09-15
stulen 2020-09-15
pythonxuexi 2020-09-06
abfdada 2020-08-26
梦的天空 2020-08-25