{"componentChunkName":"component---src-templates-lesson-post-js","path":"/lesson/about-dart","result":{"data":{"strapiLesson":{"id":"Lesson_1","author":{"email":"eric@ericwindmill.com","username":"Eric Windmill","twitter":"ericwindmill"},"content":"\n<div class='post-toc'>\n\nOn this page\n\n* [Meet Dart](#about-dart)\n* [Why Does Flutter Use Dart](#why-does-flutter-use-dart)\n\n</div>\n\n### About Dart\n\n> Dart is an application programming language that's easy to learn, easy to\n> scale, and deployable everywhere. Google depends on Dart to make very large apps.\n> -dartlang.org\n\nThe first hurdle for most would-be Flutter developers is being convinced to\n learn a new, sparsely used Language: Dart. (Although, Dart has been growing\n like crazy, thanks to Flutter. More on that in a bit.)  \n \nIn order to write Flutter apps, it's important that you also learn Dart. We\n'll do that first:\n\nDart is a programming language. And programming languages can be, as it turns\nout, hard to learn. The fundamentals of Dart are similar to all higher-level\nlanguages. You'll find familiarity in Dart syntax if you're coming from\nJavaScript, Java, or any other C-like language. You'll feel comfortable with\nDart's object-oriented design if you're coming from Ruby or Python.\n\nDart excels at being a \"safe\" language to learn. Google didn't set out to\n create anything innovative with Dart. Google wanted to make a language that\n was simple and productive and that could be compiled into JavaScript. What\n Google came up with, it turns out, works well for writing UIs.\n \nIn a nutshell, Dart is an object-oriented, class defined, single inheritance\nlanguage using a C-style syntax that transcompiles optionally into\nJavaScript. It supports interfaces, mixins, abstract classes, reified\ngenerics, optional typing, and a sound type system.\n\nLastly, Dart is always improving quite a bit. It is very much in constant\n development. Don't worry, though. There won't be any new breaking changes\n , just improvements and additional features.\n\n### Why Does Flutter Use Dart?\n\nTo us, the mobile developers, Flutter appears to be nothing more than a Dart\nlibrary (although it is much more under the hood). So, why does Flutter rely\nso heavily on this relatively unknown language?\n\nAccording to members of the Flutter team themselves, there are several\n reasons. Let's get the controversial reason out of the way first:  \n\nDart is owned and maintained by Google. I think Google owning Dart _is_ an\n advantage. In the last few years, Dart has made great strides to be a nice\nlanguage specifically for writing modern UIs. The Dart team and Flutter team\n get to work closely together on feature development. This relationship\n  allows Dart to support Flutter, rather than Flutter rely on outside forces. \n\n- Dart supports both just in time (JIT) compiling and ahead of time (AOT\n) compiling:\n-- The AOT compiler changes Dart into efficient native code. This makes Flutter\n fast (a win for the user and the developer), but it also means that (nearly) the entire framework is written in Dart. For you, the developer, that means you can customize almost everything.\n-- Dart's optional JIT compiling allows hot-reloading to exist. Fast\n development and iteration is a key to the joy of using Flutter.\n- Dart is object-oriented. This makes it easy to write visual user\n experiences with Dart, with no need for a markup language.\n- Dart is a productive, predictable language. Whether you come from a dynamic language or a static\n  language, you can get up and running with ease. \n- The type system and object orientation make it easy to reason about writing\n reusable components for the UI. \n- And, Dart includes a few functional programming features that make it\n easier to turn your data into pieces of UI.\n - Finally, asynchronous, stream -based programming features are first-class\ncitizens in Dart. These features are used heavily in reactive programming, which is the paradigm of today. \n\nLastly, Dart excels at being a language that's easy to learn. As a co-worker\n of mine said about hiring, \"We don't have to find Dart people, only smart people.\" \n","updated_at":"Sunday, 12th of July, 2020","slug":"about-dart","strapiId":1,"title":"About Dart","tutorial":{"category":"Dart","title":"Getting Started with Dart"}},"strapiTutorial":{"lessons":[{"author":1,"content":"\n<div class='post-toc'>\n\nOn this page\n\n* [Meet Dart](#about-dart)\n* [Why Does Flutter Use Dart](#why-does-flutter-use-dart)\n\n</div>\n\n### About Dart\n\n> Dart is an application programming language that's easy to learn, easy to\n> scale, and deployable everywhere. Google depends on Dart to make very large apps.\n> -dartlang.org\n\nThe first hurdle for most would-be Flutter developers is being convinced to\n learn a new, sparsely used Language: Dart. (Although, Dart has been growing\n like crazy, thanks to Flutter. More on that in a bit.)  \n \nIn order to write Flutter apps, it's important that you also learn Dart. We\n'll do that first:\n\nDart is a programming language. And programming languages can be, as it turns\nout, hard to learn. The fundamentals of Dart are similar to all higher-level\nlanguages. You'll find familiarity in Dart syntax if you're coming from\nJavaScript, Java, or any other C-like language. You'll feel comfortable with\nDart's object-oriented design if you're coming from Ruby or Python.\n\nDart excels at being a \"safe\" language to learn. Google didn't set out to\n create anything innovative with Dart. Google wanted to make a language that\n was simple and productive and that could be compiled into JavaScript. What\n Google came up with, it turns out, works well for writing UIs.\n \nIn a nutshell, Dart is an object-oriented, class defined, single inheritance\nlanguage using a C-style syntax that transcompiles optionally into\nJavaScript. It supports interfaces, mixins, abstract classes, reified\ngenerics, optional typing, and a sound type system.\n\nLastly, Dart is always improving quite a bit. It is very much in constant\n development. Don't worry, though. There won't be any new breaking changes\n , just improvements and additional features.\n\n### Why Does Flutter Use Dart?\n\nTo us, the mobile developers, Flutter appears to be nothing more than a Dart\nlibrary (although it is much more under the hood). So, why does Flutter rely\nso heavily on this relatively unknown language?\n\nAccording to members of the Flutter team themselves, there are several\n reasons. Let's get the controversial reason out of the way first:  \n\nDart is owned and maintained by Google. I think Google owning Dart _is_ an\n advantage. In the last few years, Dart has made great strides to be a nice\nlanguage specifically for writing modern UIs. The Dart team and Flutter team\n get to work closely together on feature development. This relationship\n  allows Dart to support Flutter, rather than Flutter rely on outside forces. \n\n- Dart supports both just in time (JIT) compiling and ahead of time (AOT\n) compiling:\n-- The AOT compiler changes Dart into efficient native code. This makes Flutter\n fast (a win for the user and the developer), but it also means that (nearly) the entire framework is written in Dart. For you, the developer, that means you can customize almost everything.\n-- Dart's optional JIT compiling allows hot-reloading to exist. Fast\n development and iteration is a key to the joy of using Flutter.\n- Dart is object-oriented. This makes it easy to write visual user\n experiences with Dart, with no need for a markup language.\n- Dart is a productive, predictable language. Whether you come from a dynamic language or a static\n  language, you can get up and running with ease. \n- The type system and object orientation make it easy to reason about writing\n reusable components for the UI. \n- And, Dart includes a few functional programming features that make it\n easier to turn your data into pieces of UI.\n - Finally, asynchronous, stream -based programming features are first-class\ncitizens in Dart. These features are used heavily in reactive programming, which is the paradigm of today. \n\nLastly, Dart excels at being a language that's easy to learn. As a co-worker\n of mine said about hiring, \"We don't have to find Dart people, only smart people.\" \n","created_at":"2020-07-11T16:32:17.620Z","id":1,"slug":"about-dart","title":"About Dart","tutorial":1,"updated_at":"2020-07-12T16:33:23.260Z"},{"author":1,"content":"In order to run Dart on your machine, you'll need to install the Dart SDK.\n\n> The following instructions install Dart 2. This book will be using Dart 2; Dart 1 will not work! If you already have the Dart SDK on your machine, ensure that it's version 2.0.0 or greater.\n\nInstalling the Dart SDK is straight forward if you use the command line. To check if you have Dart installed already, use the `which dart` command (on MacOS).\n\n```shell script\n$ which dart\n\n# should print \n=> /usr/local/bin/dart\n```\n\nOtherwise, install the SDK using the instructions for your machines operating system.\n\n### Mac OS\n\nIf you're using a Mac, it's likely that you have a program called Homebrew on your computer. If not, you need to install it. Homebrew is a command-line program that lets you download and manage software packages from the terminal.\n\nWe can install it easily from the command line. First, check to see if its installed:\n\n```shell script\n$ brew -v\n```\n\nIf your terminal prints `Homebrew 1.x.x`, then you're good to go. Otherwise, you need to install Homebrew. You can find instructions for installing Homebrew via the command line at https://brew.sh.\n\nHomebrew will walk you through the steps in your terminal.\n\nSecond, install Dart SDK. Thanks to Homebrew, this is incredibly easy.\n\n```shell script\n$ brew tap dart-lang/dart\n$ brew install dart\n```\n\nNow, in your terminal, run this command to make sure everything is in its right place:\n\n```shell script\n$ dart -v\n\n=> Dart VM version: 2.x.x...\n```\n\n### Windows\n\nOn Windows, the easiest way to install Dart is via the package manager, Chocolately. With Chocolatey on your machine, you simply have to run:\n\n```shell script\nC:\\> choco install dart-sdk\n```\n\n### Linux\n\nThe easiest way to install on Ubuntu is with this series of steps. Using all these commands will ensure that Dart automatically updates whenever the newest version is released.\n\nA one-time setup step:\n```shell script\n$ sudo apt-get update\n$ sudo apt-get install apt-transport-https\n$ sudo sh -c 'curl https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -'\n$ sudo sh -c 'curl https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_stable.list > /etc/apt/sources.list.d/dart_stable.list'\n```\n\nNow, install the Dart SDK:\n```shell script\n$ sudo apt-get update\n$ sudo apt-get install dart\n","created_at":"2020-07-12T16:26:34.263Z","id":2,"slug":"install-dart-on-your-machine","title":"Install Dart on your machine","tutorial":1,"updated_at":"2020-07-25T15:18:55.405Z"},{"author":1,"content":"In a previous lesson, you saw a program that print's \"Hello, World\" to the console. \n\n```dart\nvoid main() {\n  print('Hello, World!');\n}\n```\n\n`print` is used to log to the console. It's often helpful when you're debugging a Dart program.\n\n```run-dartpad:theme-light:run-false:split-60\nvoid main() {\n    // change string to print whatever you'd like!\n    print(\"Hello, World!\");\n}\n``` \n\n","created_at":"2020-07-12T16:32:32.354Z","id":8,"slug":"print-to-the-console","title":"Print to the console","tutorial":1,"updated_at":"2020-07-12T16:33:23.260Z"},{"author":1,"content":"For Flutter and Dart use, I can only recommend these two text editors:\n\n* VS Code\n* JetBrains Intellij (or Android Studio)\n\nBoth of these editors have officially-supported plugins for Dart. \n\nVSCode is probably the best completely free IDE that exists. Every web developer on the planet is jumping ship to VSCode. It's the return of the IDE in the web world. And it's a fantastic option.\n\nThat said, Intellij is truly full-featured, and that's what I recommend its use. An unfortunate part of writing code is that we also have to deal with managing a project, and an IDE like Intellij makes your life much easier on that front. Intellij Community Edition is free, and the Dart and Flutter features are fully supported in the free version.\n\n*Summer 2020 update:* Intellij is  the editor for me, BUT it seems like the Dart and Flutter teams are prioritizing VSCode these days. This is likely because it's free, popular, and more accessible to all operating systems. It just makes sense in a global community of developers. If it's all the same to you, I'd go with VS Code. That said, if you're someone that prefers robust IDE's like me, there is no downside to Intellij.","created_at":"2020-07-12T16:30:19.074Z","id":4,"slug":"text-editors-intellij-and-vs-code","title":"Text Editors: Intellij and VSCode","tutorial":1,"updated_at":"2020-07-12T16:33:23.260Z"},{"author":1,"content":"The documentation for Dart and (especially) Flutter are fantastic. It's clear that Google has put a great deal of time into the entire ecosystem. If you need a quick reference, or additional examples to compliment Flutter by Example, you can find Dart documentation at [dart.dev] and Flutter documentation at [flutter.dev].\n\n### Pub\n\n[Pub](pub.dev) is Dart's dependency management system and library. If you're looking for an open-sourced library to solve a problem for any Dart (and Flutter) program, you'll find there.","created_at":"2020-07-12T16:31:01.327Z","id":5,"slug":"resources-documentation-and-pub-dev","title":"Resources: Documentation and Pub.dev","tutorial":1,"updated_at":"2020-07-12T16:33:23.260Z"},{"author":1,"content":"In order to write _any_ Dart program, be it a script or a Flutter app, you must define a function called `main`.\n\n```dart\nvoid main() {\n  print('Hello, Dart');\n}\n```\n\nThis function tells Dart where the program starts, and it must be in the file that is considered the \"entry point\" for you program. By convention, this will be in a file called `main.dart`.\n\nThe main function can execute any code within it's code block that you'd like it to. \n\nYou must have exactly one `main` function in your program.\n\nIn general, your main function will likely initiate any pre-processing needed for your program, and end with a function call that runs the rest of your app. Some examples:\n\n### Main function in simple printing script\n\n```dart\nvoid main() {\n  // calls to separate function\n  // which handles main functionality\n  printGreeting();\n}\n```\n\n### Main in a Flutter app\n\n```dart\nvoid main() {\n  // any preprocessing can be done here, such as determining a device location\n  //\n  // runApp is a Flutter function that runs your Flutter app\n  runApp(MyApp());  \n}\n```\n\n###  Main function in an AngularDart app \n\n```dart\nvoid main() {\n  // runApp is also used in AngularDart\n  runApp(ng.AppComponentNgFactory);\n}\n```","created_at":"2020-07-12T16:32:06.288Z","id":7,"slug":"the-main-function","title":"The main function","tutorial":1,"updated_at":"2020-07-12T16:33:23.260Z"},{"author":1,"content":"Like all good programming tutorials, let's start by printing \"Hello, World\" to the console. In\n the next few lessons, we'll look at the individual components of this code sample.\n\n```dart\nvoid main() {\n  print('Hello, World!');\n}\n```\n\n```text\nOutput:\nHello, World!\n```\n\nI recommend running this example in [Dartpad](dartpad.dev).\n\n\n\n\n","created_at":"2020-07-12T16:31:30.794Z","id":6,"slug":"hello-world","title":"Hello World","tutorial":1,"updated_at":"2020-07-12T16:33:23.260Z"},{"author":1,"content":"[Dartpad](dartpad.dev) is a browser-based text editor that can execute Dart code, created by the Dart team. It's a \"playground\" or \"scratchpad\" of sorts, useful for testing  small pieces of code. If you're just starting out with Dart, you can use Dartpad to get your feet wet without having to install the Dart SDK and IDE plugins. \n\n\nIt's features include a linter, analyzer, and embedded web view, enabling you to play with HTML and CSS along side your Dart code. Dartpad is a resource that would be useful to use while following along with examples and tutorials on Flutter By Example. \n\nOn Flutter By Example, we'll make heavy use of DartPad, and it's embedded right in the page, so you never have to leave the page. It looks like this when embedded in the page:\n\n<pre>\n    <code class=\"language-run-dartpad:theme-light:mode-dart:split-60:width-100%:height-600px\">\n        main() => print(\"Hello, World!\");\n    </code>\n</pre>\n\nIf you'd rather work in your own text editor, you can find instructions to install Dart [on the Dart homepage](dart.dev).","created_at":"2020-07-12T16:27:03.138Z","id":3,"slug":"dartpad","title":"Dartpad","tutorial":1,"updated_at":"2020-07-25T21:20:39.221Z"}]},"strapiTableOfContents":{"contents":"{\n  \"Dart\": {\n    \"Getting Started with Dart\": [\n      \"About Dart\",\n      \"Install Dart on your machine\",\n      \"Dartpad\",\n      \"Text Editors: Intellij and VSCode\",\n      \"Resources: Documentation and Pub.dev\",\n      \"Hello World\",\n      \"The main function\",\n      \"Print to the console\"\n    ],\n    \"Dart Fundamentals\": [\n      \"Values and variables\",\n      \"Comments\",\n      \"const and final variables\",\n      \"Arithmetic and Comparison Operators\",\n      \"Assignment Operators\",\n      \"Logical Operators\",\n      \"Null Aware Operators\",\n      \"Type Test Operators\",\n      \"Bitwise and Shift Operators\",\n      \"Control Flow: if, else, else if\",\n      \"Switch statements and case\",\n      \"Ternary Conditional operator\",\n      \"Loops: for and while\",\n      \"Anatomy of Dart Functions\",\n      \"Arrow functions\",\n      \"Function arguments: default, optional, named\",\n      \"Lexical Scope\",\n      \"Cascade notation\"\n    ],\n    \"Data Types\": [\n      \"Intro to Dart's Type System\",\n      \"Numbers\",\n      \"Strings\",\n      \"Booleans\",\n      \"dynamic\",\n      \"lists\",\n      \"sets\",\n      \"maps\"\n    ],\n    \"Object-Oriented Programming\": [\n      \"Intro to OOP\",\n      \"Classes\",\n      \"Constructors\",\n      \"Properties and methods\",\n      \"Methods: static, private, etc\",\n      \"Getters and setters\",\n      \"Extending classes (inheritance)\",\n      \"Initializer lists and final properties\",\n      \"Factory methods\",\n      \"Singletons\",\n      \"Abstract classes (and interfaces)\",\n      \"Mixins\",\n      \"Extension methods\"\n    ],\n    \"Iterables, Iterators, and Collections\": [\n      \"What are collections (and iterables)?\",\n      \"Looping: for-in and forEach\",\n      \"Reading elements pt 1: first, last\",\n      \"Adding elements: add and insert (all)\",\n      \"Checking for elements: contains, indexOf, any, every\",\n      \"Removing elements: remove, clear, removeWhere\",\n      \"Filtering elements: where, takeWhile, and skipWhile\",\n      \"Changing elements: map and expand\",\n      \"Deriving values from elements: fold, reduce, join\",\n      \"Type casting collections: cast, as, retype, toSet, toList\",\n      \"Iterators: understanding and creating your own\",\n      \"Iterable-like methods on maps (and putIfAbsent)\"\n    ]\n  },\n  \"Flutter\": {\n    \"Getting started with Flutter\": [\n      \"About Flutter\",\n      \"IDEs and resources\"\n    ],\n    \"Widgets\": [\n      \"Intro to Widgets\",\n      \"Widget types: Stateful and Stateless\",\n      \"StatefulWidget lifecycle\",\n      \"The Widget tree\",\n      \"BuildContext\",\n      \"Inherited Widgets\",\n      \"Thinking in widgets\"\n    ],\n    \"Intro Flutter App\": [\n      \"Intro and Setup\",\n      \"Data Model and HTTP\",\n      \"Build a custom widget\",\n      \"ListView and builder pattern\",\n      \"Gradient Backgrounds\",\n      \"Routing: Add a detail page\",\n      \"Routing 2: Add a form page\",\n      \"User Input\",\n      \"Sliders and Buttons\",\n      \"Snackbars and Dialogs\",\n      \"Built-in Animation: AnimatedCrossFade\",\n      \"Built-in Animation: Hero transition\"\n    ],\n    \"Custom Animation: Progress Indicator\": [\n      \"Intro and Overview\",\n      \"Build the example app boiler-plate\",\n      \"Custom Widget: Peg\",\n      \"Tween and AnimationController classes\",\n      \"Tween by example\",\n      \"Using Tweens and Intervals\",\n      \"Wrap the Pegs in AnimatedWidgets\",\n      \"Bring it all together\"\n    ],\n    \"State Management: Blocs without Libraries\": [\n      \"What are blocs?\",\n      \"Calendar App introduction\",\n      \"Create bloc one\",\n      \"Create a bloc provider\",\n      \"Using StreamBuilders with blocs\",\n      \"Create bloc two: Add/Edit Tasks\",\n      \"Consume the second bloc's streams\",\n      \"Complete source code\"\n    ],\n    \"State Management: Provider\": [\n      \"What is Provider?\",\n      \"The most basic example using Provider\",\n      \"ChangeNotifierProvider\",\n      \"Rebuilding widgets with Consumer\",\n      \"Finer build control with Selector\",\n      \"Future Provider\",\n      \"MultiProvider micro lesson\",\n      \"Stream Provider\",\n      \"Using context extensions for more control\",\n      \"ProxyProvider\",\n      \"Using .value constructors\",\n      \"The final example (A shopping cart app)\",\n      \"For the curious: How is provider implemented\"\n    ],\n    \"Handling Data with Brick: Offline First with Rest\": [\n      \"About Brick and setup\",\n      \"Adding a Repository\",\n      \"Adding a Model\",\n      \"Generating Code\",\n      \"Rendering Models\",\n      \"Adding an Association\"\n    ]\n  }\n}"}},"pageContext":{"slug":"about-dart","tutorialTitle":"Getting Started with Dart","previous":null,"next":{"author":1,"content":"In order to run Dart on your machine, you'll need to install the Dart SDK.\n\n> The following instructions install Dart 2. This book will be using Dart 2; Dart 1 will not work! If you already have the Dart SDK on your machine, ensure that it's version 2.0.0 or greater.\n\nInstalling the Dart SDK is straight forward if you use the command line. To check if you have Dart installed already, use the `which dart` command (on MacOS).\n\n```shell script\n$ which dart\n\n# should print \n=> /usr/local/bin/dart\n```\n\nOtherwise, install the SDK using the instructions for your machines operating system.\n\n### Mac OS\n\nIf you're using a Mac, it's likely that you have a program called Homebrew on your computer. If not, you need to install it. Homebrew is a command-line program that lets you download and manage software packages from the terminal.\n\nWe can install it easily from the command line. First, check to see if its installed:\n\n```shell script\n$ brew -v\n```\n\nIf your terminal prints `Homebrew 1.x.x`, then you're good to go. Otherwise, you need to install Homebrew. You can find instructions for installing Homebrew via the command line at https://brew.sh.\n\nHomebrew will walk you through the steps in your terminal.\n\nSecond, install Dart SDK. Thanks to Homebrew, this is incredibly easy.\n\n```shell script\n$ brew tap dart-lang/dart\n$ brew install dart\n```\n\nNow, in your terminal, run this command to make sure everything is in its right place:\n\n```shell script\n$ dart -v\n\n=> Dart VM version: 2.x.x...\n```\n\n### Windows\n\nOn Windows, the easiest way to install Dart is via the package manager, Chocolately. With Chocolatey on your machine, you simply have to run:\n\n```shell script\nC:\\> choco install dart-sdk\n```\n\n### Linux\n\nThe easiest way to install on Ubuntu is with this series of steps. Using all these commands will ensure that Dart automatically updates whenever the newest version is released.\n\nA one-time setup step:\n```shell script\n$ sudo apt-get update\n$ sudo apt-get install apt-transport-https\n$ sudo sh -c 'curl https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -'\n$ sudo sh -c 'curl https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_stable.list > /etc/apt/sources.list.d/dart_stable.list'\n```\n\nNow, install the Dart SDK:\n```shell script\n$ sudo apt-get update\n$ sudo apt-get install dart\n","created_at":"2020-07-12T16:26:34.263Z","id":2,"slug":"install-dart-on-your-machine","title":"Install Dart on your machine","tutorial":1,"updated_at":"2020-07-25T15:18:55.405Z"}}},"staticQueryHashes":["2185715291","3564968493","63159454"]}