[dart/en] Learn Dart broken
Hi there, thanks for this awesome resource.
Attempting to run the current Learn Dart page in the latest version of dart throws several errors:
: Warning: Operand of null-aware operation '??' has type 'bool' which excludes null.
var hasString = isBool ?? "default String";
^
: Error: Variables must be declared using the keywords 'const', 'final', 'var' or a type name.
Try adding the name of the type of the variable or the keyword 'var'.
CONSTANT_VALUE = "DID I?"; //Error
^^^^^^^^^^^^^^
: Error: 'CONSTANT_VALUE' is already declared in this scope.
CONSTANT_VALUE = "DID I?"; //Error
^^^^^^^^^^^^^^
: Context: Previous declaration of 'CONSTANT_VALUE'.
const CONSTANT_VALUE = "I CANNOT CHANGE";
^^^^^^^^^^^^^^
: Error: Variables must be declared using the keywords 'const', 'final', 'var' or a type name.
Try adding the name of the type of the variable or the keyword 'var'.
finalValue = "Seems not"; //Error
^^^^^^^^^^
: Error: 'finalValue' is already declared in this scope.
finalValue = "Seems not"; //Error
^^^^^^^^^^
: Context: Previous declaration of 'finalValue'.
final finalValue = "value cannot be change once instantiated";
^^^^^^^^^^
: Error: Variables must be declared using the keywords 'const', 'final', 'var' or a type name.
Try adding the name of the type of the variable or the keyword 'var'.
mutableValue = "this is valid";
^^^^^^^^^^^^
: Error: 'mutableValue' is already declared in this scope.
mutableValue = "this is valid";
^^^^^^^^^^^^
: Context: Previous declaration of 'mutableValue'.
var mutableValue = "Variable string";
^^^^^^^^^^^^
: Error: Variables must be declared using the keywords 'const', 'final', 'var' or a type name.
Try adding the name of the type of the variable or the keyword 'var'.
mutableValue = false; // Error.
^^^^^^^^^^^^
Exited (254)
Thanks for reporting this, @HeyItsJono!
I will mention the contributors of the Dart documentation file. Maybe someone among them will be willing to fix this.
@jpedrosa @mxschumacher @divayprakash @Hiyorimi @vinceramcesoliveros @sridhareaswaran @prertik @sophiabrandt @samcv @okry1123 @ghalley @AntonTrekov @stranger26 @smith558
there are a lot of issues in the dart version.
/// The Class constructor method uses the same name of the class and
/// takes the form of SomeClass() : super() {}, where the ": super()"
/// part is optional and it's used to delegate constant parameters to the
/// super-parent's constructor.
class Example24A {
var _value;
Example24A({value: "someValue"}) {
_value = value;
}
get value => _value;
}
it uses : instead of = so many many mistakes :()
That's unfortunate. Would you be willing to improve the article, @gochev?
@mribeirodantas I will rewrite it and fix all in the upcoming days
Amazing, thanks so much for taking the time to fix this up!
I fixed compilation errors in https://github.com/adambard/learnxinyminutes-docs/pull/4673
HOWEVER I believe we should:
- format the code since it is super badly formatted.
- improve this with examples from dart 2 and dart 3. Basically nullable values are not explained properly and all dart 3 features are missing. Overall everything was stuck with very old versions of dart and many examples are no longer relevant or written the best way.
I can work on this 2 if you tell me to in the next week or so. I believe this can be much better then it is.
@HeyItsJono some of the initial examples are made to fail by design. However I agree it is not the best we can improve it for the next commits.