{"id":32629,"date":"2024-11-01T09:10:27","date_gmt":"2024-11-01T09:10:27","guid":{"rendered":"http:\/\/atmokpo.com\/w\/?p=32629"},"modified":"2024-11-01T11:54:32","modified_gmt":"2024-11-01T11:54:32","slug":"flutter-course-9-1-what-is-inheritance","status":"publish","type":"post","link":"https:\/\/atmokpo.com\/w\/32629\/","title":{"rendered":"Flutter Course: 9.1 What is Inheritance?"},"content":{"rendered":"<p>\n    One of the core concepts of programming, inheritance is one of the most important features of object-oriented programming,<br \/>\n    and Flutter also follows the principles of object-oriented programming.<br \/>\n    In this course, we will explain the concept of inheritance in Flutter, how to use it, and through practical examples,<br \/>\n    you will gain a deep understanding of inheritance.\n<\/p>\n<h2>1. Definition of Inheritance<\/h2>\n<p>\n    Inheritance refers to the process where a new class (child class or subclass) inherits the properties and<br \/>\n    methods of an existing class (parent class or super class). This maximizes code reuse and allows<br \/>\n    for easy expression of relationships between classes.\n<\/p>\n<h2>2. Necessity of Inheritance<\/h2>\n<p>\n    Inheritance is necessary for the following reasons:\n<\/p>\n<ul>\n<li><strong>Code Reuse:<\/strong> By reusing the code that has already been written in a new class,<br \/>\n        it reduces code duplication and makes maintenance easier.<\/li>\n<li><strong>Maintenance:<\/strong> Changes or bug fixes in the parent class are automatically applied<br \/>\n        to all child classes that inherit from it.<\/li>\n<li><strong>Hierarchical Structure:<\/strong> It creates a hierarchical structure among related classes<br \/>\n        contributing to the readability of the program.<\/li>\n<\/ul>\n<h2>3. How to Use Inheritance in Flutter<\/h2>\n<p>\n    Since Flutter is based on the Dart language, it follows the inheritance implementation of Dart.<br \/>\n    To inherit a class in Dart, the `extends` keyword is used.<br \/>\n    The basic syntax is as follows.\n<\/p>\n<pre>\nclass Parent {\n    void show() {\n        print(\"This is a method of the parent class.\");\n    }\n}\n\nclass Child extends Parent {\n    void display() {\n        print(\"This is a method of the child class.\");\n    }\n}\n<\/pre>\n<p>\n    In the above example, the `Child` class inherits from the `Parent` class,<br \/>\n    allowing it to use the `show()` method while also defining its own<br \/>\n    `display()` method.\n<\/p>\n<h2>4. Method Overriding<\/h2>\n<p>\n    The process of redefining a parent class method in a child class through inheritance<br \/>\n    is called Method Overriding.<br \/>\n    This allows the child class to implement the parent class method<br \/>\n    in its own way.\n<\/p>\n<pre>\nclass Parent {\n    void show() {\n        print(\"Parent class's show()\");\n    }\n}\n\nclass Child extends Parent {\n    @override\n    void show() {\n        print(\"Child class's show()\");\n    }\n}\n<\/pre>\n<p>\n    By using the `@override` keyword, you can explicitly indicate the method you are overriding<br \/>\n    that was inherited from the parent class,<br \/>\n    thus increasing the clarity of the code.\n<\/p>\n<h2>5. Multiple Inheritance and Mixins<\/h2>\n<p>\n    Dart does not support multiple inheritance, but you can<br \/>\n    combine multiple classes using mixins. A mixin is<br \/>\n    a way to reuse code through classes that are not classes themselves.<br \/>\n    To define a mixin, you can use the `mixins` keyword.\n<\/p>\n<pre>\nmixin MixinA {\n    void methodA() {\n        print(\"Method of Mixin A\");\n    }\n}\n\nclass Base {}\n\nclass Child extends Base with MixinA {\n    void methodB() {\n        print(\"Method of the child class\");\n    }\n}\n<\/pre>\n<p>\n    In this example, the `Child` class is able to use<br \/>\n    the `methodA()` method through the `MixinA` mixin.<br \/>\n    In other words, mixins enable code reuse as an alternative to multiple inheritance.\n<\/p>\n<h2>6. Practical Example: Utilizing Inheritance in Flutter<\/h2>\n<p>\n    Now let&#8217;s create a simple example that utilizes inheritance<br \/>\n    in a Flutter application. Here, we will show how to use<br \/>\n    inheritance along with basic UI composition.\n<\/p>\n<pre>\nimport 'package:flutter\/material.dart';\n\nvoid main() {\n  runApp(MyApp());\n}\n\nclass MyApp extends StatelessWidget {\n  @override\n  Widget build(BuildContext context) {\n    return MaterialApp(\n      home: HomeScreen(),\n    );\n  }\n}\n\nclass HomeScreen extends StatelessWidget {\n  @override\n  Widget build(BuildContext context) {\n    return Scaffold(\n      appBar: AppBar(title: Text('Inheritance Example')),\n      body: Center(\n        child: Column(\n          mainAxisAlignment: MainAxisAlignment.center,\n          children: <widget>[\n            ChildWidget(),\n            SizedBox(height: 20),\n            ParentWidget(),\n          ],\n        ),\n      ),\n    );\n  }\n}\n\nclass ParentWidget extends StatelessWidget {\n  @override\n  Widget build(BuildContext context) {\n    return Text(\n      'This is the parent class.',\n      style: TextStyle(fontSize: 24),\n    );\n  }\n}\n\nclass ChildWidget extends ParentWidget {\n  @override\n  Widget build(BuildContext context) {\n    return Text(\n      'This is the child class.',\n      style: TextStyle(fontSize: 24, color: Colors.blue),\n    );\n  }\n}\n<\/widget><\/pre>\n<p>\n    The above code describes two widget classes.<br \/>\n    `ParentWidget` outputs basic text, while<br \/>\n    `ChildWidget` inherits from `ParentWidget` and changes<br \/>\n    the text color.<br \/>\n    This shows how inheritance can be used to change or<br \/>\n    extend the properties of UI widgets.\n<\/p>\n<h2>7. Summary<\/h2>\n<p>\n    In this lesson, we learned about the concept of inheritance in Flutter and<br \/>\n    its necessity, explained the inheritance syntax in Dart,<br \/>\n    method overriding, and advanced concepts such as mixins.<br \/>\n    We also confirmed how inheritance is utilized through a practical example and<br \/>\n    learned how to effectively use inheritance in a Flutter application.\n<\/p>\n<p>\n    Inheritance is one of the central concepts of object-oriented programming,<br \/>\n    and it plays an important role when developing Flutter applications.<br \/>\n    In future lessons, we will discuss extending inheritance to develop complex<br \/>\n    applications.<br \/>\n    We hope this course provides insight into understanding the basic concept of inheritance and<br \/>\n    how it can be applied in programming.\n<\/p>\n<footer>\n<p>Author: [Author Name] | Date: [Date]<\/p>\n<\/footer>\n","protected":false},"excerpt":{"rendered":"<p>One of the core concepts of programming, inheritance is one of the most important features of object-oriented programming, and Flutter also follows the principles of object-oriented programming. In this course, we will explain the concept of inheritance in Flutter, how to use it, and through practical examples, you will gain a deep understanding of inheritance. &hellip; <a href=\"https:\/\/atmokpo.com\/w\/32629\/\" class=\"more-link\">\ub354 \ubcf4\uae30<span class=\"screen-reader-text\"> &#8220;Flutter Course: 9.1 What is Inheritance?&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[151],"tags":[],"class_list":["post-32629","post","type-post","status-publish","format-standard","hentry","category-flutter-course"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Flutter Course: 9.1 What is Inheritance? - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/atmokpo.com\/w\/32629\/\" \/>\n<meta property=\"og:locale\" content=\"ko_KR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Flutter Course: 9.1 What is Inheritance? - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"og:description\" content=\"One of the core concepts of programming, inheritance is one of the most important features of object-oriented programming, and Flutter also follows the principles of object-oriented programming. In this course, we will explain the concept of inheritance in Flutter, how to use it, and through practical examples, you will gain a deep understanding of inheritance. &hellip; \ub354 \ubcf4\uae30 &quot;Flutter Course: 9.1 What is Inheritance?&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/atmokpo.com\/w\/32629\/\" \/>\n<meta property=\"og:site_name\" content=\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"article:published_time\" content=\"2024-11-01T09:10:27+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-11-01T11:54:32+00:00\" \/>\n<meta name=\"author\" content=\"root\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@bebubo4\" \/>\n<meta name=\"twitter:site\" content=\"@bebubo4\" \/>\n<meta name=\"twitter:label1\" content=\"\uae00\uc4f4\uc774\" \/>\n\t<meta name=\"twitter:data1\" content=\"root\" \/>\n\t<meta name=\"twitter:label2\" content=\"\uc608\uc0c1 \ub418\ub294 \ud310\ub3c5 \uc2dc\uac04\" \/>\n\t<meta name=\"twitter:data2\" content=\"4\ubd84\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/atmokpo.com\/w\/32629\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/32629\/\"},\"author\":{\"name\":\"root\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7\"},\"headline\":\"Flutter Course: 9.1 What is Inheritance?\",\"datePublished\":\"2024-11-01T09:10:27+00:00\",\"dateModified\":\"2024-11-01T11:54:32+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/atmokpo.com\/w\/32629\/\"},\"wordCount\":553,\"publisher\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\"},\"articleSection\":[\"Flutter course\"],\"inLanguage\":\"ko-KR\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/atmokpo.com\/w\/32629\/\",\"url\":\"https:\/\/atmokpo.com\/w\/32629\/\",\"name\":\"Flutter Course: 9.1 What is Inheritance? - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#website\"},\"datePublished\":\"2024-11-01T09:10:27+00:00\",\"dateModified\":\"2024-11-01T11:54:32+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/atmokpo.com\/w\/32629\/#breadcrumb\"},\"inLanguage\":\"ko-KR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/atmokpo.com\/w\/32629\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/atmokpo.com\/w\/32629\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\ud648\",\"item\":\"https:\/\/atmokpo.com\/w\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Flutter Course: 9.1 What is Inheritance?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/atmokpo.com\/w\/#website\",\"url\":\"https:\/\/atmokpo.com\/w\/\",\"name\":\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/atmokpo.com\/w\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"ko-KR\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\",\"name\":\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"url\":\"https:\/\/atmokpo.com\/w\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ko-KR\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png\",\"contentUrl\":\"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png\",\"width\":400,\"height\":400,\"caption\":\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\"},\"image\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/x.com\/bebubo4\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7\",\"name\":\"root\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ko-KR\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g\",\"caption\":\"root\"},\"sameAs\":[\"http:\/\/atmokpo.com\/w\"],\"url\":\"https:\/\/atmokpo.com\/w\/author\/root\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Flutter Course: 9.1 What is Inheritance? - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/atmokpo.com\/w\/32629\/","og_locale":"ko_KR","og_type":"article","og_title":"Flutter Course: 9.1 What is Inheritance? - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","og_description":"One of the core concepts of programming, inheritance is one of the most important features of object-oriented programming, and Flutter also follows the principles of object-oriented programming. In this course, we will explain the concept of inheritance in Flutter, how to use it, and through practical examples, you will gain a deep understanding of inheritance. &hellip; \ub354 \ubcf4\uae30 \"Flutter Course: 9.1 What is Inheritance?\"","og_url":"https:\/\/atmokpo.com\/w\/32629\/","og_site_name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","article_published_time":"2024-11-01T09:10:27+00:00","article_modified_time":"2024-11-01T11:54:32+00:00","author":"root","twitter_card":"summary_large_image","twitter_creator":"@bebubo4","twitter_site":"@bebubo4","twitter_misc":{"\uae00\uc4f4\uc774":"root","\uc608\uc0c1 \ub418\ub294 \ud310\ub3c5 \uc2dc\uac04":"4\ubd84"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/atmokpo.com\/w\/32629\/#article","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/32629\/"},"author":{"name":"root","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7"},"headline":"Flutter Course: 9.1 What is Inheritance?","datePublished":"2024-11-01T09:10:27+00:00","dateModified":"2024-11-01T11:54:32+00:00","mainEntityOfPage":{"@id":"https:\/\/atmokpo.com\/w\/32629\/"},"wordCount":553,"publisher":{"@id":"https:\/\/atmokpo.com\/w\/#organization"},"articleSection":["Flutter course"],"inLanguage":"ko-KR"},{"@type":"WebPage","@id":"https:\/\/atmokpo.com\/w\/32629\/","url":"https:\/\/atmokpo.com\/w\/32629\/","name":"Flutter Course: 9.1 What is Inheritance? - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/#website"},"datePublished":"2024-11-01T09:10:27+00:00","dateModified":"2024-11-01T11:54:32+00:00","breadcrumb":{"@id":"https:\/\/atmokpo.com\/w\/32629\/#breadcrumb"},"inLanguage":"ko-KR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/atmokpo.com\/w\/32629\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/atmokpo.com\/w\/32629\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\ud648","item":"https:\/\/atmokpo.com\/w\/en\/"},{"@type":"ListItem","position":2,"name":"Flutter Course: 9.1 What is Inheritance?"}]},{"@type":"WebSite","@id":"https:\/\/atmokpo.com\/w\/#website","url":"https:\/\/atmokpo.com\/w\/","name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","description":"","publisher":{"@id":"https:\/\/atmokpo.com\/w\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/atmokpo.com\/w\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"ko-KR"},{"@type":"Organization","@id":"https:\/\/atmokpo.com\/w\/#organization","name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","url":"https:\/\/atmokpo.com\/w\/","logo":{"@type":"ImageObject","inLanguage":"ko-KR","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/","url":"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png","contentUrl":"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png","width":400,"height":400,"caption":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8"},"image":{"@id":"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/bebubo4"]},{"@type":"Person","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7","name":"root","image":{"@type":"ImageObject","inLanguage":"ko-KR","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g","caption":"root"},"sameAs":["http:\/\/atmokpo.com\/w"],"url":"https:\/\/atmokpo.com\/w\/author\/root\/"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/32629","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/comments?post=32629"}],"version-history":[{"count":1,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/32629\/revisions"}],"predecessor-version":[{"id":32630,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/32629\/revisions\/32630"}],"wp:attachment":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/media?parent=32629"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/categories?post=32629"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/tags?post=32629"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}