Defining a Function
Let’s discuss functions and learn how to define our very own function in Dart.
Writing your first function
In this chapter, we will cover user-defined functions and learn how to write our very own functions. Let’s get straight to it and look at an example of a very basic user-defined function.
Note: Ignore the Driver Code throughout this lesson.
Press + to interact
void newPrint(){print("Function Called");}// Driver Codemain() {newPrint();}
The above function is not really of any use to us as all it does is print the statement Function Called
. However, regardless of what a function does, it follows a general syntax.
Code explanation
void
is telling us that the function does not return anything.
Create a free account to access the full course.
By signing up, you agree to Educative's Terms of Service and Privacy Policy