Dart INTERFACE ( implements keyword ) Example. Dart Programming for Flutter #9.7

แชร์
ฝัง
  • เผยแพร่เมื่อ 15 ต.ค. 2024
  • Access 7000+ courses for 15 days FREE: pluralsight.px...
    Dart beginners tutorial. Learn how to implement an Interface in Dart language. Since dart has no direct keyword of 'interface' so we need to follow some rules to make a normal class to act like an Interface. Also, learn how to override method while implementing an Interface.
    Next Video : • Dart STATIC variables ...
    Previous Video : • Dart Abstract Class an...
    Code Files: bit.ly/2XEVIzY .
    .
    Please donate and support my work
    (If you think my free tutorials are better than paid ones :)
    Patreon: bit.ly/patreon...
    Paypal/Payoneer: sriyank123@gmail.com
    UPI (only for India): smartherd@okaxis
    :: If you want to develop a website or a mobile app, email me your requirement at sriyank.siddhartha@gmail.com :: Free demos provided beforehand ::
    Access my premium courses: bit.ly/sriyank...
    Free Programming courses:
    Ruby Programming: bit.ly/smyt-r
    Dart Programming: bit.ly/smyt-d
    Kotlin Programming: bit.ly/smyt-k
    Java Programming: bit.ly/smyt-j
    Kotlin Coroutines: bit.ly/smyt-coru
    Free Flutter course:
    Flutter App Development: bit.ly/2Rg7EFR
    Free Android courses:
    Android using Kotlin: bit.ly/smyt-ka
    Android using Java: bit.ly/smyt-ja
    Android Material Design: bit.ly/2SMJqU6
    Android Jetpack Architecture: bit.ly/yt-j
    Android Multiple Screen Support: bit.ly/smyt-mss
    Android Retrofit: bit.ly/2Ee6GHn
    More free programming courses:
    bit.ly/smy-list
    Check out my website:
    bit.ly/smartherd
    Let's get in touch! [Sriyank Siddhartha]
    LinkedIn: bit.ly/sriyank...
    Facebook: bit.ly/smarthe...
    Instagram: bit.ly/sriyank...
    Twitter: bit.ly/sriyank...
    Github: bit.ly/smarthe...
    --- Thank you for your love and support ---

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

  • @TechWithDnes
    @TechWithDnes 4 ปีที่แล้ว +6

    Note: With the interface, we can implement multiple classes. Thus, implementing multiple inheritance would be possible with this interface concept.

  • @nadeemshahzad4416
    @nadeemshahzad4416 4 ปีที่แล้ว +9

    If we use Remote as parent class and Override its two methods in child class Television, then television has its own implementation of these two methods ..... So why we need Interface here ?

    • @midsummerstation3345
      @midsummerstation3345 3 ปีที่แล้ว +2

      I guess interface is used in very specific cases when you must override all the methods of the interface class. For the other cases, you can just override the extended class methods.

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

    why you arent uploading videos anymore. i know you still like and love our comments but why did you stop uploading videos?

  • @MohaMed-AdeL1
    @MohaMed-AdeL1 2 ปีที่แล้ว

    i am confused about data type are all objects but int or string or other are abstract class
    and when i write
    int x = 2;
    i create object with type int
    but int is abstract and i can't write int x = int();
    pleasaaaaaaaaaaase i am very confused help ???

  • @assoliladelgrada2880
    @assoliladelgrada2880 4 ปีที่แล้ว +2

    i didn't get it ... why we needed an abstract class when it;s as the same as the regular class
    and in the implementation what is the use of it when you are going to copy all the subjects to the child clas

    • @George-or3uv
      @George-or3uv 4 ปีที่แล้ว +1

      Hi Assolil, I am just studying this now, and I think I've found the answer for this in the book Quick Start Guide to Dart Programming, by Sanjib Sinha, I'm paraphrasing here... I guess that the key advantage is that with the abstract class, it cannot be instantiated, so you have the benefits of having a partial class implementation, which leaves the unimplemented piece to a subclass? An abstract class is also where we can define an interface but leave its implementation up to other classes. But, any class in dart abstract or concrete can be an interface.

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

    What if Remote and SomeOtherClass have the same method, and override in the Television class then in actuality which class method will override?

  • @JoaoCSpeixoto
    @JoaoCSpeixoto 6 ปีที่แล้ว +2

    If I'm going to use Implements, my class that will be implemented should not have to be abstract? Since I need to override the methods, in abstract class I just need to declare them. What's the point of using implement in an non abstract class?

    • @smartherd
      @smartherd  6 ปีที่แล้ว

      I did not understand what u want to say

    • @JoaoCSpeixoto
      @JoaoCSpeixoto 6 ปีที่แล้ว +2

      Thanks for the reply. I will try to explain with an example. This example makes more sense or not to understand implements and abstract class? It's my first day trying to understand them, so bare with me.
      main() {
      var volumeRemote=Remote();
      volumeRemote.volumeUp();
      var volumeTv=Tv();
      volumeTv.volumeUp();
      }
      abstract class Volume {
      void volumeUp();
      void volumeDown();
      }
      class Remote implements Volume {
      void volumeUp() => print("---volume up from remote----");
      void volumeDown() => print("---volume down from remote----");
      }
      class Tv implements Volume {
      void volumeUp() => print("---volume up from Tv----");
      void volumeDown() => print("---volume down from Tv----");
      }

    • @smartherd
      @smartherd  6 ปีที่แล้ว

      The whole point is, if you want to use a class as interface then use implements keyword. I am unable to get your confusion. You can see abstract class video and compare it with interface video.

    • @JoaoCSpeixoto
      @JoaoCSpeixoto 6 ปีที่แล้ว +2

      If I want to use a class as interface, should not the parent class be an abstract class? And use Implement on that parent class? using a normal class as you did as an interface doesn't make sense to me. my example just changed your code to an interface that makes sense to me. I was trying to understand if I'm thinking right or wrong. I know I can make an interface from any class, but should I? It's not a better approach from an abstract class? btw, your videos are very very good. I tried to watch lot's of different videos to learn Dart, your's are the best so far.

    • @sarveshyadav01
      @sarveshyadav01 4 ปีที่แล้ว +8

      @@JoaoCSpeixoto Let me explain what i understood :
      Have you ever played with remote control car?
      when you press forward , car goes forward and vice versa,
      since every function of remote have specific action on car...
      we need to override function of remote with implement to make car actionable. Since car will have same no. of function as remote.
      Implement help to create relation between remote forward and cars forward..
      and for abstract class.... i don't think it can establish relation between two objects with different class. Imagine you try to play with your friends car but use your remote car... will car work? of course not because even though it has same function as your remote (abstract class) their is no tuning of signals.....
      that tuning/relation is created by implement.
      let me know if you understood.... or you have better explanation.

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

    what is the diff between interface and abstract.

  • @MegaLearningStuff
    @MegaLearningStuff 6 ปีที่แล้ว +9

    Hmm, so it seems that interfaces in dart programming language can have implementations in them. Doesn't this defeat the purpose of interface? How is it different from abstract class now?

    • @VivekYadav-ds8oz
      @VivekYadav-ds8oz 4 ปีที่แล้ว +2

      Exactly my doubt.

    • @NimoArts
      @NimoArts 3 ปีที่แล้ว

      Interfaces are not the same as in other programming languages.
      "Class declarations are themselves interfaces in Dart."
      www.tutorialspoint.com/dart_programming/dart_programming_interfaces.htm

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

    Mahn you are good;

  • @MadeInKurdistan
    @MadeInKurdistan 3 ปีที่แล้ว

    So obvoius well done man

  • @alanturing454
    @alanturing454 3 ปีที่แล้ว

    when do we need to use override method. can someone explain me

    • @vighneshsharma
      @vighneshsharma 2 ปีที่แล้ว

      Just when you saw an error or issues to write @override

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

    Why we didn't use @override?

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

      That's just annotation

  • @MrPDTaylor
    @MrPDTaylor 4 ปีที่แล้ว +2

    I can't help but say that if it isn't mandatory then it isn't an interface.

  • @MassimoTodaro74
    @MassimoTodaro74 5 ปีที่แล้ว

    Guess the purpose of this Interfaces and Abstract classes is to comply with the 'O' in SOLID principles?

  • @krishnakumarramachandran5888
    @krishnakumarramachandran5888 5 ปีที่แล้ว

    Super sir👍

  • @shivatiwari1127
    @shivatiwari1127 4 ปีที่แล้ว

    👌

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

    I dont know where im gonna use this lol

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

      widgets in flutter , good luck

  • @learnwithshash1475
    @learnwithshash1475 3 ปีที่แล้ว

    what the heck is an interface.....explain the meanings of different terms first....the content is good but a lot of information missing in between and the course is not complete.

  • @sealandland3959
    @sealandland3959 2 ปีที่แล้ว

    You should do a version of this, but in English....

  • @pratyakshpandey2248
    @pratyakshpandey2248 3 ปีที่แล้ว

    First of all, you should tell a person what is an interface and related terms to it. You directly start with the implementation which is not a good practice. If a person is unaware of the terms or if he/she didn't code before then you are not a good teacher for him/her. Sorry, but that's the truth. You have change your style of teaching. Some of your videos are really good but some are real shit.

    • @smartherd
      @smartherd  3 ปีที่แล้ว

      Kindly check java videos to understand interface in detail. This dart and kotlin series are intentionally not in detail.