diff --git a/packages/flutter_tools/templates/package_ffi/README.md.tmpl b/packages/flutter_tools/templates/package_ffi/README.md.tmpl index 05b96b01d68da..485a428ea43b1 100644 --- a/packages/flutter_tools/templates/package_ffi/README.md.tmpl +++ b/packages/flutter_tools/templates/package_ffi/README.md.tmpl @@ -31,7 +31,7 @@ Bundling is done by Flutter based on the output from `build.dart`. To use the native code, bindings in Dart are needed. To avoid writing these by hand, they are generated from the header file (`src/{{projectName}}.h`) by `package:ffigen`. -Regenerate the bindings by running `flutter pub run ffigen --config ffigen.yaml`. +Regenerate the bindings by running `dart run ffigen --config ffigen.yaml`. ## Invoking native code diff --git a/packages/flutter_tools/templates/package_ffi/ffigen.yaml.tmpl b/packages/flutter_tools/templates/package_ffi/ffigen.yaml.tmpl index c33bb9f92cdaa..1686f0a9a43a6 100644 --- a/packages/flutter_tools/templates/package_ffi/ffigen.yaml.tmpl +++ b/packages/flutter_tools/templates/package_ffi/ffigen.yaml.tmpl @@ -1,9 +1,9 @@ -# Run with `flutter pub run ffigen --config ffigen.yaml`. +# Run with `dart run ffigen --config ffigen.yaml`. name: {{pluginDartClass}}Bindings description: | Bindings for `src/{{projectName}}.h`. - Regenerate bindings with `flutter pub run ffigen --config ffigen.yaml`. + Regenerate bindings with `dart run ffigen --config ffigen.yaml`. output: 'lib/{{projectName}}_bindings_generated.dart' headers: entry-points: diff --git a/packages/flutter_tools/templates/plugin_ffi/README.md.tmpl b/packages/flutter_tools/templates/plugin_ffi/README.md.tmpl index 43378e7a94c8b..3d3efc0987a52 100644 --- a/packages/flutter_tools/templates/plugin_ffi/README.md.tmpl +++ b/packages/flutter_tools/templates/plugin_ffi/README.md.tmpl @@ -73,7 +73,7 @@ The native build systems that are invoked by FFI (and method channel) plugins ar To use the native code, bindings in Dart are needed. To avoid writing these by hand, they are generated from the header file (`src/{{projectName}}.h`) by `package:ffigen`. -Regenerate the bindings by running `flutter pub run ffigen --config ffigen.yaml`. +Regenerate the bindings by running `dart run ffigen --config ffigen.yaml`. ## Invoking native code diff --git a/packages/flutter_tools/templates/plugin_ffi/ffigen.yaml.tmpl b/packages/flutter_tools/templates/plugin_ffi/ffigen.yaml.tmpl index 65aa00e6921c2..5762da10e4aa8 100644 --- a/packages/flutter_tools/templates/plugin_ffi/ffigen.yaml.tmpl +++ b/packages/flutter_tools/templates/plugin_ffi/ffigen.yaml.tmpl @@ -1,9 +1,9 @@ -# Run with `flutter pub run ffigen --config ffigen.yaml`. +# Run with `dart run ffigen --config ffigen.yaml`. name: {{pluginDartClass}}Bindings description: | Bindings for `src/{{projectName}}.h`. - Regenerate bindings with `flutter pub run ffigen --config ffigen.yaml`. + Regenerate bindings with `dart run ffigen --config ffigen.yaml`. output: 'lib/{{projectName}}_bindings_generated.dart' headers: entry-points: diff --git a/packages/flutter_tools/templates/plugin_ffi/lib/projectName_bindings_generated.dart.tmpl b/packages/flutter_tools/templates/plugin_ffi/lib/projectName_bindings_generated.dart.tmpl index 11b9f06a22854..34b0773ca6614 100644 --- a/packages/flutter_tools/templates/plugin_ffi/lib/projectName_bindings_generated.dart.tmpl +++ b/packages/flutter_tools/templates/plugin_ffi/lib/projectName_bindings_generated.dart.tmpl @@ -10,7 +10,7 @@ import 'dart:ffi' as ffi; /// Bindings for `src/{{projectName}}.h`. /// -/// Regenerate bindings with `flutter pub run ffigen --config ffigen.yaml`. +/// Regenerate bindings with `dart run ffigen --config ffigen.yaml`. /// class {{pluginDartClass}}Bindings { /// Holds the symbol lookup function. @@ -43,7 +43,7 @@ class {{pluginDartClass}}Bindings { } late final _sumPtr = - _lookup>( + _lookup>( 'sum'); late final _sum = _sumPtr.asFunction(); @@ -63,7 +63,7 @@ class {{pluginDartClass}}Bindings { } late final _sum_long_runningPtr = - _lookup>( + _lookup>( 'sum_long_running'); late final _sum_long_running = _sum_long_runningPtr.asFunction(); diff --git a/packages/flutter_tools/templates/plugin_ffi/src.tmpl/projectName.c.tmpl b/packages/flutter_tools/templates/plugin_ffi/src.tmpl/projectName.c.tmpl index a4bb788df989b..3e559d1d885b1 100644 --- a/packages/flutter_tools/templates/plugin_ffi/src.tmpl/projectName.c.tmpl +++ b/packages/flutter_tools/templates/plugin_ffi/src.tmpl/projectName.c.tmpl @@ -5,14 +5,14 @@ // For very short-lived functions, it is fine to call them on the main isolate. // They will block the Dart execution while running the native function, so // only do this for native functions which are guaranteed to be short-lived. -FFI_PLUGIN_EXPORT intptr_t sum(intptr_t a, intptr_t b) { return a + b; } +FFI_PLUGIN_EXPORT int sum(int a, int b) { return a + b; } // A longer-lived native function, which occupies the thread calling it. // // Do not call these kind of native functions in the main isolate. They will // block Dart execution. This will cause dropped frames in Flutter applications. // Instead, call these native functions on a separate isolate. -FFI_PLUGIN_EXPORT intptr_t sum_long_running(intptr_t a, intptr_t b) { +FFI_PLUGIN_EXPORT int sum_long_running(int a, int b) { // Simulate work. #if _WIN32 Sleep(5000); diff --git a/packages/flutter_tools/templates/plugin_ffi/src.tmpl/projectName.h.tmpl b/packages/flutter_tools/templates/plugin_ffi/src.tmpl/projectName.h.tmpl index 084c64228f465..79444598be7ad 100644 --- a/packages/flutter_tools/templates/plugin_ffi/src.tmpl/projectName.h.tmpl +++ b/packages/flutter_tools/templates/plugin_ffi/src.tmpl/projectName.h.tmpl @@ -20,11 +20,11 @@ // For very short-lived functions, it is fine to call them on the main isolate. // They will block the Dart execution while running the native function, so // only do this for native functions which are guaranteed to be short-lived. -FFI_PLUGIN_EXPORT intptr_t sum(intptr_t a, intptr_t b); +FFI_PLUGIN_EXPORT int sum(int a, int b); // A longer lived native function, which occupies the thread calling it. // // Do not call these kind of native functions in the main isolate. They will // block Dart execution. This will cause dropped frames in Flutter applications. // Instead, call these native functions on a separate isolate. -FFI_PLUGIN_EXPORT intptr_t sum_long_running(intptr_t a, intptr_t b); +FFI_PLUGIN_EXPORT int sum_long_running(int a, int b);