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
145
votes
6 answers

How do I initialize a final class property in a constructor?

In Java you are allowed to do this: class A { private final int x; public A() { x = 5; } } In Dart, I tried: class A { final int x; A() { this.x = 5; } } I get two compilation errors: The final…
Blackbam
  • 17,496
  • 26
  • 97
  • 150
144
votes
6 answers

How can I detect if my Flutter app is running in the web?

I know that I can detect the operating system with Platform.isAndroid, Platform.isIOS, etc. but there isn't something like Platform.isWeb so how can I detect this?
n1ks
  • 2,188
  • 2
  • 12
  • 12
142
votes
7 answers

How do I call a super constructor in Dart?

How do I call a super constructor in Dart? Is it possible to call named super constructors?
Eduardo Copat
  • 4,941
  • 5
  • 23
  • 40
141
votes
15 answers

How to work with progress indicator in flutter?

I'm newbie in flutter and wanted to know what is better way to add CircularProgressIndicator in my layout. For example, my login view. This view have username, password and login Button. I did want create a overlay layout (with Opacity) that, when…
Ricardo Bocchi
  • 1,551
  • 2
  • 12
  • 12
139
votes
8 answers

How to change textField underline color?

I'm new to both flutter & dart. Currently, using this in one of my personal projects. In all of my form, the underline of textField is showing in blue color. I want to change that to some other color. The piece of code which I'm using is…
Suresh
  • 5,687
  • 12
  • 51
  • 80
139
votes
8 answers

How to generate unique id in Dart

I write websocket chat. How to generate unique id for user? now i use this code: id = new DateTime.now().millisecondsSinceEpoch; is there any more neat solution?
Sergey Karasev
  • 4,513
  • 4
  • 25
  • 24
138
votes
7 answers

Add border to a Container with borderRadius in Flutter

Container( child: Text( 'This is a Container', textScaleFactor: 2, style: TextStyle(color: Colors.black), ), decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), …
Richard
  • 1,702
  • 2
  • 11
  • 17
138
votes
9 answers

Invalid Constant Value using variable as parameter

var textSize = 10.0; // or double textSize = 10.0; into Text Widget of Flutter child: const Text('Calculate Client Fees', style: TextStyle(fontSize: textSize),) Here it is giving error Invalid Constant Value Do we have to…
Gaurang Goda
  • 3,394
  • 4
  • 20
  • 29
138
votes
3 answers

What does Underscore "_" before variable name mean for Flutter

with reference to the Flutter tutorial, I encountered an underscore, _. I know that in Java, _ is used as a naming convention for a private variable. Does it also apply to Flutter? Noting that there is no public/protected in Flutter. Will the _…
lonelearner
  • 1,637
  • 4
  • 14
  • 22
138
votes
8 answers

flutter - correct way to create a box that starts at minHeight, grows to maxHeight

I have a container that I want to start off at a minimum size and grow (if its contents grow while user is adding content) to a maximum size, then stop. The correct widget for this seems to be ConstrainedBox, like so: new ConstrainedBox( …
Deborah
  • 4,316
  • 8
  • 31
  • 45
138
votes
9 answers

Dart List min/max value

How do you get the min and max values of a List in Dart. [1, 2, 3, 4, 5].min //returns 1 [1, 2, 3, 4, 5].max //returns 5 I'm sure I could a) write a short function or b) copy then sort the list and select the last value, but I'm looking to see if…
basheps
  • 10,034
  • 11
  • 36
  • 45
137
votes
18 answers

How to implement Dark mode and Light Mode in flutter?

I want to create a flutter app that has 2 light and dark mode themes that change by a switch in-app and the default theme is default android theme. I need to pass some custom color to the fellow widget and I don't want to just config material theme.…
javad bat
  • 4,236
  • 6
  • 26
  • 44
136
votes
20 answers

Flutter : Bad state: Stream has already been listened to

class MyPage extends StatelessWidget { @override Widget build(BuildContext context) { return DefaultTabController( length: 2, child: new Scaffold( appBar: TabBar( tabs: [ …
BINAY THAPA MAGAR
  • 4,017
  • 4
  • 16
  • 24
135
votes
18 answers

update dart sdk for flutter

I would like to use dart SDK >= 2.2.0 with flutter. But my current version used BY Flutter is 2.1.2 flutter --version Flutter 1.2.1 • channel stable • https://github.com/flutter/flutter.git Framework • revision 8661d8aecd (2 months ago) • 2019-02-14…
Itoun
  • 3,713
  • 5
  • 27
  • 47
135
votes
8 answers

Close modal bottom sheet programmatically in flutter

I am displaying a BottomSheet via showModalBottomSheet() and inside several widgets with a GestureDetector. I would like to see the BottomSheet closed not only by touching outside it but also after an onTap event of a GestureDetector inside.…
JonasH
  • 3,960
  • 3
  • 15
  • 17