• +91 9723535972
  • info@interviewmaterial.com

Dart Programming Interview Questions and Answers

Related Subjects

Question - Differentiate between required and optional parameters in Dart

Answer -

Required Parameters

Dart required parameters are the arguments that are passed to a function and the function or method required all those parameters to complete its code block.

findVolume(int length, int breath, int height) {
 print('length = $length, breath = $breath, height = $height');
}

findVolume(10,20,30);
Optional Parameters

Optional parameters are defined at the end of the parameter list, after any required parameters.
In Flutter/Dart, there are 3 types of optional parameters: - Named - Parameters wrapped by { } - eg. getUrl(int color, [int favNum]) - Positional - Parameters wrapped by [ ]) - eg. getUrl(int color, {int favNum}) - Default - Assigning a default value to a parameter. - eg. getUrl(int color, [int favNum = 6])

Comment(S)

Show all Coment

Leave a Comment




NCERT Solutions

 

Share your email for latest updates

Name:
Email:

Our partners