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
195
votes
9 answers

How do I open a web browser (URL) from my Flutter code?

I am building a Flutter app, and I'd like to open a URL into a web browser or browser window (in response to a button tap). How can I do this?
Seth Ladd
  • 112,095
  • 66
  • 196
  • 279
193
votes
5 answers

What are the ?? double question marks in Dart?

The following line of code has two question marks: final myStringList = prefs.getStringList('my_string_list_key') ?? []; What is the meaning?
Suragch
  • 484,302
  • 314
  • 1,365
  • 1,393
192
votes
12 answers

Flutter : Vertically center column

How to vertically center a column in Flutter? I have used widget "new Center". I have used widget "new Center", but it does not vertically center my column ? Any ideas would be helpful.... @override Widget build(BuildContext context) { return…
Zeusox
  • 7,708
  • 10
  • 31
  • 60
188
votes
26 answers

Flutter command not found

Apparently, none of the Flutter commands are working in the terminal of Android Studio which I believe I am trying to run it at the root of my project. Output: bash: flutter: command not found
heyr
  • 5,514
  • 11
  • 34
  • 55
187
votes
17 answers

How to make an AlertDialog in Flutter?

I am learning to build apps in Flutter. Now I have come to alert dialogs. I have done them before in Android and iOS, but how do I make an alert in Flutter? Here are some related SO questions: How to style AlertDialog Actions in Flutter adding…
Suragch
  • 484,302
  • 314
  • 1,365
  • 1,393
187
votes
10 answers

Set the space between Elements in Row Flutter

Code: new Container( alignment: FractionalOffset.center, child: new Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ new FlatButton( child: new…
marcelo.wdrb
  • 2,041
  • 2
  • 10
  • 16
187
votes
17 answers

Is there a way to load async data on InitState method?

I'm a looking for a way to load async data on InitState method, I need some data before build method runs. I'm using a GoogleAuth code, and I need to execute build method 'till a Stream runs. My initState method is: @override void initState () { …
Joseph Arriaza
  • 12,014
  • 21
  • 44
  • 63
187
votes
7 answers

How to log data to the Flutter console?

I am a beginner and using IntelliJ IDEA, and I wanted to log data to the console? I tried print() and printDebug(), but none of my data were showing in the Flutter console.
185
votes
13 answers

Null check operator used on a null value

I am new to Flutter I got this error when I run my simple flutter APP. I could not figure out why this error occurred. Error Null check operator used on a null value My code in main.dart import 'package:flutter/material.dart'; import…
Sivaram Rasathurai
  • 5,533
  • 3
  • 22
  • 45
185
votes
4 answers

Flutter: filter list as per some condition

I'm having a list of movies. That contains all animated and non-animated movies. To identify whether it's Animated or not there is one flag called isAnimated. I want to show only Animated movies. How can I do that?
Tushar Pol
  • 7,119
  • 14
  • 29
  • 36
184
votes
15 answers

How to add image in Flutter

I am developing Flutter app for the first time. I have an issue adding an image. I have a following questions: Where to create an images folder? Where to add assets tag in pubspec.ymal? Is there any assets folder needed for this? What I tried: …
Annie
  • 2,397
  • 3
  • 18
  • 26
181
votes
20 answers

Flutter: Scrolling to a widget in ListView

How can I scroll to a special widget in a ListView? For instance I want to scroll automatically to some Container in the ListView if I press a specific button. ListView(children: [ Container(...), Container(...), #scroll for example to…
GreenTigerEye
  • 5,917
  • 9
  • 22
  • 33
181
votes
7 answers

How to get a timestamp in Dart?

I've been learning Dart, but I don't know how to generate a timestamp. I have tried this: void main() { print((new Date()).millisecondsSinceEpoch); } Thanks to the IDE I was able to get this far, but I'm getting a confusing error: Exception: No…
user1781056
179
votes
12 answers

Do not use BuildContexts across async gaps

I have noticed a new lint issue in my project. Long story short: I need to use BuildContext in my custom classes flutter lint tool is not happy when this being used with aysnc method. Example: MyCustomClass{ final buildContext context; …
178
votes
4 answers

Flutter: How to correctly use an Inherited Widget?

What is the correct way to use an InheritedWidget? So far I understood that it gives you the chance to propagate data down the Widget tree. In extreme if you put is as RootWidget it will be accessible from all Widgets in the tree on all Routes,…
Thomas
  • 8,397
  • 7
  • 29
  • 39