1
0
mirror of https://github.com/flutter/samples.git synced 2025-11-08 13:58:47 +00:00
Files
samples/platform_channels
Brett Morgan e5ec08fccd Update Samples for 3.16 (#2085)
*Replace this paragraph with a description of what this PR is changing
or adding, and why. Consider including before/after screenshots.*

*List which issues are fixed by this PR. For larger changes, raising an
issue first helps
reduce redundant work.*

## Pre-launch Checklist

- [ ] I read the [Flutter Style Guide] _recently_, and have followed its
advice.
- [ ] I signed the [CLA].
- [ ] I read the [Contributors Guide].
- [ ] I updated/added relevant documentation (doc comments with `///`).
- [ ] All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-devrel
channel on [Discord].

<!-- Links -->
[Flutter Style Guide]:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo
[CLA]: https://cla.developers.google.com/
[Discord]: https://github.com/flutter/flutter/wiki/Chat
[Contributors Guide]:
https://github.com/flutter/samples/blob/main/CONTRIBUTING.md
2023-11-16 08:55:44 +10:00
..
2023-11-16 08:55:44 +10:00
2023-11-16 08:55:44 +10:00
2023-11-16 08:55:44 +10:00
2021-03-17 15:42:29 +11:00

Platform Channel Samples

A sample app which demonstrates how to use MethodChannel, EventChannel, BasicMessageChannel and MessageCodec in Flutter.

Goals

  • Demonstrate how to use MethodChannel to invoke platform methods.
  • Demonstrate how to use EventChannel to listen continuous value changes from the platform.
  • Demonstrate how to use BasicMessageChannel and MessageCodec to send messages of different types across the platform.

The important bits

Method Channel demo

Demonstrates how to implement a MethodChannel to increment and decrement a counter.

Event Channel demo

Demonstrates how to implement an EventChannel to listen to value changes from the Accelerometer sensor from native side.

Platform Image demo

Demonstrates how to implement a BasicMessageChannel using StandardMessageCodec to load an image from native asset.

Basic Message Channel demo

Demonstrates how to implement BasicMessageChannel using JSONMessageCodec, BinaryCodec and StringCodec to send and receive data about pets.

Questions/issues

If you have a general question about Platform Channels in Flutter, the best places to go are:

If you run into an issue with the sample itself, please file an issue here.