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
275
votes
14 answers

The equivalent of wrap_content and match_parent in flutter?

In Android match_parent and wrap_content are used to resize the widgets automatically relative to their parent to the content the widget contains. In Flutter it seems by default all widgets are set to wrap_content, how would I change it such that I…
Faisal Abid
  • 8,900
  • 14
  • 59
  • 91
274
votes
8 answers

Passing Data to a Stateful Widget in Flutter

I'm wondering what the recommended way of passing data to a stateful widget, while creating it, is. The two styles I've seen are: class ServerInfo extends StatefulWidget { Server _server; ServerInfo(Server server) { this._server = server; …
Mojachiee
  • 2,859
  • 4
  • 14
  • 9
269
votes
13 answers

Flutter: Unhandled Exception: ServicesBinding.defaultBinaryMessenger was accessed before the binding was initialized

Any solution to solve this problem? Stacktrace: [VERBOSE-2:ui_dart_state.cc(148)] Unhandled Exception: ServicesBinding.defaultBinaryMessenger was accessed before the binding was initialized. If you're running an application and need to access the…
Sopheadavid Sopheap
  • 2,714
  • 2
  • 9
  • 10
266
votes
14 answers

Flutter give container rounded border

I'm making a Container(), I gave it a border, but it would be nice to have rounded borders. This is what I have now: Container( width: screenWidth / 7, decoration: BoxDecoration( border: Border.all( color:…
Karel Debedts
  • 5,226
  • 9
  • 30
  • 70
264
votes
51 answers

Flutter and google_sign_in plugin: PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null)

The dialog (Google form) for the credentials is opened successfully, but after I fill my credentials I'm getting this error. I followed the instructions from here. Created a Firebase project, enabled the Google Drive API (that's what I need for now)…
263
votes
42 answers

Visual Studio Code - Target of URI doesn't exist 'package:flutter/material.dart'

I've just set up my Macbook for flutter development, So I downloaded flutter SDK, and placed it in my Documents. After, I set up my path variable to work with flutter in my command line. I execute the command flutter create todolist so I achieve a…
James
  • 3,580
  • 3
  • 25
  • 36
262
votes
16 answers

How to format DateTime in Flutter

I am trying to display the current DateTime in a Text widget after tapping on a button. The following works, but I'd like to change the format. Current approach DateTime now = DateTime.now(); currentTime = new DateTime(now.year, now.month, now.day,…
Nitneuq
  • 3,866
  • 13
  • 41
  • 64
262
votes
24 answers

Adding a splash screen to Flutter apps

How would you approach adding a splash screen to Flutter apps? It should load and display before any other content. Currently, there is a brief flash of color before the Scaffold(home:X) widget loads.
Pieter
  • 4,721
  • 6
  • 19
  • 18
261
votes
27 answers

Space between Column's children in Flutter

I have a Column widget with two TextField widgets as children and I want to have some space between both of them. I already tried mainAxisAlignment: MainAxisAlignment.spaceAround, but the result was not what I wanted.
Sachin Soma
  • 3,432
  • 2
  • 10
  • 18
247
votes
17 answers

Flutter: RenderBox was not laid out

I'm trying to create a ListView but when I import the list_form.dart class i get this error. Maybe I made some mistakes with the layout because if I try to run it inside the main file I don't get this error. This is the error: I/flutter (12956):…
Alessandro Bertozzi
  • 2,521
  • 2
  • 9
  • 9
244
votes
10 answers

Flutter: Expanded vs Flexible

I've used both Expanded and Flexible widgets and they both seem to work the same. What is the difference between Expanded and Flexible?
user6274128
243
votes
28 answers

Check whether there is an Internet connection available on Flutter app

I have a network call to be executed. But before doing that I need to check whether the device have internet connectivity. This is what i have done so far: var connectivityResult = new Connectivity().checkConnectivity();// User defined class …
Rissmon Suresh
  • 13,173
  • 5
  • 29
  • 38
242
votes
14 answers

Incorrect use of parent data widget. expanded widgets must be placed inside flex widgets

I am getting the following error: i.e.., Another exception was thrown: Incorrect use of ParentDataWidget. showing error on the mobile screen. @override Widget build(BuildContext context) { return MaterialApp( title: widget.title, …
Mounika
  • 3,348
  • 5
  • 16
  • 25
241
votes
11 answers

How can I "sleep" a Dart program

I like to simulate an asynchronous web service call in my Dart application for testing. To simulate the randomness of these mock calls responding (possibly out of order) I'd like to program my mocks to wait (sleep) for a certain period of time…
Vinnie
  • 12,400
  • 15
  • 59
  • 80
236
votes
45 answers

How to capitalize the first letter of a string in dart?

How do I capitalize the first character of a string, while not changing the case of any of the other letters? For example, "this is a string" should give "This is a string".
Kasper
  • 12,594
  • 12
  • 41
  • 63