Dart 2 is changing the Dart language in many ways, some of which are not backward-compatible.
Questions tagged [dart-2]
60 questions
5
votes
1 answer
Only static members can be accessed in initializer. Dart2.0
I am using banklist in stateful widget. passing list to pageState using List bankLists = this.widget.bankLists;
Que 1. Why I am getting error at gradientcolor: gradientBankCard("FFB74093","FFB74093")) that only static members can be…

Harsh Bhavsar
- 1,561
- 4
- 21
- 39
5
votes
3 answers
How to add a name to a chart on flutter, x- and y-axis?
I have been working with the online gallery of Flutter charts (https://google.github.io/charts/flutter/gallery.html) but I'm struggling to add a title for x & y axis values.
Can somebody help me or tell me how to add the labels to the graph?

Eti
- 93
- 1
- 2
- 8
4
votes
3 answers
is it possible to lazily use JS libs with Dart?
I am using chartjs (with the dart interface https://pub.dartlang.org/packages/chartjs) and trying to make it deferred by injecting a into the head section and awaiting it's load event to then use the lib.
I am…

Jonathan
- 4,724
- 7
- 45
- 65
4
votes
2 answers
Flutter (Dart 2) accessing twitter GET api
I am having trouble calling on the Twitter api in my Flutter app. I have used the twitter sign in library to get my token and secret token, and I have my consumer and consumer secret. But I am unable to form an https request correctly. I have tried…

Nick Mowen
- 2,572
- 2
- 22
- 38
3
votes
2 answers
Flutter, how to reduce repeated widget
Thank you for aiding me.
What I'm trying to do is cut down on repeat of the code below;
class PeddingRadius extends StatelessWidget {
PeddingRadius(final column);
@override
Widget build(BuildContext context) {
Container(
padding:…

Fool Baby
- 178
- 2
- 10
3
votes
1 answer
Are Dart 1 books still relevant for learning Dart 2
I read on many places that Dart 2 is not completely backward compatible with Dart. I found a list of books that are for Dart 1.x
https://dart.dev/resources/books
Can someone with Dart 1 and Dart 2 experience tell me if this books are relevant for…

onetwo12
- 2,359
- 5
- 23
- 34
3
votes
2 answers
how does WebSocketChannel warns that it disconnected?
I am using WebSocketChannel as a socket server:
var handler = webSocketHandler((WebSocketChannel webSocket) async {
}
How can I know when the webSocket above gets disconnected?

Jonathan
- 4,724
- 7
- 45
- 65
3
votes
1 answer
How to throttle TextEditingController listener events in Dart 2 - Flutter
I am wondering if there's some built in function that I might have missed. I tried to find something similar, but the only package I found (throttle) is not supported for Dart 2 anymore
Here's the part of the code I wanted to throttle
final…

Victor Hugo Montes
- 1,270
- 1
- 17
- 28
3
votes
2 answers
Remove Index wise CustomWidget from List in Flutter
I have initially empty list of Widget in Column. Now on Other widget click I am adding new Custom Widget in _contactItems
Column(
children: _contactItems,
)
List _contactItems = new List();
…

Harsh Bhavsar
- 1,561
- 4
- 21
- 39
3
votes
2 answers
How I can show back button when device is iPhone
I am developing an app using flutter. But I am stuck on a situation that Android device has its default back button but iPhone don't. So I need to show back button when I open app in iOS device.
Also if there is any other built in functionality…

Code Hunter
- 10,075
- 23
- 72
- 102
3
votes
2 answers
NoSuchMethodError: The method 'ancestorStateOfType' was called on null
i am doing screen change like this iam listing for stream and when it emit i change the screen
@override
void initState() {
super.initState();
appBloc.error.listen((data) {
_scaffoldKey.currentState.showSnackBar(new…

shakil.k
- 1,623
- 5
- 17
- 27
3
votes
1 answer
Dart version 2.0.0-dev.64.1 incompatible snapshot
I just installed Dart version 2.0.0-dev.64.1 and when running tests in WebStorm using the Dart VM I get the error:
Snapshot not compatible with the current VM configuration: the snapshot requires 'release no-strong no-type_checks no-asserts…

jfp
- 381
- 1
- 3
- 8
2
votes
1 answer
How to add Border around an oval image? Flutter
I want to add a border color around an oval shaped image that doesn't have a constant height value.
My code example:
Align(
child: ConstrainedBox(
constraints: const…

Texv
- 1,225
- 10
- 14
2
votes
1 answer
The argument type 'Function' can't be assigned to the parameter type 'String? Function(String?)? after dart2
I am getting error
The argument type 'Function' can't be assigned to the parameter type 'String? Function(String?)?
after dart 2 for a form field widget.
full code:
class MyFormField extends StatelessWidget {
Function onTextChanged;
Function…

Sulfy
- 239
- 4
- 17
2
votes
0 answers
How to import generated source in dart2 using build_runner?
I want to create a Builder that would create Env class on the fly. That class should be available for import anywhere in my project. It is as container for environment constants defined in build.yml
Builder itself works fine, it generates desired…

Antoniossss
- 31,590
- 6
- 57
- 99