#30DaysMasterFlutter
Learn the basics of Flutter and Dart in 30 days! We provide a roadmap, resources, and project ideas to help you along your journey.
back to 30 Days to Master FlutterDay 4
In Dart, a function is a block of code that performs a specific task and can be called from other parts of the program. They can take parameters and return values, helping to organize and simplify code.
Project - Palindrome Checker
Write a function to check if a given string is a palindrome.
- A palindrome is a word, phrase, or sequence that reads the same backward as forward, e.g., madam or nurses run.
- Use the function to check if a given string is a palindrome. Print the answer to the console.
By the end of this day, you should have a good understanding of how to write and call functions in Dart.
int add(int a, int b) {
return a + b;
}
This function takes two integer parameters, adds them together, and returns the result.
void main() {
int result = add(3, 4);
print(result); // 7
}
This calls the add function with the arguments 3 and 4, stores the result in the “result” variable, and prints the result to the console.
void greet() {
print('Hello, world!');
}
void main() {
greet(); // prints "Hello, world!" to the console
}
Here are some resources for Day 5: Dart Functions:
Enjoying? Tell your friends.
Learn the basics of Flutter and Dart in 30 days! We provide a roadmap, resources, and project ideas to help you along your journey.
back to 30 Days to Master FlutterJoin our community on Discord to connect with fellow learners, share your progress, and get help with any questions you may have throughout the #30DaysMasterFlutter challenge. Join now and get started on your journey to mastering Dart and Flutter!