Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing note: The file should be recompiled using Visual Studio for the changes to take effect. #11390

Open
1 task done
AbdeMohlbi opened this issue Nov 12, 2024 · 0 comments · May be fixed by #11391
Open
1 task done
Labels
from.page-issue Reported in a reader-filed concern

Comments

@AbdeMohlbi
Copy link

Page URL

https://docs.flutter.dev/platform-integration/platform-channels/

Page source

https://github.com/flutter/website/tree/main/src/content/platform-integration/platform-channels.md

Describe the problem

After completing Step 5 in the Flutter documentation, replace the code with the following:

channel.SetMethodCallHandler(
    [](const flutter::MethodCall<>& call,
       std::unique_ptr<flutter::MethodResult<>> result) {
      if (call.method_name() == "getBatteryLevel") {
        int battery_level = GetBatteryLevel();
        if (battery_level != -1) {
          result->Success(battery_level);
        } else {
          result->Error("UNAVAILABLE", "Battery level not available.");
        }
      } else {
        result->NotImplemented();
      }
    });

You should now be able to run the application on Windows. If your device doesn't have a battery, it will display 'Battery level not available'.

Expected fix

i suggest adding at the end :
Note: To ensure the changes take effect, the project should be recompiled with Visual Studio. Otherwise, you may encounter an error saying: Failed to get battery level: Memory leak.
it's not mention that the exe should be recompiled using Visual studio again.
also the error message of the leaking is very confusing.

Additional context

No response

I would like to fix this problem.

  • I will try and fix this problem on docs.flutter.dev.
@AbdeMohlbi AbdeMohlbi added the from.page-issue Reported in a reader-filed concern label Nov 12, 2024
@AbdeMohlbi AbdeMohlbi changed the title Missing note: The file should be compiled using Visual Studio for the changes to take effect. Missing note: The file should be recompiled using Visual Studio for the changes to take effect. Nov 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
from.page-issue Reported in a reader-filed concern
Projects
None yet
1 participant