This is part of the "Flutter Fundamentals" learning path. View Path

Programming in Dart: Functions & Closures

Jun 21 2022 · Video Course (1 hr, 0 mins) · Beginner

You’ll continue to build on the lessons taught in the Programming in Dart series by learning how to write functions to maximize code reuse as well as to filter and map collections. You’ll also be introduced to self-contained functions called closures to take your Dart code to the next level.

Version

  • Dart 2.16, Flutter, DartPad

Meet the Function

Introduction

2:44 Free

Gain an understanding of functions in Dart and then receive an overview of all the various concepts that will be covered in the first part of the course.

1

Use Functions

4:45 Free

Meet the function! Learn how to define functions and then how to use them throughout your code.

2

Make your functions easier to use by providing options to the function caller. Of course, doing so requires you to write your parameters in a special way.

3

Named parameters make your function easier to use and easier to read. Learn how to define named parameters to make your code self documenting.

4

Now that you have a good idea about functions, your first challenge in this course is to write your very own function. Don’t worry - it’s not too hard.

5

One of the coolest parts of functions is storing them and passing them around like any other variable. This episode will get you started.

6

Learn how to define an alias to functions to make your them easier to both use & read.

7

Dart provides a nice little shortcut when writing functions called arrow notation. While it makes your functions easier to read, it raises questions about the void return type.

8

Conclusion

1:19

This episode wraps up the first part of this course, but things are just getting started. You’ll get a review of what was covered.

9

Learn Anonymous Functions & Closures

In this next part, you’ll learn about creating anonymous functions and closures and the capabilities that they provide to your code.

10

Learn the basics of writing anonymous functions as well as why you’d even want to use them in the first place.

11

Put anonymous functions to use by using the map function and the filter function on Lists to both transform and filter values.

12

In this first challenge of the part, you’ll put your knowledge of anonymous methods to the test by filtering out a list.

13

Understand the basics of closures - why you’d use them and how they can maintain their own internal state.

14

Learn the theory behind the idea of generics; why it is useful and how it can make your easier to maintain.

15

Understand the basics of writing generic functions. That is, writing a function that can be used by many different types.

16

Now that you understand generics, you’ll put your new knowledge to the test by writing a method that filters a collection of numbers.

17

Conclusion

2:08

With this course complete, learn about some next steps as well as some additional resources to continue your Dart learning journey.

18

Next course in this Learning Path

Who is this for?

This course is written for people who are new to programming! If you don’t know the difference between a function or an object, you’ve come to the right place.

Before starting, you should have watched Programming in Dart: Fundamentals and Programming in Dart: Control Flow & Collections. This course will build on those foundational concepts and expand on your understanding of the Dart programming language.

Covered concepts

  • Functions
  • Optional & named parameters
  • Function variables
  • Alias functions
  • Arrow notation
  • Anonymous functions
  • Closures
  • Generics

Contributors

Comments