Programming in Dart: Functions & Closures

Jun 21 2022 · Dart 2.16, Flutter, DartPad

Part 1: Meet the Function

04. Understand Named Parameters

Episode complete

Play next episode

Next
About this episode
Leave a rating/review
See forum comments
Cinema mode Mark complete Download course materials
Previous episode: 03. Implement Optional Parameters Next episode: 05. Challenge: Create a Function

Get immediate access to this and 4,000+ other videos and books.

Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and 4,000+ professional videos in a single subscription, it's simply the best investment you can make in your development career.

Learn more Already a subscriber? Sign in.

Heads up... You've reached locked video content where the transcript will be shown as obfuscated text.

So far in defining functions, you will have noticed that often times, it’s difficult to determine the meaning of the value being passed into it.

bool isWithinTolerance(int value, [int min = 0, int max = 10]) {
  return min <= value && value <= max;
}
bool isWithinTolerance(int value, {int min = 0, int max = 10}) {
  return min <= value && value <= max;
}
print(isWithinTolerance(9, min: 7, max: 11));
print(isWithinTolerance(9, max: 11));
print(isWithinTolerance(9, max: 11, min: 5));
print(isWithinTolerance(9));
bool isWithinTolerance({ int value, int min = 0, int max = 10})
bool isWithinTolerance({ required int value, int min = 0, int max = 10})
print(isWithinTolerance(value: 9, max: 11, min: 5));