https://github.com/xclud/dart_serial
Wrapper around the `window.navigator.serial` for flutter web.
https://github.com/xclud/dart_serial
dart flutter serialport
Last synced: about 1 year ago
JSON representation
Wrapper around the `window.navigator.serial` for flutter web.
- Host: GitHub
- URL: https://github.com/xclud/dart_serial
- Owner: xclud
- License: mit
- Created: 2022-01-19T15:13:44.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2025-04-03T14:36:21.000Z (over 1 year ago)
- Last Synced: 2025-04-25T12:54:40.616Z (about 1 year ago)
- Topics: dart, flutter, serialport
- Language: Dart
- Homepage: https://pub.dev/packages/serial
- Size: 5.31 MB
- Stars: 13
- Watchers: 2
- Forks: 8
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
`serial` is a wrapper around the `window.navigator.serial`. This package does not provide any additional API, but merely helps to make the `dart:html` package work "out of the box" without the need of manually writing any javascript code.
## Web Demo
[Web Demo](https://serial.pwa.ir)
## Requirements
In order to access serial ports on web, you need your web page to open from an HTTPS url.
> Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.
More information: [https://developer.mozilla.org/en-US/docs/Web/API/SerialPort](https://developer.mozilla.org/en-US/docs/Web/API/SerialPort)
## Usage
``` dart
import 'dart:html';
import 'package:serial/serial.dart';
final port = await window.navigator.serial.requestPort();
await port.open(baudRate: 9600);
final writer = port.writable.writer;
await writer.ready;
await writer.write(Uint8List.fromList('Hello World.'.codeUnits));
await writer.ready;
await writer.close();
```