日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Flutter之基本数据类型测试

發布時間:2023/12/4 编程问答 38 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Flutter之基本数据类型测试 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1、Flutter的數據基本類型

Dart語言里一切皆為對象,所以如果沒有將變初始化,那么它的默認值為null

  • Number(int、doubkle)
  • String
  • Boolean(bool)?
  • List?
  • Map

?

?

?

?

?

?

?

2、測試代碼

void testData() {//Number包含了int和doubleint a = 4;int b = 8;print(a + b);int a1;if (a == null) {print('a == null');} else {print('a != null');}if (a1 == null) {print('a1 == null');} else {print('a1 != null');}double c = 5.9;double d = 6.4;print(c + d);//String類型var chen = 'chen';var yu = 'yu';var name = chen + yu;print(name);var hello = '''hello wordpublic static void main1''';print(hello);var word = """hello wordpublic stati void main2""";print(word);//Boolean類型bool isSelect = false;if (isSelect) {print('isSelect is true');} else {print('isSelect is false');}//List類型var list = [];list.add(1);list.add(2);print(list);print('size is ${list.length}');list.removeAt(0);print(list);print('size is ${list.length}');//Map類型var week = {'one':'test1', 'two':'test2'};print(week);print('week length is ${week.length}');week.putIfAbsent('three', () => 'test3');print(week);print('week length is ${week.length}');}

?

?

?

?

?

?

?

?

?

3、運行結果

I/flutter (24359): 12 I/flutter (24359): a != null I/flutter (24359): a1 == null I/flutter (24359): 12.3 I/flutter (24359): chenyu I/flutter (24359): hello word I/flutter (24359): public static void main1 I/flutter (24359): I/flutter (24359): hello word I/flutter (24359): public stati void main2 I/flutter (24359): I/flutter (24359): isSelect is false I/flutter (24359): [1, 2] I/flutter (24359): size is 2 I/flutter (24359): [2] I/flutter (24359): size is 1 I/flutter (24359): {one: test1, two: test2} I/flutter (24359): week length is 2 I/flutter (24359): {one: test1, two: test2, three: test3} I/flutter (24359): week length is 3

?

公眾號:記得關注我。

?

總結

以上是生活随笔為你收集整理的Flutter之基本数据类型测试的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。