<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Dart on Yaohong</title><link>https://yh.timefriend.vip/tags/dart/</link><description>Recent content in Dart on Yaohong</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Fri, 24 May 2024 09:17:20 +0800</lastBuildDate><atom:link href="https://yh.timefriend.vip/tags/dart/index.xml" rel="self" type="application/rss+xml"/><item><title>The Flutter Plugin Project Files</title><link>https://yh.timefriend.vip/post/flutter/theflutterpluginprojectfiles/</link><pubDate>Fri, 24 May 2024 09:17:20 +0800</pubDate><guid>https://yh.timefriend.vip/post/flutter/theflutterpluginprojectfiles/</guid><description>&lt;h1 id="the-flutter-plugin-project-files"&gt;The Flutter Plugin Project Files&lt;/h1&gt;&#10;&lt;p&gt;Creating the plugin project&lt;/p&gt;&#10;&lt;pre tabindex="0"&gt;&lt;code&gt;$ flutter create --org com.example --template=plugin --platforms=android,ios,linux,macos,windows hello_plugin &#10;&#10;Signing iOS app for device deployment using developer identity: &amp;#34;Apple&#10;Development: Yaohong Huang (WS3UUERGF9)&amp;#34;&#10;Creating project hello_plugin...&#10;Resolving dependencies in hello_plugin... (3.3s)&#10;Got dependencies in hello_plugin.&#10;Resolving dependencies in hello_plugin/example... (1.1s)&#10;Got dependencies in hello_plugin/example.&#10;Wrote 161 files.&#10;&#10;All done!&#10;&#10;Your plugin code is in hello_plugin/lib/hello_plugin.dart.&#10;&#10;Your example app code is in hello_plugin/example/lib/main.dart.&#10;&#10;&#10;Host platform code is in the android, ios, linux, macos, windows directories&#10;under hello_plugin.&#10;To edit platform code in an IDE see&#10;https://flutter.dev/developing-packages/#edit-plugin-package.&#10;&#10;&#10;To add platforms, run `flutter create -t plugin --platforms &amp;lt;platforms&amp;gt; .` under&#10;hello_plugin.&#10;For more information, see https://flutter.dev/go/plugin-platforms.&#10;&lt;/code&gt;&lt;/pre&gt;&lt;pre tabindex="0"&gt;&lt;code&gt;hello_plugin&#10;├── CHANGELOG.md&#10;├── LICENSE&#10;├── README.md&#10;├── analysis_options.yaml&#10;├── android&#10;│   ├── build.gradle&#10;│   ├── hello_plugin_android.iml&#10;│   ├── local.properties&#10;│   ├── settings.gradle&#10;│   └── src&#10;│   ├── main&#10;│   └── test&#10;├── example&#10;│   ├── README.md&#10;│   ├── analysis_options.yaml&#10;│   ├── android&#10;│   │   ├── app&#10;│   │   ├── build.gradle&#10;│   │   ├── gradle&#10;│   │   ├── gradle.properties&#10;│   │   ├── gradlew&#10;│   │   ├── gradlew.bat&#10;│   │   ├── hello_plugin_example_android.iml&#10;│   │   ├── local.properties&#10;│   │   └── settings.gradle&#10;│   ├── build&#10;│   │   ├── 52f352800ae67b257006addf8ca3668f&#10;│   │   ├── e29aedf18e567df5728f6b7ce57d2e97.cache.dill.track.dill&#10;│   │   ├── ios&#10;│   │   └── last_build_run.json&#10;│   ├── hello_plugin_example.iml&#10;│   ├── integration_test&#10;│   │   └── plugin_integration_test.dart&#10;│   ├── ios&#10;│   │   ├── Flutter&#10;│   │   ├── Podfile&#10;│   │   ├── Podfile.lock&#10;│   │   ├── Pods&#10;│   │   ├── Runner&#10;│   │   ├── Runner.xcodeproj&#10;│   │   ├── Runner.xcworkspace&#10;│   │   └── RunnerTests&#10;│   ├── lib&#10;│   │   └── main.dart&#10;│   ├── linux&#10;│   │   ├── CMakeLists.txt&#10;│   │   ├── flutter&#10;│   │   ├── main.cc&#10;│   │   ├── my_application.cc&#10;│   │   └── my_application.h&#10;│   ├── macos&#10;│   │   ├── Flutter&#10;│   │   ├── Podfile&#10;│   │   ├── Runner&#10;│   │   ├── Runner.xcodeproj&#10;│   │   ├── Runner.xcworkspace&#10;│   │   └── RunnerTests&#10;│   ├── pubspec.lock&#10;│   ├── pubspec.yaml&#10;│   ├── test&#10;│   │   └── widget_test.dart&#10;│   └── windows&#10;│   ├── CMakeLists.txt&#10;│   ├── flutter&#10;│   └── runner&#10;├── hello_plugin.iml&#10;├── ios&#10;│   ├── Assets&#10;│   ├── Classes&#10;│   │   └── HelloPlugin.swift&#10;│   └── hello_plugin.podspec&#10;├── lib&#10;│   ├── hello_plugin.dart&#10;│   ├── hello_plugin_method_channel.dart&#10;│   └── hello_plugin_platform_interface.dart&#10;├── linux&#10;│   ├── CMakeLists.txt&#10;│   ├── hello_plugin.cc&#10;│   ├── hello_plugin_private.h&#10;│   ├── include&#10;│   │   └── hello_plugin&#10;│   └── test&#10;│   └── hello_plugin_test.cc&#10;├── macos&#10;│   ├── Classes&#10;│   │   └── HelloPlugin.swift&#10;│   └── hello_plugin.podspec&#10;├── pubspec.lock&#10;├── pubspec.yaml&#10;├── test&#10;│   ├── hello_plugin_method_channel_test.dart&#10;│   └── hello_plugin_test.dart&#10;└── windows&#10; ├── CMakeLists.txt&#10; ├── hello_plugin.cpp&#10; ├── hello_plugin.h&#10; ├── hello_plugin_c_api.cpp&#10; ├── include&#10; │   └── hello_plugin&#10; └── test&#10; └── hello_plugin_test.cpp&#10;&lt;/code&gt;&lt;/pre&gt;&lt;pre tabindex="0"&gt;&lt;code&gt;name: hello_plugin&#10;description: A new Flutter plugin project.&#10;version: 0.0.1&#10;homepage:&#10;&#10;environment:&#10; sdk: &amp;#39;&amp;gt;=3.0.5 &amp;lt;4.0.0&amp;#39;&#10; flutter: &amp;#34;&amp;gt;=3.3.0&amp;#34;&#10;&#10;dependencies:&#10; flutter:&#10; sdk: flutter&#10; plugin_platform_interface: ^2.0.2&#10;&#10;dev_dependencies:&#10; flutter_test:&#10; sdk: flutter&#10; flutter_lints: ^2.0.0&#10;&#10;# For information on the generic Dart part of this file, see the&#10;# following page: https://dart.dev/tools/pub/pubspec&#10;&#10;# The following section is specific to Flutter packages.&#10;flutter:&#10; # This section identifies this Flutter project as a plugin project.&#10; # The &amp;#39;pluginClass&amp;#39; specifies the class (in Java, Kotlin, Swift, Objective-C, etc.)&#10; # which should be registered in the plugin registry. This is required for&#10; # using method channels.&#10; # The Android &amp;#39;package&amp;#39; specifies package in which the registered class is.&#10; # This is required for using method channels on Android.&#10; # The &amp;#39;ffiPlugin&amp;#39; specifies that native code should be built and bundled.&#10; # This is required for using `dart:ffi`.&#10; # All these are used by the tooling to maintain consistency when&#10; # adding or updating assets for this project.&#10; plugin:&#10; platforms:&#10; android:&#10; package: com.example.hello_plugin&#10; pluginClass: HelloPlugin&#10; ios:&#10; pluginClass: HelloPlugin&#10; linux:&#10; pluginClass: HelloPlugin&#10; macos:&#10; pluginClass: HelloPlugin&#10; windows:&#10; pluginClass: HelloPluginCApi&#10;&lt;/code&gt;&lt;/pre&gt;</description></item><item><title>The project files generated by 'flutter create --template=plugin_ffi' using dart:ffi to call C APIs</title><link>https://yh.timefriend.vip/post/flutter/theprojectfilesflutterpluginffidartfficapis/</link><pubDate>Thu, 23 May 2024 20:17:20 +0800</pubDate><guid>https://yh.timefriend.vip/post/flutter/theprojectfilesflutterpluginffidartfficapis/</guid><description>&lt;h1 id="the-project-files-generated-by-flutter-create-templateplugin_ffi-using-dartffi-to-call-c-apis"&gt;The project files generated by &amp;lsquo;flutter create &amp;ndash;template=plugin_ffi&amp;rsquo; using dart:ffi to call C APIs&lt;/h1&gt;&#10;&lt;p&gt;Flutter mobile and desktop apps can use the &lt;code&gt;dart:ffi&lt;/code&gt; library to call native C APIs.&lt;/p&gt;&#10;&lt;p&gt;Here are the project files generated by executing the following command:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#282a36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;flutter create --platforms&lt;span style="color:#ff79c6"&gt;=&lt;/span&gt;android,ios,macos,windows,linux --template&lt;span style="color:#ff79c6"&gt;=&lt;/span&gt;plugin_ffi native_add&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;flutter version: flutter_macos_3.10.5-stable&lt;/p&gt;&#10;&lt;p&gt;Reference:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;1.&lt;a href="https://docs.flutter.dev/platform-integration/android/c-interop"&gt;Binding to native Android code using dart:ffi&lt;/a&gt;&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;2.&lt;a href="https://docs.flutter.dev/platform-integration/ios/c-interop"&gt;Binding to native iOS code using dart:ffi&lt;/a&gt;&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;Notes:&lt;/p&gt;&#10;&lt;p&gt;1.The FFI library can only bind against C symbols, so in C++ these symbols are marked extern &amp;ldquo;C&amp;rdquo;.&lt;/p&gt;</description></item><item><title>The method with the same name from the last mixin will override the previous ones in dart</title><link>https://yh.timefriend.vip/post/flutter/mixinmethodoverride/</link><pubDate>Mon, 20 May 2024 18:17:20 +0800</pubDate><guid>https://yh.timefriend.vip/post/flutter/mixinmethodoverride/</guid><description>&lt;h1 id="the-method-with-the-same-name-from-the-last-mixin-will-override-the-previous-ones-in-dart"&gt;The method with the same name from the last mixin will override the previous ones in dart&lt;/h1&gt;&#10;&lt;p&gt;TestMixin file:&lt;/p&gt;&#10;&lt;pre tabindex="0"&gt;&lt;code&gt;class MyObject{&#10; init(){&#10; print(&amp;#34;draw object&amp;#34;);&#10; }&#10;}&#10;&#10;mixin Circle{&#10; &#10; init(){&#10; print(&amp;#34;draw circle&amp;#34;);&#10; }&#10;}&#10;&#10;&#10;mixin Square{&#10; init(){&#10; print(&amp;#34;draw Square&amp;#34;);&#10; }&#10;}&#10;&#10;class MyShape extends MyObject with Circle, Square{&#10; init() {&#10; super.init();&#10; print(&amp;#34;draw MyShape&amp;#34;);&#10; }&#10;}&#10;&#10;&#10;void main() {&#10; MyShape shape = MyShape();&#10; shape.init();&#10;}&#10;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;//Output:&lt;/p&gt;&#10;&lt;pre tabindex="0"&gt;&lt;code&gt;draw Square&#10;draw MyShape&#10;&lt;/code&gt;&lt;/pre&gt;</description></item></channel></rss>