flutter evaluate if var is integer or string

You can use the keyword is or switch over runtimeType :

dynamic foo = 42;
if (foo is int) {
  print("Hello");
}
switch (foo.runtimeType) {
  case int: {
    print("World");
  }
}

Consider using is instead of directly using runtimeType. As is works with subclasses. While using runtimeType is a strict comparison.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)