Questions tagged [dart]

Dart is a class-based, statically(& strongly)-typed programming language for building web and mobile applications. Dart compiles to modern JavaScript to run in the browser and compiles to native code to run on mobile platforms like Android and iOS. Dart also runs on the command-line for scripting and server-side apps.

Dart is an open-source, class-based, statically(& strongly)-typed (with inference) programming language for building web and mobile applications created by Google. Although Dart is statically-typed it supports dynamic-typing through the 'dynamic' type.

Dart’s design goals are:

  • Create a structured yet flexible language.
  • Make Dart feel familiar and natural to programmers and thus easy to learn.
  • Ensure that Dart delivers high performance on modern web browsers, mobile, and environments ranging from small handheld devices to server-side execution.

Dart targets a wide range of development scenarios, from a one-person project without much structure to a large-scale project needing formal types in the code to state programmer intent.

To support this wide range of projects, Dart provides the following features and tools:

  • Sound type system: A type system which feels lightweight thanks to inference and gives good safety
  • Mobile and Web frameworks: Dart developers can use Flutter on mobile and AngularDart on the web
  • IDE Integration: official plugins for Jetbrains' IDEs (IntelliJ IDEA / WebStorm etc) and Visual Studio Code. Community plugins also exist for many other editors backed by the Dart Analysis Server

Links

Documentation

FAQ

Chat Room

90488 questions
25
votes
3 answers

TDD in Flutter/Dart. How to reduce start up time

I try to do Test-Driven Development (TDD) in Dart for the business logic of apps with Flutter. The startup time for running the test feels a little bit slow for fast TDD cycles. It is around 4-5 seconds on my machine. I am using the…
Minsky
  • 2,106
  • 28
  • 31
25
votes
2 answers

How to display more than 3 items in a BottomNavigationBar while coding in flutter

I tried adding 5 BottomNavigationBarItem but, the compiler throws an error if I try to add more than 3 items. It looks something like this: The following RangeError was thrown building BottomNavigationBar(dirty,…
Naveen
  • 1,363
  • 7
  • 17
  • 28
25
votes
3 answers

Constructors in dart

I have this constructor in my class. Now when it's like this, I get The type parameter icon is annotated with @required but only named parameters without default value can be annotated with it. - const Category( @required this.name, …
MAA
  • 1,294
  • 3
  • 18
  • 34
25
votes
3 answers

Parsing JSON that has a nested array of objects in Dart?

I am making a Flutter app and I am using The MovieDB api to get data. When I call the api and ask for a specific movie, this is the general format that I get back: { "adult": false, "backdrop_path": "/wrqUiMXttHE4UBFMhLHlN601MZh.jpg", …
rakeshdas
  • 2,363
  • 5
  • 20
  • 28
25
votes
10 answers

How to save an image to the photo gallery using Flutter?

My flutter app uses the camera package to take a photo, which I save to the application's data directory (obtained from path_provider and the getApplicationDocumentsDirectory() function). How can I save this image file into the phone photo gallery?…
Duncan Jones
  • 67,400
  • 29
  • 193
  • 254
25
votes
5 answers

Flutter Widget Tests with NetworkImage

I have a Widget with NetworkImage (so far with hard-coded url). I would like to widget test this Widget, but I got 404 when I run widget test (url is 100% valid). How can I make NetworkImages load themselves or (which would be better) ignore them so…
Marcin Szałek
  • 4,609
  • 5
  • 30
  • 43
25
votes
3 answers

Insert comments after closing bracket using Android Studio automatically

Is it possible to get comments to be placed automatically at the end of a method with Android Studio? return new MaterialApp( ); // MaterialApp
Ricardo Rocha
  • 251
  • 4
  • 6
25
votes
5 answers

How to read bytes of a local image file in Dart/Flutter?

I would like to use a placeholder image file that I've added to my code as "assets/placeholder.png", but I'm getting a File not found error. This is how I'm doing it from the dartlang documentation... var bytes = await new…
Charles Jr
  • 8,333
  • 15
  • 53
  • 74
25
votes
2 answers

How to create a generic method in Dart?

I'm trying to use generic methods in Dart (1.22.0-dev.10.3). Here is a simple example: abstract class VR { VR(); bool foo(T value); } class VRInt extends VR { VRInt(); bool foo(int n) => n > 0; // Thinks n is…
jfp
  • 381
  • 1
  • 3
  • 8
25
votes
1 answer

HTML import: CustomTag not registered

I'm trying to create a custom element from polymer-element, but I cannot make the @CustomTag work. My dart file (my_element.dart) looks like this: @HtmlImport('my_element.html') library projects.projectFolder.layout; import…
tomasyany
  • 1,132
  • 3
  • 15
  • 32
25
votes
5 answers

How to create a StreamTransformer in Dart?

Trying to build a custom StreamTransformer class, however a lot of the examples out there seem to be out of date, and the one found in the documentation isn't (what some typed languages might consider anyway) as a class (found here:…
Will Squire
  • 6,127
  • 7
  • 45
  • 57
25
votes
3 answers

Default stringify for objects, equivalent to Java's toString?

I have just take a look at the 3º tutorial from dart, creating the rating component. I was wondering if there is same method which is called when stringifying an object, something similar to Java's toString. For example: MyClass myObject = new…
Javier Mr
  • 2,130
  • 4
  • 31
  • 39
25
votes
3 answers

Sort a list of maps in Dart - Second Level Sort in Dart

I have a list of maps like this: var associations = [{'name': 'EG', 'description': 'Evil Genius'}, {'name': 'NaVi', 'description': 'Natus Vincere'}]; var members = [ {'associationName': 'EG', 'firstName': 'Bob', 'lastName':…
user3379856
  • 251
  • 1
  • 3
  • 3
25
votes
2 answers

How to work with char types in Dart? (Print alphabet)

I am trying to learn the Dart language, by transposing the exercices given by my school for C programming. The very first exercice in our C pool is to write a function print_alphabet() that prints the alphabet in lowercase; it is forbidden to print…
Diti
  • 1,454
  • 3
  • 23
  • 38
25
votes
2 answers

Extending the Exception class in Dart

I keep getting an error when I try to extend the Exception class and can't figure out why. Here is the code for my custom exception: class MyException extends Exception { String msg; MyException(this.msg); String toString() => 'FooException:…
user1869518