learnxinyminutes-docs icon indicating copy to clipboard operation
learnxinyminutes-docs copied to clipboard

[dart/en] Learn Dart broken

Open HeyItsJono opened this issue 3 years ago • 7 comments

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)

HeyItsJono avatar Jul 21 '22 17:07 HeyItsJono

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

mribeirodantas avatar Jul 21 '22 18:07 mribeirodantas

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 :()

gochev avatar May 22 '23 13:05 gochev

That's unfortunate. Would you be willing to improve the article, @gochev?

mribeirodantas avatar May 22 '23 15:05 mribeirodantas

@mribeirodantas I will rewrite it and fix all in the upcoming days

gochev avatar May 23 '23 16:05 gochev

Amazing, thanks so much for taking the time to fix this up!

HeyItsJono avatar May 24 '23 05:05 HeyItsJono

I fixed compilation errors in https://github.com/adambard/learnxinyminutes-docs/pull/4673

HOWEVER I believe we should:

  1. format the code since it is super badly formatted.
  2. 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.

gochev avatar May 24 '23 08:05 gochev

@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.

gochev avatar May 24 '23 09:05 gochev