loading...
Cover image for Functions in Dart

Functions in Dart

jay_tillu profile image Jay Tillu😎 ・3 min read
  • A function is a group of statements that perform a specific task.

  • Functions are mostly used to automate the repeated task. They are basically used to divide the large program into smaller chunks.

  • Divide our program into smaller chunks makes it more organized and manageable. Also, it avoids repetition and makes our code reusable.

  • The bad thing about function is they are famous with several names. Different programming languages name them differently. For example functions, methods, sub-routines, procedures, etc. When you hear any one of them just imagine about the same concept.

Advantages of Functions


Functions have three major advantages:

  1. They make our code manageable.
  2. They reduce the boilerplate code
  3. They make our code reusable.

Types of Functions


There are basically two types of functions in programming.

  1. Built-in functions
  2. User-define functions

Built-in functions

  • Built-in functions are functions that is comes with language and they are ready to use. For example in dart print(), readLineSync(), tryParse() are built-in functions.

  • In dart, there are many libraries, in which all built-in functions are stored and ready to help you. Dart SDK comes with many pre-built libraries like a dart: core, dart: async, dart: collection, etc.

Dart libraries come in three major flavors:

  • Core libraries — Core libraries come directly with the Dart SDK. You can find detail documentation on Dart API.

  • Community Shared Libraries — Some libraries are shared with the Dart community and they are distributed as library packages and published at Pub Site. The pub tool allows us to create, publish and manage library packages.

  • You can also use libraries from GitHub, from a URL, or from a local path. Please visit this for more information.

User define functions

  • User-define functions are functions that are created by programmers. You can also create functions according to your needs and that functions will be called User-define functions.

That’s it for function’s introduction guys. I’ll post more articles on functions soon. So please check them as well. Feel free to share with me if I miss something I will love to learn it from you.

Remember no teacher, no book, no video tutorial, or no blog can teach you everything. As one said Learning is Journey and Journey never ends. Just collect some data from here and there, read it, learn it, practice it, and try to apply it. Don’t feel hesitate that you can’t do that or you don’t know this concept or that concept. Remember every programmer was passed from the path on which you are walking right now. Remember Every Master was Once a Beginner. Work hard and Give your best.

Till Then Keep Loving, Keep Coding. And just like always I’ll surely catch you up in the next article.

For more information please visit


Wanna get in touch with me? Here are links. I’ll love to become your friend. 😊
Twitter
Facebook
Instagram
Medium
or just mail me at jayviveki13@gmail.com

Posted on by:

jay_tillu profile

Jay Tillu😎

@jay_tillu

🌏 विधायास्य धमॅस्य संरक्षणम् 🌍 ☀️ Society before Self ☀️ 🙏🏻 Humanism by Religion 🙏🏻 💻 Work for Mankind 💻 🌐 Believes in वसुधैव कुटुम्बकम् 🌐

Discussion

pic
Editor guide