Yaohong

为了真相不惜被羞辱

The Flutter Plugin Project Files

The Flutter Plugin Project Files

Creating the plugin project

$ flutter create --org com.example --template=plugin --platforms=android,ios,linux,macos,windows hello_plugin 

Signing iOS app for device deployment using developer identity: "Apple
Development: Yaohong Huang (WS3UUERGF9)"
Creating project hello_plugin...
Resolving dependencies in hello_plugin... (3.3s)
Got dependencies in hello_plugin.
Resolving dependencies in hello_plugin/example... (1.1s)
Got dependencies in hello_plugin/example.
Wrote 161 files.

All done!

Your plugin code is in hello_plugin/lib/hello_plugin.dart.

Your example app code is in hello_plugin/example/lib/main.dart.


Host platform code is in the android, ios, linux, macos, windows directories
under hello_plugin.
To edit platform code in an IDE see
https://flutter.dev/developing-packages/#edit-plugin-package.


To add platforms, run `flutter create -t plugin --platforms <platforms> .` under
hello_plugin.
For more information, see https://flutter.dev/go/plugin-platforms.
hello_plugin
├── CHANGELOG.md
├── LICENSE
├── README.md
├── analysis_options.yaml
├── android
│   ├── build.gradle
│   ├── hello_plugin_android.iml
│   ├── local.properties
│   ├── settings.gradle
│   └── src
│       ├── main
│       └── test
├── example
│   ├── README.md
│   ├── analysis_options.yaml
│   ├── android
│   │   ├── app
│   │   ├── build.gradle
│   │   ├── gradle
│   │   ├── gradle.properties
│   │   ├── gradlew
│   │   ├── gradlew.bat
│   │   ├── hello_plugin_example_android.iml
│   │   ├── local.properties
│   │   └── settings.gradle
│   ├── build
│   │   ├── 52f352800ae67b257006addf8ca3668f
│   │   ├── e29aedf18e567df5728f6b7ce57d2e97.cache.dill.track.dill
│   │   ├── ios
│   │   └── last_build_run.json
│   ├── hello_plugin_example.iml
│   ├── integration_test
│   │   └── plugin_integration_test.dart
│   ├── ios
│   │   ├── Flutter
│   │   ├── Podfile
│   │   ├── Podfile.lock
│   │   ├── Pods
│   │   ├── Runner
│   │   ├── Runner.xcodeproj
│   │   ├── Runner.xcworkspace
│   │   └── RunnerTests
│   ├── lib
│   │   └── main.dart
│   ├── linux
│   │   ├── CMakeLists.txt
│   │   ├── flutter
│   │   ├── main.cc
│   │   ├── my_application.cc
│   │   └── my_application.h
│   ├── macos
│   │   ├── Flutter
│   │   ├── Podfile
│   │   ├── Runner
│   │   ├── Runner.xcodeproj
│   │   ├── Runner.xcworkspace
│   │   └── RunnerTests
│   ├── pubspec.lock
│   ├── pubspec.yaml
│   ├── test
│   │   └── widget_test.dart
│   └── windows
│       ├── CMakeLists.txt
│       ├── flutter
│       └── runner
├── hello_plugin.iml
├── ios
│   ├── Assets
│   ├── Classes
│   │   └── HelloPlugin.swift
│   └── hello_plugin.podspec
├── lib
│   ├── hello_plugin.dart
│   ├── hello_plugin_method_channel.dart
│   └── hello_plugin_platform_interface.dart
├── linux
│   ├── CMakeLists.txt
│   ├── hello_plugin.cc
│   ├── hello_plugin_private.h
│   ├── include
│   │   └── hello_plugin
│   └── test
│       └── hello_plugin_test.cc
├── macos
│   ├── Classes
│   │   └── HelloPlugin.swift
│   └── hello_plugin.podspec
├── pubspec.lock
├── pubspec.yaml
├── test
│   ├── hello_plugin_method_channel_test.dart
│   └── hello_plugin_test.dart
└── windows
    ├── CMakeLists.txt
    ├── hello_plugin.cpp
    ├── hello_plugin.h
    ├── hello_plugin_c_api.cpp
    ├── include
    │   └── hello_plugin
    └── test
        └── hello_plugin_test.cpp
name: hello_plugin
description: A new Flutter plugin project.
version: 0.0.1
homepage:

environment:
  sdk: '>=3.0.5 <4.0.0'
  flutter: ">=3.3.0"

dependencies:
  flutter:
    sdk: flutter
  plugin_platform_interface: ^2.0.2

dev_dependencies:
  flutter_test:
    sdk: flutter
  flutter_lints: ^2.0.0

# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec

# The following section is specific to Flutter packages.
flutter:
  # This section identifies this Flutter project as a plugin project.
  # The 'pluginClass' specifies the class (in Java, Kotlin, Swift, Objective-C, etc.)
  # which should be registered in the plugin registry. This is required for
  # using method channels.
  # The Android 'package' specifies package in which the registered class is.
  # This is required for using method channels on Android.
  # The 'ffiPlugin' specifies that native code should be built and bundled.
  # This is required for using `dart:ffi`.
  # All these are used by the tooling to maintain consistency when
  # adding or updating assets for this project.
  plugin:
    platforms:
      android:
        package: com.example.hello_plugin
        pluginClass: HelloPlugin
      ios:
        pluginClass: HelloPlugin
      linux:
        pluginClass: HelloPlugin
      macos:
        pluginClass: HelloPlugin
      windows:
        pluginClass: HelloPluginCApi

The project files generated by 'flutter create --template=plugin_ffi' using dart:ffi to call C APIs

The project files generated by ‘flutter create –template=plugin_ffi’ using dart:ffi to call C APIs

Flutter mobile and desktop apps can use the dart:ffi library to call native C APIs.

Here are the project files generated by executing the following command:

flutter create --platforms=android,ios,macos,windows,linux --template=plugin_ffi native_add

flutter version: flutter_macos_3.10.5-stable

Reference:

Notes:

1.The FFI library can only bind against C symbols, so in C++ these symbols are marked extern “C”.


The method with the same name from the last mixin will override the previous ones in dart

The method with the same name from the last mixin will override the previous ones in dart

TestMixin file:

class MyObject{
    init(){
        print("draw object");
    }
}

mixin Circle{
    
    init(){
        print("draw circle");
    }
}


mixin Square{
    init(){
        print("draw Square");
    }
}

class MyShape extends MyObject with Circle, Square{
    init() {
        super.init();
        print("draw MyShape");
    }
}


void main() {
    MyShape shape = MyShape();
    shape.init();
}

//Output:

draw Square
draw MyShape