0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【Flutter/Dart】DartにおけるNullチェック、isEmpty、isNotEmptyの振る舞い

Posted at

DartにおけるNullチェック、isEmpty、isNotEmptyの振る舞い

image.png

テストコード

main.dart
void main() {
  String? testDataNull = null;
  String? testDataEmptyString = "";
  String? testDataString = "testData";
  
  print("testDataNull == null: ${testDataNull == null}");
  print("testDataNull != null: ${testDataNull != null}");
  print("testDataNull.isEmpty: ${testDataNull?.isEmpty}");
  print("testDataNull.isNotEmpty: ${testDataNull?.isNotEmpty}");
  
  print("--------------------------------");
  
  print("testDataEmptyString == null: ${testDataEmptyString == null}");
  print("testDataEmptyString != null: ${testDataEmptyString != null}");
  print("testDataEmptyString.isEmpty: ${testDataEmptyString?.isEmpty}");
  print("testDataEmptyString.isNotEmpty: ${testDataEmptyString?.isNotEmpty}");
  
  print("--------------------------------");
  
  print("testDataString == null: ${testDataString == null}");
  print("testDataString != null: ${testDataString != null}");
  print("testDataString.isEmpty: ${testDataString?.isEmpty}");
  print("testDataString.isNotEmpty: ${testDataString?.isNotEmpty}");
}

0
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?