Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Update documentation for new location of linux source
  • Loading branch information
robert-ancell committed Sep 25, 2024
commit 5f0b8267e67f286afd8b278ddc805658ba4ad673
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`:
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