Why return statement is not working in this dart program?

Viewed 40

MY Code:

String fun(int age, String name)
{
  print("hi");
  return 'My name is $name and i am $age';
}

void main()
  {
   print("Hello! Good Morning good people.");
   fun(21,"Jasraj");   
  }

Output:

Hello! Good Morning good people. hi

My Question: Why return statement is not working?

See Image

1 Answers

fun return a string and to show, you need to wrap with print method.

void main() {
  print("Hel`enter code here`lo! Good Morning good people.");
  print(fun(21, "Jasraj"));
}

Or

  String result = fun(21, "Jasraj");
  print(result);
Related