{"id":369369,"date":"2024-05-21T04:01:53","date_gmt":"2024-05-21T04:01:53","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=369369"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2024-05-21T04:01:53","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=369369","title":{"rendered":"<span>\u0412 \u043e\u0431\u0449\u0438\u0445 \u0441\u043b\u043e\u0432\u0430\u0445 \u043f\u0440\u043e \u042f\u041f Dart<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/808\/1a6\/cd3\/8081a6cd30bd452a74c1b8c91c757b77.png\" width=\"780\" height=\"439\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/808\/1a6\/cd3\/8081a6cd30bd452a74c1b8c91c757b77.png\"\/><\/figure>\n<p><em>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440!<\/em><\/p>\n<p>\u0418\u0441\u0442\u043e\u0440\u0438\u044f <strong>Dart<\/strong><s>h\u00a0Vader<\/s> \u043d\u0430\u0447\u0430\u043b\u0430\u0441\u044c \u0432 2011 \u0433\u043e\u0434\u0443. \u0426\u0435\u043b\u044c\u044e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f Dart \u0431\u044b\u043b\u043e \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0438\u0442\u044c <strong>\u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u0443 JavaScript<\/strong>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u043b\u0430 \u0431\u044b \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0435, \u0432\u044b\u0441\u043e\u043a\u043e\u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0432\u0435\u0431-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043e\u0431\u043b\u0435\u0433\u0447\u0430\u044f \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438. <\/p>\n<p>\u0421\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c Dart \u043f\u0440\u0435\u0442\u0435\u0440\u043f\u0435\u043b \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0430\u043f\u0434\u0435\u0439\u0442\u043e\u0432, \u043d\u043e \u0435\u0433\u043e \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0440\u044b\u0432\u043e\u043a \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u0435\u043b \u0441 \u0437\u0430\u043f\u0443\u0441\u043a\u043e\u043c <strong>Flutter<\/strong> \u2014 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0445 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432 \u0434\u043b\u044f \u043c\u043e\u0431\u0438\u043b\u044c\u043d\u044b\u0445, \u0432\u0435\u0431- \u0438 \u043d\u0430\u0441\u0442\u043e\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0438\u0437 \u0435\u0434\u0438\u043d\u043e\u0439 \u043a\u043e\u0434\u043e\u0432\u043e\u0439 \u0431\u0430\u0437\u044b. <\/p>\n<p>\u042f\u0437\u044b\u043a \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 <strong>\u041e\u041e\u041f<\/strong> \u0441 \u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438 \u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435\u043c, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a \u0432\u044b\u0441\u0448\u0438\u0435 \u043f\u043e\u0440\u044f\u0434\u043a\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u0437\u0430\u043c\u044b\u043a\u0430\u043d\u0438\u044f \u0438 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0441\u0442\u044c \u0438 \u0442.\u043f.<\/p>\n<p>\u0421\u0438\u0441\u0442\u0435\u043c\u0430 \u0442\u0438\u043f\u043e\u0432 \u0432 Dart \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u043a\u0430\u043a <strong>\u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044e,<\/strong> \u0442\u0430\u043a \u0438 <strong>\u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044e \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f.<\/strong><\/p>\n<h3>\u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438<\/h3>\n<h4>\u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0438 \u0442\u0438\u043f\u044b \u0434\u0430\u043d\u043d\u044b\u0445<\/h4>\n<p><code>var<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0431\u0435\u0437 \u044f\u0432\u043d\u043e\u0433\u043e \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u0435\u0451 \u0442\u0438\u043f\u0430. Dart \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0442\u0438\u043f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043f\u0440\u0438\u0441\u0432\u043e\u0435\u043d\u043d\u043e\u0433\u043e \u0435\u0439 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f:<\/p>\n<pre><code class=\"dart\">var name = 'Dart'; \/\/ dart \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u0442, \u0447\u0442\u043e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f name \u0438\u043c\u0435\u0435\u0442 \u0442\u0438\u043f string var version = 2.12; \/\/ dart \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442, \u0447\u0442\u043e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f version` \u0438\u043c\u0435\u0435\u0442 \u0442\u0438\u043f double<\/code><\/pre>\n<p>\u0427\u0442\u043e \u043a\u0430\u0441\u0430\u0442\u0435\u043b\u044c\u043d\u043e <strong>\u043d\u0435\u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445<\/strong>, Dart \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u0438\u043c\u0435\u0435\u0442 \u0434\u0432\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438: <code>final<\/code> \u0438 <code>const<\/code>.<\/p>\n<ul>\n<li>\n<p><code>final<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <strong>\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b<\/strong> \u0438 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u043e \u043f\u043e\u0441\u043b\u0435 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043f\u0440\u0438\u0441\u0432\u043e\u0435\u043d\u0438\u044f.<\/p>\n<\/li>\n<li>\n<p><code>const<\/code> \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u043a \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 <strong>\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u0438 \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u043d\u044b\u043c<\/strong> \u043d\u0430 \u043f\u0440\u043e\u0442\u044f\u0436\u0435\u043d\u0438\u0438 \u0432\u0441\u0435\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f.<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"dart\">final userName = 'otus'; const double PI = 3.14;<\/code><\/pre>\n<p>Dart \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 <strong>\u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044e<\/strong>:<\/p>\n<pre><code class=\"dart\">String language = 'Dart'; int year = 2023; double version = 2.10; List&lt;String> developers = ['artem', 'ivan', 'igor']; Map&lt;String, dynamic> info = {   'name': 'Dart',   'created': 2008, };<\/code><\/pre>\n<p>Dart \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442<code>List<\/code>, <code>Set<\/code>, \u0438 <code>Map<\/code>:<\/p>\n<ul>\n<li>\n<p><strong>List<\/strong>: \u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0435\u043d\u043d\u0430\u044f \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043e\u0434\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430.<\/p>\n<\/li>\n<li>\n<p><strong>Set<\/strong>: \u043d\u0435\u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0435\u043d\u043d\u0430\u044f \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432.<\/p>\n<\/li>\n<li>\n<p><strong>Map<\/strong>: \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f \u043f\u0430\u0440 \u043a\u043b\u044e\u0447-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0433\u0434\u0435 \u043a\u0430\u0436\u0434\u044b\u0439 \u043a\u043b\u044e\u0447 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0435\u0442\u0441\u044f \u043d\u0435 \u0431\u043e\u043b\u0435\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u0430.<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"dart\">List&lt;int> primeNumbers = [2, 3, 5, 7, 11]; Set&lt;String> languages = {'Dart', 'Flutter', 'Java'}; Map&lt;String, String> headers = {   'Content-Type': 'application\/json',   'Authorization': 'Bearer your_token', };<\/code><\/pre>\n<h4>\u0424\u0443\u043d\u043a\u0446\u0438\u0438  <\/h4>\n<p>\u0418\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0432 \u0444\u0438\u0433\u0443\u0440\u043d\u044b\u0445 \u0441\u043a\u043e\u0431\u043a\u0430\u0445 <code>{}<\/code>:<\/p>\n<pre><code class=\"dart\">void printUserInfo({String name, int age}) {   print('Name: $name, Age: $age'); }  void main() {   \/\/ \u0432\u044b\u0437\u043e\u0432   printUserInfo(name: 'ivan', age: 30); }<\/code><\/pre>\n<p>Dart \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 <strong>\u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u043e\u0437\u0438\u0446\u0438\u043e\u043d\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b<\/strong> \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>[]<\/code>:<\/p>\n<pre><code class=\"dart\">void printMessage(String message, [String author = 'Anonymous']) {   print('$message \u2014 $author'); }  void printUserInfoOptional({String name = 'Unknown', int age}) {   print('Name: $name, Age: $age'); }  void main() {   \/\/ \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0441 \u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u043f\u043e\u0437\u0438\u0446\u0438\u043e\u043d\u043d\u044b\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c   printMessage('Hello, Dart!');   \/\/ \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0441 \u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c   printUserInfoOptional(age: 25); }<\/code><\/pre>\n<p><strong>\u0424\u0443\u043d\u043a\u0446\u0438\u0438 \u0432\u044b\u0441\u0448\u0435\u0433\u043e \u043f\u043e\u0440\u044f\u0434\u043a\u0430<\/strong> \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0442 \u0434\u0440\u0443\u0433\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0438\u043b\u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0442 \u0438\u0445:<\/p>\n<pre><code class=\"dart\">void operateOnNumbers(int a, int b, Function(int, int) operation) {   var result = operation(a, b);   print('Result: $result'); }  int sum(int x, int y) => x + y; int product(int x, int y) => x * y;  void main() {   \/\/ \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432\u044b\u0441\u0448\u0435\u0433\u043e \u043f\u043e\u0440\u044f\u0434\u043a\u0430   operateOnNumbers(3, 4, sum); \/\/ Result: 7   operateOnNumbers(3, 4, product); \/\/ Result: 12    \/\/ use \u0430\u043d\u043e\u043d\u0438\u043c\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438   operateOnNumbers(3, 4, (x, y) => x - y); \/\/ Result: -1 }<\/code><\/pre>\n<h4>\u041a\u043b\u0430\u0441\u0441\u044b \u0438 \u041e\u041e\u041f<\/h4>\n<p>\u0412 Dart \u043a\u043b\u0430\u0441\u0441\u044b \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0441\u043e\u0431\u043e\u0439 \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e \u0434\u043b\u044f \u0438\u043d\u043a\u0430\u043f\u0441\u0443\u043b\u044f\u0446\u0438\u0438 \u0438 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u0430:<\/p>\n<pre><code class=\"dart\">class Car {   String make;   String model;   int year;    \/\/ \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440   Car(this.make, this.model, this.year);    \/\/ \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440   Car.named({required this.make, required this.model, required this.year});    \/\/ \u043c\u0435\u0442\u043e\u0434 \u0434\u043b\u044f \u0432\u044b\u0432\u043e\u0434\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0430\u0432\u0442\u043e\u043c\u043e\u0431\u0438\u043b\u044f   void displayInfo() {     print('Make: $make, Model: $model, Year: $year');   } }  void main() {   var myCar = Car('Toyota', 'Corolla', 2020);   myCar.displayInfo();    var mySecondCar = Car.named(make: 'Ford', model: 'Mustang', year: 1969);   mySecondCar.displayInfo(); }<\/code><\/pre>\n<p><strong>\u041d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435<\/strong> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043a\u043b\u0430\u0441\u0441\u0443 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0438 \u043c\u0435\u0442\u043e\u0434\u044b \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430, \u044e\u0437\u0430\u0435\u0442\u0441\u044f \u0441\u043b\u043e\u0432\u043e <code>extends<\/code> \u0434\u043b\u044f \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f:<\/p>\n<pre><code class=\"dart\">class ElectricCar extends Car {   double batteryCapacity;    ElectricCar(String make, String model, int year, this.batteryCapacity)       : super(make, model, year);    @override   void displayInfo() {     super.displayInfo();     print('Battery Capacity: $batteryCapacity kWh');   } }  void main() {   var myElectricCar = ElectricCar('Tesla', 'Model Y', 2023, 85.0);   myElectricCar.displayInfo(); }<\/code><\/pre>\n<p><strong>\u0410\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0435 \u043a\u043b\u0430\u0441\u0441\u044b<\/strong> \u0432 Dart \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u043a\u0430\u043a \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u043a\u043b\u0430\u0441\u0441\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f \u0438\u043d\u0441\u0442\u0430\u043d\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e:<\/p>\n<pre><code class=\"dart\">abstract class Shape {   void draw(); \/\/ \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 }  class Circle extends Shape {   @override   void draw() {     print('Drawing circle...');   } }  class Square extends Shape {   @override   void draw() {     print('Drawing square...');   } }  void main() {   var circle = Circle();   circle.draw();    var square = Square();   square.draw(); }<\/code><\/pre>\n<p>\u0412 Dart <strong>\u043d\u0435\u0442 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0430<\/strong> \u0434\u043b\u044f \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f <strong>\u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432<\/strong>. \u041b\u044e\u0431\u043e\u0439 \u043a\u043b\u0430\u0441\u0441 \u043c\u043e\u0436\u0435\u0442 \u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u043a \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u0438 \u0434\u0440\u0443\u0433\u043e\u0439 \u043a\u043b\u0430\u0441\u0441 \u043c\u043e\u0436\u0435\u0442 \u0435\u0433\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0441 <code>implements<\/code>:<\/p>\n<pre><code class=\"dart\">class Vehicle {   void start() => print(\"Vehicle started\");   void stop() => print(\"Vehicle stopped\"); }  class Bike implements Vehicle {   @override   void start() => print(\"Bike started\");    @override   void stop() => print(\"Bike stopped\"); }  void main() {   var bike = Bike();   bike.start();   bike.stop(); }<\/code><\/pre>\n<h4>\u0423\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0435 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438  <\/h4>\n<p>\u0417\u0434\u0435\u0441\u044c \u0432\u0441\u0435 \u0438\u043d\u0442\u0443\u0438\u0442\u0438\u0432\u043d\u043e.<\/p>\n<p><strong>\u0423\u0441\u043b\u043e\u0432\u043d\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u044b<\/strong> <code>if-else<\/code> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u0431\u043b\u043e\u043a \u043a\u043e\u0434\u0430 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0442\u043e\u0433\u043e, \u0438\u0441\u0442\u0438\u043d\u043d\u043e \u043b\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u0435:<\/p>\n<pre><code class=\"dart\">int number = 10; if (number % 2 == 0) {   print('$number is even'); } else {   print('$number is odd'); }<\/code><\/pre>\n<p><strong>\u0426\u0438\u043a\u043b\u044b<\/strong> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0431\u043b\u043e\u043a\u0430 \u043a\u043e\u0434\u0430, \u043f\u043e\u043a\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u0435:<\/p>\n<pre><code class=\"dart\">for (int i = 0; i &lt; 5; i++) {   print('i = $i'); }<\/code><\/pre>\n<p><strong>while<\/strong> \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0431\u043b\u043e\u043a \u043a\u043e\u0434\u0430, \u043f\u043e\u043a\u0430 \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u0438\u0441\u0442\u0438\u043d\u043d\u043e:<\/p>\n<pre><code class=\"dart\">int num = 5; while (num > 0) {   print('num = $num');   num--; }<\/code><\/pre>\n<p><strong>do-while<\/strong>: \u043f\u043e\u0445\u043e\u0436 \u043d\u0430 <code>while<\/code>, \u043d\u043e \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442, \u0447\u0442\u043e \u0442\u0435\u043b\u043e \u0446\u0438\u043a\u043b\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u0441\u044f \u0445\u043e\u0442\u044f \u0431\u044b \u043e\u0434\u0438\u043d \u0440\u0430\u0437:<\/p>\n<pre><code class=\"dart\">int count = 0; do {   print('count = $count');   count++; } while (count &lt; 5);<\/code><\/pre>\n<p><code>switch-case<\/code> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0431\u043b\u043e\u043a\u0438 \u043a\u043e\u0434\u0430 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439:<\/p>\n<pre><code class=\"dart\">String grade = 'B'; switch (grade) {   case 'A':     print('Excellent');     break;   case 'B':     print('Good');     break;   case 'C':     print('Fair');     break;   case 'D':   case 'F':     print('Poor');     break;   default:     print('Invalid grade'); }<\/code><\/pre>\n<p>\u041c\u043e\u0436\u043d\u043e \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>throw<\/code> \u0438 \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0438\u0445 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>try-catch<\/code>:<\/p>\n<pre><code class=\"dart\">void checkAge(int age) {   if (age &lt; 18) {     throw Exception('Not eligible for voting');   } else {     print('Eligible for voting');   } }  try {   checkAge(16); } catch (e) {   print('Caught an exception: $e'); } finally {   print('This is always executed'); }<\/code><\/pre>\n<h4>null safety<\/h4>\n<p>\u0412 Dart \u0441 \u0432\u043a\u043b\u044e\u0447\u0451\u043d\u043d\u044b\u043c null safety \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043d\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c null:<\/p>\n<pre><code class=\"dart\">int a = null; \/\/ err<\/code><\/pre>\n<p>\u0427\u0442\u043e\u0431\u044b \u043e\u0431\u044a\u044f\u0432\u0438\u0442\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c null, \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0437\u043d\u0430\u043a \u0432\u043e\u043f\u0440\u043e\u0441\u0430 \u043f\u043e\u0441\u043b\u0435 \u0442\u0438\u043f\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439:<\/p>\n<pre><code class=\"dart\">int? a = null; \/\/ \u041e\u041a<\/code><\/pre>\n<p>\u041a\u043e\u0433\u0434\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c null, Dart \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043e\u0442 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u044d\u0442\u0443 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c, \u043a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0451 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435:<\/p>\n<pre><code class=\"dart\">int? a;  if (a != null) {   print(a + 2); \/\/ \u041e\u041a, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043c\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043b\u0438, \u0447\u0442\u043e a \u043d\u0435 null }<\/code><\/pre>\n<p>\u041e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 <code>!<\/code> \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0443: &#171;\u042f \u0443\u0432\u0435\u0440\u0435\u043d, \u0447\u0442\u043e \u044d\u0442\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u043d\u0435 null&#187;. \u0415\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u044e\u0437\u0430\u0442\u044c \u0441 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043e\u0441\u0442\u043e\u0440\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e:<\/p>\n<pre><code class=\"dart\">int? a = null; print(a! + 2); \/\/ \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f<\/code><\/pre>\n<p>\u041e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u044b <code>??=<\/code> \u0438 <code>??<\/code> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c null, \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u044f \u0438\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e.<\/p>\n<ul>\n<li>\n<p><code>??=<\/code> \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439, \u0435\u0441\u043b\u0438 \u043e\u043d\u0430 null.<\/p>\n<\/li>\n<li>\n<p><code>??<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u043f\u0440\u0430\u0432\u0430 \u043e\u0442 \u0441\u0435\u0431\u044f, \u0435\u0441\u043b\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u043b\u0435\u0432\u0430 \u043e\u0442 \u043d\u0435\u0433\u043e \u2014 null.<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"dart\">int? a; a ??= 10; \/\/ a \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0432\u043d\u043e 10, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0434\u043e \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u043d\u0438\u044f a \u0431\u044b\u043b\u043e null print(a); \/\/  10  int? b = null; print(b ?? 20); \/\/ 20, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e b \u0440\u0430\u0432\u043d\u043e null<\/code><\/pre>\n<h4>Dart \u0441 Flutter<\/h4>\n<p>\u0412 Flutter \u0435\u0441\u0442\u044c \u0434\u0432\u0430 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u0442\u0438\u043f\u0430 \u0432\u0438\u0434\u0436\u0435\u0442\u043e\u0432: <code>StatefulWidget<\/code> \u0438 <code>StatelessWidget<\/code>. <code>StatelessWidget<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0432\u0438\u0434\u0436\u0435\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u044f\u044e\u0442 \u0441\u0432\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f, \u0430 <code>StatefulWidget<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0432\u0438\u0434\u0436\u0435\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u0441\u0432\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0432 \u043e\u0442\u0432\u0435\u0442 \u043d\u0430 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438\u043b\u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0444\u0430\u043a\u0442\u043e\u0440\u044b<\/p>\n<p><strong>StatelessWidget:<\/strong><\/p>\n<pre><code class=\"dart\">import 'package:flutter\/material.dart';  void main() => runApp(MyApp());  class MyApp extends StatelessWidget {   @override   Widget build(BuildContext context) {     return MaterialApp(       home: Scaffold(         appBar: AppBar(           title: Text('\u041f\u0440\u0438\u043c\u0435\u0440 StatelessWidget'),         ),         body: Center(           child: Text('\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440!'),         ),       ),     );   } }<\/code><\/pre>\n<p><strong>StatefulWidget:<\/strong><\/p>\n<pre><code class=\"dart\">import 'package:flutter\/material.dart';  void main() => runApp(MyApp());  class MyApp extends StatefulWidget {   @override   _MyAppState createState() => _MyAppState(); }  class _MyAppState extends State&lt;MyApp> {   int _counter = 0;    void _incrementCounter() {     setState(() {       _counter++;     });   }    @override   Widget build(BuildContext context) {     return MaterialApp(       home: Scaffold(         appBar: AppBar(           title: Text('\u041f\u0440\u0438\u043c\u0435\u0440 StatefulWidget'),         ),         body: Center(           child: Column(             mainAxisAlignment: MainAxisAlignment.center,             children: &lt;Widget>[               Text('\u0412\u044b \u043d\u0430\u0436\u0430\u043b\u0438 \u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0443 \u0441\u0442\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437:'),               Text('$_counter', style: Theme.of(context).textTheme.headline4),             ],           ),         ),         floatingActionButton: FloatingActionButton(           onPressed: _incrementCounter,           tooltip: 'Increment',           child: Icon(Icons.add),         ),       ),     );   } }<\/code><\/pre>\n<p>Flutter \u043e\u0431\u043b\u0435\u0433\u0447\u0430\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u043c\u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f\u043c\u0438 \u0447\u0435\u0440\u0435\u0437 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 <code>FutureBuilder<\/code>:<\/p>\n<pre><code class=\"dart\">import 'package:flutter\/material.dart'; import 'dart:async';  void main() => runApp(MyApp());  class MyApp extends StatelessWidget {   final Future&lt;String> _calculation = Future&lt;String>.delayed(     Duration(seconds: 2),     () => '\u0414\u0430\u043d\u043d\u044b\u0435 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u044b',   );    @override   Widget build(BuildContext context) {     return MaterialApp(       home: Scaffold(         appBar: AppBar(           title: Text('\u041f\u0440\u0438\u043c\u0435\u0440 FutureBuilder'),         ),         body: Center(           child: FutureBuilder&lt;String>(             future: _calculation,             builder: (BuildContext context, AsyncSnapshot&lt;String> snapshot) {               List&lt;Widget> children;                if (snapshot.connectionState == ConnectionState.done) {                 if (snapshot.hasError) {                   children = &lt;Widget>[                     Icon(                       Icons.error_outline,                       color: Colors.red,                       size: 60,                     ),                     Padding(                       padding: const EdgeInsets.only(top: 16),                       child: Text('Error: ${snapshot.error}'),                     ),                   ];                 } else {                   children = &lt;Widget>[                     Icon(                       Icons.check_circle_outline,                       color: Colors.green,                       size: 60,                     ),                     Padding(                       padding: const EdgeInsets.only(top: 16),                       child: Text('Result: ${snapshot.data}'),                     ),                   ];                 }               } else {                 children = &lt;Widget>[                   SizedBox(                     child: CircularProgressIndicator(),                     width: 60,                     height: 60,                   ),                   const Padding(                     padding: EdgeInsets.only(top: 16),                     child: Text('Awaiting result...'),                   )                 ];               }                return Column(                 mainAxisAlignment: MainAxisAlignment.center,                 crossAxisAlignment: CrossAxisAlignment.center,                 children: children,               );             },           ),         ),       ),     );   } }<\/code><\/pre>\n<p>\u041f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u0435\u0436\u0434\u0443 \u044d\u043a\u0440\u0430\u043d\u0430\u043c\u0438 \u043e\u0431\u044b\u0447\u043d\u043e \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u044b \u0438 Navigator API:<\/p>\n<pre><code class=\"dart\">import 'package:flutter\/material.dart';  void main() => runApp(MyApp());  class MyApp extends StatelessWidget {   @override   Widget build(BuildContext context) {     return MaterialApp(       title: '\u041f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u0435\u0436\u0434\u0443 \u044d\u043a\u0440\u0430\u043d\u0430\u043c\u0438',       home: FirstScreen(),     );   } }  class FirstScreen extends StatelessWidget {   @override   Widget build(BuildContext context) {     return Scaffold(       appBar: AppBar(         title: Text('\u041f\u0435\u0440\u0432\u044b\u0439 \u044d\u043a\u0440\u0430\u043d'),       ),       body: Center(         child: ElevatedButton(           child: Text('\u041f\u0435\u0440\u0435\u0439\u0442\u0438 \u043a\u043e \u0432\u0442\u043e\u0440\u043e\u043c\u0443 \u044d\u043a\u0440\u0430\u043d\u0443'),           onPressed: () {             Navigator.push(               context,               MaterialPageRoute(                 builder: (context) => SecondScreen(data: '\u041f\u0440\u0438\u0432\u0435\u0442 \u043e\u0442 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u044d\u043a\u0440\u0430\u043d\u0430'),               ),             );           },         ),       ),     );   } }  class SecondScreen extends StatelessWidget {   final String data;    SecondScreen({Key key, @required this.data}) : super(key: key);    @override   Widget build(BuildContext context) {     return Scaffold(       appBar: AppBar(         title: Text('\u0412\u0442\u043e\u0440\u043e\u0439 \u044d\u043a\u0440\u0430\u043d'),       ),       body: Center(         child: Text(data),       ),     );   } }<\/code><\/pre>\n<hr\/>\n<p><em>\u041d\u0430\u043f\u043e\u043c\u043d\u044e, \u0447\u0442\u043e \u0432<\/em><a href=\"https:\/\/otus.pw\/xZcW\/\"><em>\u00a0\u0440\u0430\u043c\u043a\u0430\u0445 \u043e\u043d\u043b\u0430\u0439\u043d-\u043a\u0443\u0440\u0441\u043e\u0432 OTUS \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0437\u0443\u0447\u0438\u0442\u044c \u0441\u0430\u043c\u044b\u0435 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0435 \u042f\u041f<\/em><\/a><em>, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430<\/em><a href=\"https:\/\/otus.pw\/S52f\/\"><em>\u00a0\u0440\u044f\u0434 \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u044b\u0445 \u043c\u0435\u0440\u043e\u043f\u0440\u0438\u044f\u0442\u0438\u0439<\/em><\/a><em>.<\/em>  <\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/796585\/\"> https:\/\/habr.com\/ru\/articles\/796585\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><\/figure>\n<p><em>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440!<\/em><\/p>\n<p>\u0418\u0441\u0442\u043e\u0440\u0438\u044f <strong>Dart<\/strong><s>h\u00a0Vader<\/s> \u043d\u0430\u0447\u0430\u043b\u0430\u0441\u044c \u0432 2011 \u0433\u043e\u0434\u0443. \u0426\u0435\u043b\u044c\u044e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f Dart \u0431\u044b\u043b\u043e \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0438\u0442\u044c <strong>\u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u0443 JavaScript<\/strong>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u043b\u0430 \u0431\u044b \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0435, \u0432\u044b\u0441\u043e\u043a\u043e\u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0432\u0435\u0431-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043e\u0431\u043b\u0435\u0433\u0447\u0430\u044f \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438. <\/p>\n<p>\u0421\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c Dart \u043f\u0440\u0435\u0442\u0435\u0440\u043f\u0435\u043b \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0430\u043f\u0434\u0435\u0439\u0442\u043e\u0432, \u043d\u043e \u0435\u0433\u043e \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0440\u044b\u0432\u043e\u043a \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u0435\u043b \u0441 \u0437\u0430\u043f\u0443\u0441\u043a\u043e\u043c <strong>Flutter<\/strong> \u2014 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0445 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432 \u0434\u043b\u044f \u043c\u043e\u0431\u0438\u043b\u044c\u043d\u044b\u0445, \u0432\u0435\u0431- \u0438 \u043d\u0430\u0441\u0442\u043e\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0438\u0437 \u0435\u0434\u0438\u043d\u043e\u0439 \u043a\u043e\u0434\u043e\u0432\u043e\u0439 \u0431\u0430\u0437\u044b. <\/p>\n<p>\u042f\u0437\u044b\u043a \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 <strong>\u041e\u041e\u041f<\/strong> \u0441 \u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438 \u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435\u043c, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a \u0432\u044b\u0441\u0448\u0438\u0435 \u043f\u043e\u0440\u044f\u0434\u043a\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u0437\u0430\u043c\u044b\u043a\u0430\u043d\u0438\u044f \u0438 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0441\u0442\u044c \u0438 \u0442.\u043f.<\/p>\n<p>\u0421\u0438\u0441\u0442\u0435\u043c\u0430 \u0442\u0438\u043f\u043e\u0432 \u0432 Dart \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u043a\u0430\u043a <strong>\u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044e,<\/strong> \u0442\u0430\u043a \u0438 <strong>\u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044e \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f.<\/strong><\/p>\n<h3>\u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438<\/h3>\n<h4>\u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0438 \u0442\u0438\u043f\u044b \u0434\u0430\u043d\u043d\u044b\u0445<\/h4>\n<p><code>var<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0431\u0435\u0437 \u044f\u0432\u043d\u043e\u0433\u043e \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u0435\u0451 \u0442\u0438\u043f\u0430. Dart \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0442\u0438\u043f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043f\u0440\u0438\u0441\u0432\u043e\u0435\u043d\u043d\u043e\u0433\u043e \u0435\u0439 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f:<\/p>\n<pre><code class=\"dart\">var name = 'Dart'; \/\/ dart \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u0442, \u0447\u0442\u043e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f name \u0438\u043c\u0435\u0435\u0442 \u0442\u0438\u043f string var version = 2.12; \/\/ dart \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442, \u0447\u0442\u043e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f version` \u0438\u043c\u0435\u0435\u0442 \u0442\u0438\u043f double<\/code><\/pre>\n<p>\u0427\u0442\u043e \u043a\u0430\u0441\u0430\u0442\u0435\u043b\u044c\u043d\u043e <strong>\u043d\u0435\u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445<\/strong>, Dart \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u0438\u043c\u0435\u0435\u0442 \u0434\u0432\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438: <code>final<\/code> \u0438 <code>const<\/code>.<\/p>\n<ul>\n<li>\n<p><code>final<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <strong>\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b<\/strong> \u0438 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u043e \u043f\u043e\u0441\u043b\u0435 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043f\u0440\u0438\u0441\u0432\u043e\u0435\u043d\u0438\u044f.<\/p>\n<\/li>\n<li>\n<p><code>const<\/code> \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u043a \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 <strong>\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u0438 \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u043d\u044b\u043c<\/strong> \u043d\u0430 \u043f\u0440\u043e\u0442\u044f\u0436\u0435\u043d\u0438\u0438 \u0432\u0441\u0435\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f.<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"dart\">final userName = 'otus'; const double PI = 3.14;<\/code><\/pre>\n<p>Dart \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 <strong>\u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044e<\/strong>:<\/p>\n<pre><code class=\"dart\">String language = 'Dart'; int year = 2023; double version = 2.10; List&lt;String> developers = ['artem', 'ivan', 'igor']; Map&lt;String, dynamic> info = {   'name': 'Dart',   'created': 2008, };<\/code><\/pre>\n<p>Dart \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442<code>List<\/code>, <code>Set<\/code>, \u0438 <code>Map<\/code>:<\/p>\n<ul>\n<li>\n<p><strong>List<\/strong>: \u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0435\u043d\u043d\u0430\u044f \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043e\u0434\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430.<\/p>\n<\/li>\n<li>\n<p><strong>Set<\/strong>: \u043d\u0435\u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0435\u043d\u043d\u0430\u044f \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432.<\/p>\n<\/li>\n<li>\n<p><strong>Map<\/strong>: \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f \u043f\u0430\u0440 \u043a\u043b\u044e\u0447-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0433\u0434\u0435 \u043a\u0430\u0436\u0434\u044b\u0439 \u043a\u043b\u044e\u0447 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0435\u0442\u0441\u044f \u043d\u0435 \u0431\u043e\u043b\u0435\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u0430.<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"dart\">List&lt;int> primeNumbers = [2, 3, 5, 7, 11]; Set&lt;String> languages = {'Dart', 'Flutter', 'Java'}; Map&lt;String, String> headers = {   'Content-Type': 'application\/json',   'Authorization': 'Bearer your_token', };<\/code><\/pre>\n<h4>\u0424\u0443\u043d\u043a\u0446\u0438\u0438  <\/h4>\n<p>\u0418\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0432 \u0444\u0438\u0433\u0443\u0440\u043d\u044b\u0445 \u0441\u043a\u043e\u0431\u043a\u0430\u0445 <code>{}<\/code>:<\/p>\n<pre><code class=\"dart\">void printUserInfo({String name, int age}) {   print('Name: $name, Age: $age'); }  void main() {   \/\/ \u0432\u044b\u0437\u043e\u0432   printUserInfo(name: 'ivan', age: 30); }<\/code><\/pre>\n<p>Dart \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 <strong>\u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u043e\u0437\u0438\u0446\u0438\u043e\u043d\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b<\/strong> \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>[]<\/code>:<\/p>\n<pre><code class=\"dart\">void printMessage(String message, [String author = 'Anonymous']) {   print('$message \u2014 $author'); }  void printUserInfoOptional({String name = 'Unknown', int age}) {   print('Name: $name, Age: $age'); }  void main() {   \/\/ \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0441 \u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u043f\u043e\u0437\u0438\u0446\u0438\u043e\u043d\u043d\u044b\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c   printMessage('Hello, Dart!');   \/\/ \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0441 \u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c   printUserInfoOptional(age: 25); }<\/code><\/pre>\n<p><strong>\u0424\u0443\u043d\u043a\u0446\u0438\u0438 \u0432\u044b\u0441\u0448\u0435\u0433\u043e \u043f\u043e\u0440\u044f\u0434\u043a\u0430<\/strong> \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0442 \u0434\u0440\u0443\u0433\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0438\u043b\u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0442 \u0438\u0445:<\/p>\n<pre><code class=\"dart\">void operateOnNumbers(int a, int b, Function(int, int) operation) {   var result = operation(a, b);   print('Result: $result'); }  int sum(int x, int y) => x + y; int product(int x, int y) => x * y;  void main() {   \/\/ \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432\u044b\u0441\u0448\u0435\u0433\u043e \u043f\u043e\u0440\u044f\u0434\u043a\u0430   operateOnNumbers(3, 4, sum); \/\/ Result: 7   operateOnNumbers(3, 4, product); \/\/ Result: 12    \/\/ use \u0430\u043d\u043e\u043d\u0438\u043c\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438   operateOnNumbers(3, 4, (x, y) => x - y); \/\/ Result: -1 }<\/code><\/pre>\n<h4>\u041a\u043b\u0430\u0441\u0441\u044b \u0438 \u041e\u041e\u041f<\/h4>\n<p>\u0412 Dart \u043a\u043b\u0430\u0441\u0441\u044b \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0441\u043e\u0431\u043e\u0439 \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e \u0434\u043b\u044f \u0438\u043d\u043a\u0430\u043f\u0441\u0443\u043b\u044f\u0446\u0438\u0438 \u0438 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u0430:<\/p>\n<pre><code class=\"dart\">class Car {   String make;   String model;   int year;    \/\/ \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440   Car(this.make, this.model, this.year);    \/\/ \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440   Car.named({required this.make, required this.model, required this.year});    \/\/ \u043c\u0435\u0442\u043e\u0434 \u0434\u043b\u044f \u0432\u044b\u0432\u043e\u0434\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0430\u0432\u0442\u043e\u043c\u043e\u0431\u0438\u043b\u044f   void displayInfo() {     print('Make: $make, Model: $model, Year: $year');   } }  void main() {   var myCar = Car('Toyota', 'Corolla', 2020);   myCar.displayInfo();    var mySecondCar = Car.named(make: 'Ford', model: 'Mustang', year: 1969);   mySecondCar.displayInfo(); }<\/code><\/pre>\n<p><strong>\u041d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435<\/strong> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043a\u043b\u0430\u0441\u0441\u0443 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0438 \u043c\u0435\u0442\u043e\u0434\u044b \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430, \u044e\u0437\u0430\u0435\u0442\u0441\u044f \u0441\u043b\u043e\u0432\u043e <code>extends<\/code> \u0434\u043b\u044f \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f:<\/p>\n<pre><code class=\"dart\">class ElectricCar extends Car {   double batteryCapacity;    ElectricCar(String make, String model, int year, this.batteryCapacity)       : super(make, model, year);    @override   void displayInfo() {     super.displayInfo();     print('Battery Capacity: $batteryCapacity kWh');   } }  void main() {   var myElectricCar = ElectricCar('Tesla', 'Model Y', 2023, 85.0);   myElectricCar.displayInfo(); }<\/code><\/pre>\n<p><strong>\u0410\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0435 \u043a\u043b\u0430\u0441\u0441\u044b<\/strong> \u0432 Dart \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u043a\u0430\u043a \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u043a\u043b\u0430\u0441\u0441\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f \u0438\u043d\u0441\u0442\u0430\u043d\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e:<\/p>\n<pre><code class=\"dart\">abstract class Shape {   void draw(); \/\/ \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 }  class Circle extends Shape {   @override   void draw() {     print('Drawing circle...');   } }  class Square extends Shape {   @override   void draw() {     print('Drawing square...');   } }  void main() {   var circle = Circle();   circle.draw();    var square = Square();   square.draw(); }<\/code><\/pre>\n<p>\u0412 Dart <strong>\u043d\u0435\u0442 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0430<\/strong> \u0434\u043b\u044f \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f <strong>\u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432<\/strong>. \u041b\u044e\u0431\u043e\u0439 \u043a\u043b\u0430\u0441\u0441 \u043c\u043e\u0436\u0435\u0442 \u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u043a \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u0438 \u0434\u0440\u0443\u0433\u043e\u0439 \u043a\u043b\u0430\u0441\u0441 \u043c\u043e\u0436\u0435\u0442 \u0435\u0433\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0441 <code>implements<\/code>:<\/p>\n<pre><code class=\"dart\">class Vehicle {   void start() => print(\"Vehicle started\");   void stop() => print(\"Vehicle stopped\"); }  class Bike implements Vehicle {   @override   void start() => print(\"Bike started\");    @override   void stop() => print(\"Bike stopped\"); }  void main() {   var bike = Bike();   bike.start();   bike.stop(); }<\/code><\/pre>\n<h4>\u0423\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0435 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438  <\/h4>\n<p>\u0417\u0434\u0435\u0441\u044c \u0432\u0441\u0435 \u0438\u043d\u0442\u0443\u0438\u0442\u0438\u0432\u043d\u043e.<\/p>\n<p><strong>\u0423\u0441\u043b\u043e\u0432\u043d\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u044b<\/strong> <code>if-else<\/code> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u0431\u043b\u043e\u043a \u043a\u043e\u0434\u0430 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0442\u043e\u0433\u043e, \u0438\u0441\u0442\u0438\u043d\u043d\u043e \u043b\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u0435:<\/p>\n<pre><code class=\"dart\">int number = 10; if (number % 2 == 0) {   print('$number is even'); } else {   print('$number is odd'); }<\/code><\/pre>\n<p><strong>\u0426\u0438\u043a\u043b\u044b<\/strong> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0431\u043b\u043e\u043a\u0430 \u043a\u043e\u0434\u0430, \u043f\u043e\u043a\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u0435:<\/p>\n<pre><code class=\"dart\">for (int i = 0; i &lt; 5; i++) {   print('i = $i'); }<\/code><\/pre>\n<p><strong>while<\/strong> \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0431\u043b\u043e\u043a \u043a\u043e\u0434\u0430, \u043f\u043e\u043a\u0430 \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u0438\u0441\u0442\u0438\u043d\u043d\u043e:<\/p>\n<pre><code class=\"dart\">int num = 5; while (num > 0) {   print('num = $num');   num--; }<\/code><\/pre>\n<p><strong>do-while<\/strong>: \u043f\u043e\u0445\u043e\u0436 \u043d\u0430 <code>while<\/code>, \u043d\u043e \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442, \u0447\u0442\u043e \u0442\u0435\u043b\u043e \u0446\u0438\u043a\u043b\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u0441\u044f \u0445\u043e\u0442\u044f \u0431\u044b \u043e\u0434\u0438\u043d \u0440\u0430\u0437:<\/p>\n<pre><code class=\"dart\">int count = 0; do {   print('count = $count');   count++; } while (count &lt; 5);<\/code><\/pre>\n<p><code>switch-case<\/code> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0431\u043b\u043e\u043a\u0438 \u043a\u043e\u0434\u0430 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439:<\/p>\n<pre><code class=\"dart\">String grade = 'B'; switch (grade) {   case 'A':     print('Excellent');     break;   case 'B':     print('Good');     break;   case 'C':     print('Fair');     break;   case 'D':   case 'F':     print('Poor');     break;   default:     print('Invalid grade'); }<\/code><\/pre>\n<p>\u041c\u043e\u0436\u043d\u043e \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>throw<\/code> \u0438 \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0438\u0445 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>try-catch<\/code>:<\/p>\n<pre><code class=\"dart\">void checkAge(int age) {   if (age &lt; 18) {     throw Exception('Not eligible for voting');   } else {     print('Eligible for voting');   } }  try {   checkAge(16); } catch (e) {   print('Caught an exception: $e'); } finally {   print('This is always executed'); }<\/code><\/pre>\n<h4>null safety<\/h4>\n<p>\u0412 Dart \u0441 \u0432\u043a\u043b\u044e\u0447\u0451\u043d\u043d\u044b\u043c null safety \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043d\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c null:<\/p>\n<pre><code class=\"dart\">int a = null; \/\/ err<\/code><\/pre>\n<p>\u0427\u0442\u043e\u0431\u044b \u043e\u0431\u044a\u044f\u0432\u0438\u0442\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c null, \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0437\u043d\u0430\u043a \u0432\u043e\u043f\u0440\u043e\u0441\u0430 \u043f\u043e\u0441\u043b\u0435 \u0442\u0438\u043f\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439:<\/p>\n<pre><code class=\"dart\">int? a = null; \/\/ \u041e\u041a<\/code><\/pre>\n<p>\u041a\u043e\u0433\u0434\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c null, Dart \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043e\u0442 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u044d\u0442\u0443 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c, \u043a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0451 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435:<\/p>\n<pre><code class=\"dart\">int? a;  if (a != null) {   print(a + 2); \/\/ \u041e\u041a, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043c\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043b\u0438, \u0447\u0442\u043e a \u043d\u0435 null }<\/code><\/pre>\n<p>\u041e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 <code>!<\/code> \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0443: &#171;\u042f \u0443\u0432\u0435\u0440\u0435\u043d, \u0447\u0442\u043e \u044d\u0442\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u043d\u0435 null&#187;. \u0415\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u044e\u0437\u0430\u0442\u044c \u0441 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043e\u0441\u0442\u043e\u0440\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e:<\/p>\n<pre><code class=\"dart\">int? a = null; print(a! + 2); \/\/ \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f<\/code><\/pre>\n<p>\u041e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u044b <code>??=<\/code> \u0438 <code>??<\/code> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c null, \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u044f \u0438\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e.<\/p>\n<ul>\n<li>\n<p><code>??=<\/code> \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439, \u0435\u0441\u043b\u0438 \u043e\u043d\u0430 null.<\/p>\n<\/li>\n<li>\n<p><code>??<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u043f\u0440\u0430\u0432\u0430 \u043e\u0442 \u0441\u0435\u0431\u044f, \u0435\u0441\u043b\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u043b\u0435\u0432\u0430 \u043e\u0442 \u043d\u0435\u0433\u043e \u2014 null.<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"dart\">int? a; a ??= 10; \/\/ a \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0432\u043d\u043e 10, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0434\u043e \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u043d\u0438\u044f a \u0431\u044b\u043b\u043e null print(a); \/\/  10  int? b = null; print(b ?? 20); \/\/ 20, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e b \u0440\u0430\u0432\u043d\u043e null<\/code><\/pre>\n<h4>Dart \u0441 Flutter<\/h4>\n<p>\u0412 Flutter \u0435\u0441\u0442\u044c \u0434\u0432\u0430 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u0442\u0438\u043f\u0430 \u0432\u0438\u0434\u0436\u0435\u0442\u043e\u0432: <code>StatefulWidget<\/code> \u0438 <code>StatelessWidget<\/code>. <code>StatelessWidget<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0432\u0438\u0434\u0436\u0435\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u044f\u044e\u0442 \u0441\u0432\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f, \u0430 <code>StatefulWidget<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0432\u0438\u0434\u0436\u0435\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u0441\u0432\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0432 \u043e\u0442\u0432\u0435\u0442 \u043d\u0430 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438\u043b\u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0444\u0430\u043a\u0442\u043e\u0440\u044b<\/p>\n<p><strong>StatelessWidget:<\/strong><\/p>\n<pre><code class=\"dart\">import 'package:flutter\/material.dart';  void main() => runApp(MyApp());  class MyApp extends StatelessWidget {   @override   Widget build(BuildContext context) {     return MaterialApp(       home: Scaffold(         appBar: AppBar(           title: Text('\u041f\u0440\u0438\u043c\u0435\u0440 StatelessWidget'),         ),         body: Center(           child: Text('\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440!'),         ),       ),     );   } }<\/code><\/pre>\n<p><strong>StatefulWidget:<\/strong><\/p>\n<pre><code class=\"dart\">import 'package:flutter\/material.dart';  void main() => runApp(MyApp());  class MyApp extends StatefulWidget {   @override   _MyAppState createState() => _MyAppState(); }  class _MyAppState extends State&lt;MyApp> {   int _counter = 0;    void _incrementCounter() {     setState(() {       _counter++;     });   }    @override   Widget build(BuildContext context) {     return MaterialApp(       home: Scaffold(         appBar: AppBar(           title: Text('\u041f\u0440\u0438\u043c\u0435\u0440 StatefulWidget'),         ),         body: Center(           child: Column(             mainAxisAlignment: MainAxisAlignment.center,             children: &lt;Widget>[               Text('\u0412\u044b \u043d\u0430\u0436\u0430\u043b\u0438 \u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0443 \u0441\u0442\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437:'),               Text('$_counter', style: Theme.of(context).textTheme.headline4),             ],           ),         ),         floatingActionButton: FloatingActionButton(           onPressed: _incrementCounter,           tooltip: 'Increment',           child: Icon(Icons.add),         ),       ),     );   } }<\/code><\/pre>\n<p>Flutter \u043e\u0431\u043b\u0435\u0433\u0447\u0430\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u043c\u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f\u043c\u0438 \u0447\u0435\u0440\u0435\u0437 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 <code>FutureBuilder<\/code>:<\/p>\n<pre><code class=\"dart\">import 'package:flutter\/material.dart'; import 'dart:async';  void main() => runApp(MyApp());  class MyApp extends StatelessWidget {   final Future&lt;String> _calculation = Future&lt;String>.delayed(     Duration(seconds: 2),     () => '\u0414\u0430\u043d\u043d\u044b\u0435 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u044b',   );    @override   Widget build(BuildContext context) {     return MaterialApp(<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-369369","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/369369","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=369369"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/369369\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=369369"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=369369"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=369369"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}