Skip to content
This repository has been archived by the owner on Feb 8, 2022. It is now read-only.
/ Missing_Kotlin Public archive

"Flutter is **** because it does not use Kotlin" Already heard it ? Prove them you can do the same thing as Kotlin using Flutter/Dart !

License

Notifications You must be signed in to change notification settings

florent37/Missing_Kotlin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

missing_kotlin

"Flutter is **** because it does not use Kotlin" Already heard it ? Prove them you can do the same thing as Kotlin using Flutter/Dart !

.let

Work like .let in kotlin

final calculated = myMethod()?.let((v){
  return v*2;
}) ?? 0;

Will also break th chain if th expression is null

String variable; //null
final calculated = variable?.let((v) => v.length());

//here the expression is null, it will not execute the lambda
expect(calculated, null);

.also

Work like .also in kotlin

final result = myMethod()?.also((v){
  print(v);
});

result here is the return value of myMethod()

.run

Work like .run in kotlin

final calculated = myMethod()?.let((v){
  return v*2;
}) ?? run(() => 3);

.takeIf

Work like .takeIf in kotlin

final calculated = myMethod()?.takeIf((v) => v == 3)?.let((v){
  return v*2;
}) ?? 0;

When

final variable = 3;
final result = when(variable, [
    Case(2, () => "A"),
    Case(3, () => "B"),
    Default(() => "C"),
]);

//here the result is "B"
expect(calculated, null);

If

Like a Kotlin if, returning a value, but with an Uppercase (because if is a reserved word)

final result = If(1 == 2, 
  () => "A", 
  Else: () => "B"
);

//here the result is "B"
expect(result, "1");

You can also chain statements

final variable2 = 1;
final result = If(variable2 == 2,
    () => "A",
  Else: () => 
    If(variable2 == 3,
        () => "B",
    Else: 
        () => "C"
  ),
);

//here the result is "C"
expect(result, "C");

About

"Flutter is **** because it does not use Kotlin" Already heard it ? Prove them you can do the same thing as Kotlin using Flutter/Dart !

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published