Named Constructor In Dart - Learn Dart Programming

แชร์
ฝัง
  • เผยแพร่เมื่อ 15 ต.ค. 2024

ความคิดเห็น • 10

  • @michalsaky
    @michalsaky ปีที่แล้ว

    in constructor you have map and then json, what it means and why itis there?
    Thank you.

  • @khubaibirfan9215
    @khubaibirfan9215 2 ปีที่แล้ว +1

    Sir pls make videos on single ton

  • @jio-4568
    @jio-4568 ปีที่แล้ว

    It was so useful. Thank you))

  • @telugutechtutssudheer6212
    @telugutechtutssudheer6212 5 หลายเดือนก่อน

    bro can you upload json video

  • @abdurrehmanch27
    @abdurrehmanch27 ปีที่แล้ว

    Level sir ji

  • @foxe2206
    @foxe2206 ปีที่แล้ว

    ty

  • @welshmanmakwara9798
    @welshmanmakwara9798 6 หลายเดือนก่อน

    Did the challenge
    class Car {
    //properties
    String? name;
    String? color;
    String? price;
    //Constructor 1
    Car({required this.name, required this.color, this.price});
    // Constructor 2
    Car.other(this.name, this.color);
    //Methods
    display() {
    if (price == null) {
    price = "not stated";
    }
    print("This car is a $name");
    print("its color is $color");
    print("the price is $price");
    print("-----------------------------");
    }
    }
    void main(List args) {
    Car car1 = Car(name: "Benz", color: "white", price: "5000");
    car1.display();
    Car car2 = Car.other("BMW", "BLUE");
    car2.display();
    }

  • @BankITOfficer
    @BankITOfficer ปีที่แล้ว +1

    class Car {
    String? name;
    String? color;
    var price;
    //parameterized constructor
    Car(this.name, this.color, this.price);
    void dispaly() {
    print("car name: $name");
    print("car color: $color");
    print("car price: $price");
    }
    //named constructor
    Car.newcar(this.name, this.color, [this.price = "N/A"]);
    }
    void main(List args) {
    Car c = Car("BMW", "BLACK", 100000);
    c.dispaly();
    Car car = Car.newcar("AUDI", "RED");
    car.dispaly();
    }

  • @Lui_Catarino
    @Lui_Catarino 5 หลายเดือนก่อน +1

    class Car {
    String? name;
    String? color;
    double? prize;
    Car({this.name, this.prize, this.color});
    Car.second({this.name, this.color});
    void display() {
    print('Name: $name');
    print('Color: $color');
    print('Prize: $prize');
    print('-----------------');
    if (prize == null) {
    prize = 0;
    }
    }
    }
    void main(){
    Car honda= Car(name:'honda', color: 'black', prize: 500000);
    honda.display();
    Car bmw= Car(name: 'M4', color: 'Blue', prize: 400000);
    bmw.display();
    }

  • @yusufvinfotech3582
    @yusufvinfotech3582 ปีที่แล้ว

    class Car{

    // properties

    String? name;
    String? color;
    int? prize;

    //Constructor
    Car(this.name,this.color,this.prize);

    //Name Constructor
    Car.name(this.name,this.color);


    // Methods & Function
    void display(){

    if(prize==null){

    print('The car prize is $prize');
    }

    print('The car name is $name');
    print('The car color is $color');


    }

    }
    void main(){

    // 1st object 3paremeter given

    Car car=Car('Mercedes','White',5000000);
    car.display();



    // 2nd object 2paremeter given
    Car car2=Car.name('Porsche', 'Red');
    car2.display();
    }
    Is the right???