
Explore tens of thousands of sets crafted by our community.
Dart Language Features
36
Flashcards
0/36




Dart Null Safety




Null safety in Dart means that variables can't hold null values by default, preventing null reference exceptions.




Generics




Dart supports generics, allowing you to write code that can work with any type in a type-safe way.




Strongly Typed Language




Dart is a strongly typed language, meaning that the type of variable is known at compile time. This helps catch errors early in the development process.




Extension Methods




Dart allows you to add new functionality to existing classes via extension methods without modifying the original class.




Asynchronous programming with Futures and Streams




Dart handles asynchronous operations with Futures and Streams, allowing you to write code that can execute in the background.




First-Class Functions




Functions in Dart are first-class citizens, meaning they can be passed as arguments to other functions, assigned to variables, and returned from functions.




Named Constructors




Dart classes can have multiple constructors with different names, allowing you to initialize your objects in various ways.




Mixin-based Inheritance




Dart supports mixin-based inheritance, allowing you to create a class body that can be reused in multiple class hierarchies.




Isolates for Concurrency




Dart uses isolates as a way to handle concurrency, with each isolate having its own memory and running in its own thread.




Metadata Annotations




Dart provides metadata annotations, which can be used to provide additional information about the code to tools, compilers, or for reflection at runtime.




String Interpolation




Dart allows inserting values directly into strings without concatenation, through string interpolation, by using the '\\




Enums




Dart supports enumerations (enums), which are a set of named constant values. Enums are useful for defining a common set of related values.




Sound Type System




The Dart type system is sound, which means that if a variable is of a certain type, the compiler guarantees that it will always be of that type.




Cascades Notation (..)




Cascades (..) allow you to make a sequence of operations on the same object. This results in more fluent code and avoids the need to save the instance in a temporary variable.




Typedefs




A typedef in Dart is used to create a user-defined name for a function type that can be used when declaring variables and return types.




Collection if and spread




The collection if and spread operators provide a concise way to conditionally insert items or merge multiple collections within lists or maps.




Control Flow Collections




Dart offers syntax to include if statements and for loops inside collections, which help in creating dynamic collections.




Operator Overloading




Dart allows you to provide custom implementation for existing operators for your class using the operator keyword.




Library and Visibility




Dart uses libraries to organize and share code. A library can restrict the visibility of its content to other files with '_underscore' prefixes.




Assertions




An assertion is a runtime check that a boolean condition is true, used during debugging to ensure that an unexpected situation does not occur.




Named Parameters




Dart functions can have named parameters, which allow you to specify arguments by their name for better readability and to make arguments order-independent.




Static Members




Dart supports static methods and properties, which belong to the class itself rather than instances of the class.




Getters and Setters




Dart allows you to define getters and setters for your classes to control and validate changes to an object's properties, similar to other object-oriented languages.




Late Variables




The 'late' keyword is used to delay initialization of a variable until it is actually used, which can help avoid null errors and potentially improve startup time.




Exception Handling




Dart provides exception handling with try-catch blocks. You can catch specific exceptions or use a final block to execute code after an exception has been handled.




The 'required' keyword




The 'required' keyword is used to specify that a named parameter in a function or constructor must be provided; it prevents the omission of parameters that are essential for a function's execution.




Cascade Operator (..)




The cascade operator (..) allows you to perform a sequence of operations on the same object.




Factory Constructors




Factory constructors enable a class to have multiple constructors that can return objects of various types, including subtypes or pre-existing instances.




Conditional Import




Dart supports conditional imports which make it possible to have different implementations of a library for different platforms.




Type Promotion




Dart's control flow analysis promotes types within if-statements, which simplifies the handling of nullable types.




Interoperability with JavaScript




Dart can interoperate with JavaScript, allowing you to use JavaScript libraries in your Dart applications with the help of the js package.




Iterable spreads




In Dart, you can use the spread operator (...) to insert all elements of an iterable (like a list, set) into a collection.




Lambdas




Dart supports lambda expressions — anonymous functions that are concise and can be passed around as arguments.




Collection Literals




Dart provides collection literals for easily creating lists, sets, or maps.




Multi-Threaded Programming with Isolates




Dart uses isolates to achieve concurrency, isolates are separate workers that don't share memory but can pass messages between each other.




Records (proposed feature)




Dart is considering adding records as a language feature to provide a simple way to represent data structures with value-based equality.
© Hypatia.Tech. 2024 All rights reserved.