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
178
votes
15 answers

How can I compare Lists for equality in Dart?

I'm comparing two lists in Dart like this: main() { if ([1,2,3] == [1,2,3]) { print("Equal"); } else { print("Not equal"); } } But they are never equal. There doesn't seem to be an equal() method in the Dart API to…
Mark B
  • 2,870
  • 3
  • 20
  • 18
177
votes
22 answers

How can I hide letter counter from bottom of TextField in Flutter

I'm facing a small problem. As you can see, i have set maxLength 1 of TextField in Flutter, But i'm unable to hide bottom label of text counter.
Sunil
  • 3,211
  • 3
  • 21
  • 21
176
votes
47 answers

CocoaPods not installed or not in valid state

Launching lib/main.dart on iPhone 11 Pro Max in debug mode... Warning: CocoaPods is installed but broken. Skipping pod install. You appear to have CocoaPods installed but it is not working. This can happen if the version of Ruby that CocoaPods…
rahul rawat
  • 1,878
  • 2
  • 7
  • 6
176
votes
24 answers

How to make flutter app responsive according to different screen size?

I am facing difficulties to make it responsive according to various screen sizes. How to make it responsive? @override Widget build(BuildContext context) { return new Container( decoration: new BoxDecoration(color:…
praveen Dp
  • 2,766
  • 4
  • 22
  • 26
176
votes
23 answers

How can I delete duplicates in a Dart List? list.distinct()?

How do I delete duplicates from a list without fooling around with a set? Is there something like list.distinct()? or list.unique()? void main() { print("Hello, World!"); List list = ['abc',"abc",'def']; list.forEach((f) =>…
Gero
  • 12,993
  • 25
  • 65
  • 106
175
votes
15 answers

How do I set the background color of my main screen in Flutter?

I'm learning Flutter, and I'm starting from the very basics. I'm not using MaterialApp. What's a good way to set the background color of the whole screen? Here's what I have so far: import 'package:flutter/material.dart'; void main() { runApp(new…
Seth Ladd
  • 112,095
  • 66
  • 196
  • 279
173
votes
11 answers

How to refresh an AlertDialog in Flutter?

Currently, I have an AlertDialog with an IconButton. The user can click on the IconButton, I have two colors for each click. The problem is that I need to close the AlertDialog and reopen to see the state change of the color icon. I want to change…
Nitneuq
  • 3,866
  • 13
  • 41
  • 64
173
votes
22 answers

Converting timestamp

I couldn't find a solution to this, I'm grabbing data from firebase and one of the fields is a timestamp which looks like this -> 1522129071. How to convert it to a date? Swift example (works) : func readTimestamp(timestamp: Int) { let now =…
Mohamed Mohamed
  • 3,965
  • 3
  • 23
  • 40
172
votes
33 answers

Generate SHA-1 for Flutter/React-Native/Android-Native app

I'm trying to generate a SHA-1 for a Flutter app, for Android studio to support Google Sign in, but I don't know how to do that, I saw some posts that indicate to run a command, but there I need a jks file I guess, and flutter doesn't create…
Joseph Arriaza
  • 12,014
  • 21
  • 44
  • 63
172
votes
11 answers

How should I check if the input is an email address in Flutter?

According to RegExp documentation, we must use JavaScript (Perl 5) regular expressions : ECMA Specification. What method should I use in Dart to check if the input is an email?
Eric Lavoie
  • 5,121
  • 3
  • 32
  • 49
169
votes
3 answers

"extends" versus "implements" versus "with"

I want to understand the difference between extends, implements and with. When do I use each keyword?
Keerti Purswani
  • 4,878
  • 3
  • 16
  • 29
169
votes
4 answers

how to use local flutter package in another flutter application?

How to use local flutter package in another flutter application? I created a package using following command: flutter create --template=package my_new_package and then in my application source code => main.dart import…
behzad besharati
  • 5,873
  • 3
  • 18
  • 22
168
votes
4 answers

How do I do the "frosted glass" effect in Flutter?

I'm writing a Flutter app, and I'd like to use/implement the "frosted glass" effect that's common on iOS. How do I do this?
Seth Ladd
  • 112,095
  • 66
  • 196
  • 279
167
votes
20 answers

The argument type 'Function' can't be assigned to the parameter type 'void Function()?' after null safety

I want to achieve to make a drawer with different items on it, so I am creating a separate file for the DrawerItems and the with the constructor, pass the data to the main file. But I get the following error on the onPressed function: "The argument…
dosytres
  • 2,096
  • 3
  • 10
  • 21
167
votes
7 answers

Flutter get context in initState method

I'm not sure if the initState is the right function for this. What I'm trying to achieve is to check when the page is rendered to perform some checks and based on them opening a AlertDialog to make some settings if needed. I've got a Page which has…
wawa
  • 4,816
  • 3
  • 29
  • 52