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

Should Flutter web use Wasm instead of dart2js

I spotted several articles about Wasm being faster then JS [1, 2] I see the topic has been touched in this old (closed) issues [3, 4] and this seemingly abandoned discussion on google groups [5]; the question is: why flutter web doesn't use Wasm…
Francesco Iapicca
  • 2,618
  • 5
  • 40
  • 85
25
votes
4 answers

What's the usage of three dots (...) in dart List?

I have my code written like this but it gives an error saying: Error: A value of type 'List' can't be assigned to a variable of type 'Widget'. Column( children: [ Question( questions[_questionIndex]['questionText'], ), …
Farwa
  • 6,156
  • 8
  • 31
  • 46
25
votes
4 answers

How to sync flutter app's offline data with online database efficiently

lets say I have a todo app that stores the data in sqflite database(locally on the phone) when the app goes online I want the data to be synced with my online database say mongodb or firestore.I don't want to do complete overwrites or creating the…
Mahesh Jamdade
  • 17,235
  • 8
  • 110
  • 131
25
votes
5 answers

How to create table like ui in flutter

I am new in flutter just want to know using which widget i can create ui like given in below image. Thanks,
ketan
  • 348
  • 1
  • 4
  • 12
25
votes
2 answers

How to setState inside showModalBottomSheet

Is there any limitation in BottomSheet that we cannot update the widget states? As you can see in the example below I'm using a Switch but its display is not changing, although the value update, it's just that it doesn't get re-render again. This is…
Manvendra SK
  • 802
  • 1
  • 10
  • 20
25
votes
1 answer

Is it possible to define an abstract named constructor in Dart?

I'm trying to create an abstract class Firestorable which will ensure that subclasses override a named constructor fromMap(Map map) The code looks like this ... abstract class Firestorable { /// Concrete implementations will…
ra9r
  • 4,528
  • 4
  • 42
  • 52
25
votes
5 answers

In Dart, is it possible to pass an argument in a singleton?

class Peoples { late int id; late String name; static final Peoples _inst = Peoples._internal(); Peoples._internal(); factory Peoples() { return _inst; } } I have this singleton class. Which ensures that, only one instance of a…
drmirk
  • 403
  • 1
  • 7
  • 14
25
votes
2 answers

Dart/Flutter - "yield" inside a callback function

I need to yield a list for a function; however, I want to yield the list from within a callback function, which itself is inside the main function - this results in the yield statement not executing for the main function, but rather for the callback…
Marcus Bornman
  • 375
  • 3
  • 7
25
votes
1 answer

Convert List into json in flutter

I have a list of option when the attribute is selected of a particular option then I save attribute object at the selected position of option in the list. now I have an option list with their selected attribute object. My aim is to convert the…
Farhana Naaz Ansari
  • 7,524
  • 26
  • 65
  • 105
25
votes
3 answers

Flutter Json Encode List

How to encode list to json? This is my class for Json. class Players{ List players; Players({this.players}); factory Players.fromJson(List parsedJson){ List players = List(); players =…
willy wijaya
  • 692
  • 3
  • 8
  • 18
25
votes
1 answer

How to mimic a pressing ENTER on a TextField in Flutter Tests

Given that tester.enterText will allow me to enter the text on a TextField in a flutter test, how would I mock pressing the DONE key on the android keyboard or pressing ENTER on my keyboard inside the textfield? This would also be equivalent to…
xpeldev
  • 1,812
  • 2
  • 12
  • 23
25
votes
6 answers

How to check if Widget has mounted in flutter

So in my app, I want to make an Ajax request as soon as the widget is mounted, not in initState(). Similar to ComponentWillMount() in react
Kingsley CA
  • 10,685
  • 10
  • 26
  • 39
25
votes
2 answers

Flutter: How to avoid pushing the same route on existing route

I have view with bottom navigation bar, and when you push a navbar item, a new route is pushed into view. final navigatorKey = GlobalKey(); @override Widget build(BuildContext context) => MaterialApp( home: Scaffold( …
skjagini
  • 3,142
  • 5
  • 34
  • 63
25
votes
7 answers

How to create multiple tables in a database in sqflite?

Im building and app with flutter that uses SQLite database. I have created first table using this piece of code: void _createDb(Database db, int newVersion) async { await db.execute('''CREATE TABLE cards (id_card INTEGER PRIMARY KEY, …
filiard
  • 471
  • 2
  • 6
  • 15
25
votes
7 answers

Flutter Picking Wrong Keystore path and giving error key.jks not found

I followed all the steps on the Flutter official site and thought I'd done everything correctly but it is failing to locate the keystore file when I build it. This is the error message I get showing it taking wrong path instead of…
Gudguy
  • 923
  • 2
  • 9
  • 16