Skip to content

Commit

Permalink
[Next stable] Update documentation for new location of linux source (#…
Browse files Browse the repository at this point in the history
…11182)

The Linux directory was changed in
flutter/flutter#153812.

Land once
flutter/flutter@8925e1f
is in stable.
  • Loading branch information
robert-ancell authored Dec 12, 2024
1 parent 83517f0 commit 58c0c93
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/content/platform-integration/platform-channels.md
Original file line number Diff line number Diff line change
Expand Up @@ -1014,19 +1014,19 @@ of your choice. The instructions below are for Visual Studio Code with the
1. Choose **Yes** in the prompt asking: `Would you like to configure project "linux"?`.
This enables C++ autocomplete.

1. Open the file `my_application.cc`.
1. Open the file `runner/my_application.cc`.

First, add the necessary includes to the top of the file, just
after `#include <flutter_linux/flutter_linux.h>`:

```c title="my_application.cc"
```c title="runner/my_application.cc"
#include <math.h>
#include <upower.h>
```

Add an `FlMethodChannel` to the `_MyApplication` struct:

```c title="my_application.cc"
```c title="runnner/my_application.cc"
struct _MyApplication {
GtkApplication parent_instance;
char** dart_entrypoint_arguments;
Expand All @@ -1036,7 +1036,7 @@ struct _MyApplication {

Make sure to clean it up in `my_application_dispose`:

```c title="my_application.cc"
```c title="runner/my_application.cc"
static void my_application_dispose(GObject* object) {
MyApplication* self = MY_APPLICATION(object);
g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev);
Expand All @@ -1050,7 +1050,7 @@ Edit the `my_application_activate` method and initialize
`samples.flutter.dev/battery`, just after the call to
`fl_register_plugins`:
```c title="my_application.cc"
```c title="runner/my_application.cc"
static void my_application_activate(GApplication* application) {
// ...
fl_register_plugins(FL_PLUGIN_REGISTRY(self->view));
Expand All @@ -1073,7 +1073,7 @@ you would write in a native Linux application.
Add the following as a new function at the top of
`my_application.cc` just after the `G_DEFINE_TYPE` line:

```c title="my_application.cc"
```c title="runner/my_application.cc"
static FlMethodResponse* get_battery_level() {
// Find the first available battery and report that.
g_autoptr(UpClient) up_client = up_client_new();
Expand Down Expand Up @@ -1103,7 +1103,7 @@ is called, report that instead.

Add the following code after the `get_battery_level` function:

```cpp title="my_application.cpp"
```cpp title="runner/my_application.cpp"
static void battery_method_call_handler(FlMethodChannel* channel,
FlMethodCall* method_call,
gpointer user_data) {
Expand Down

0 comments on commit 58c0c93

Please sign in to comment.