Forum Replies Created

Viewing 1 post (of 1 total)
  • Author
    Posts
  • in reply to: Null Safety Switch Dartpad #48436
    Sicario
    Participant

      Coach, pakai https://dartpad.dev/?null_safety=false masih belum berhasil.

      Syntax:
      class Manusia{
      String nama;
      int umur;
      Manusia({this.nama, this.umur});
      }

      void main(){
      var m1 = Manusia(nama: ‘Andi’,umur: 17);
      print(m1.nama);
      print(m1.umur);
      }

      Pesan Error:
      Error compiling to JavaScript:
      Info: Compiling with sound null safety
      Warning: Interpreting this as package URI, ‘package:dartpad_sample/main.dart’.
      lib/main.dart:4:17:
      Error: The parameter ‘nama’ can’t have a value of ‘null’ because of its type ‘String’, but the implicit default value is ‘null’.
      Manusia({this.nama, this.umur});
      ^^^^
      lib/main.dart:4:28:
      Error: The parameter ‘umur’ can’t have a value of ‘null’ because of its type ‘int’, but the implicit default value is ‘null’.
      Manusia({this.nama, this.umur});
      ^^^^
      Error: Compilation failed.

    Viewing 1 post (of 1 total)
    Shopping cart0
    There are no products in the cart!
    Continue shopping