• +91 9723535972
  • info@interviewmaterial.com

Dart Programming Interview Questions and Answers

Related Subjects

Question - How to declare async function as a variable in Dart?

Answer -

Async functions are normal functions with some sugar on top. The function variable type just needs to specify that it returns a Future:

class Example {
  Future Function() asyncFuncVar;
  Future asyncFunc() async => print('Do async stuff...');

  Example() {
    asyncFuncVar = asyncFunc;
    asyncFuncVar().then((_) => print('Hello'));
  }
}

void main() => Example();

Comment(S)

Show all Coment

Leave a Comment




NCERT Solutions

 

Share your email for latest updates

Name:
Email:

Our partners