ditto_live_web_alpha 0.0.3 ditto_live_web_alpha: ^0.0.3 copied to clipboard
An alpha build of the Ditto SDK for Flutter Web
ditto_live_web_alpha #
Warning
This plugin is an early alpha which enables users to use Ditto on web platforms. Other platforms will not be supported by this package, that is covered by package:ditto_live
For more information, consult the docs for package:ditto_live
Installation #
- Add the package to your
pubspec.yaml
, or runflutter pub add ditto_live_web_alpha
- Edit the
index.html
of your app to loadditto.es6.js
in the<body>
:
<!-- before -->
<body>
<script src="flutter_bootstrap.js" async></script>
</body>
<!-- after -->
<body>
<script type="module">
import * as dittoJS from "/assets/packages/ditto_live_web_alpha/lib/assets/ditto.es6.js";
window.dittoJS = dittoJS;
</script>
<script src="flutter_bootstrap.js" async></script>
</body>
Usage #
Ditto's WebAssembly library needs to be downloaded and initialized before any of its APIs can be used. By default, the WebAssembly binary is loaded from the plugin's assets.
import 'package:ditto_live_web_alpha/ditto_live_web_alpha.dart';
WidgetsFlutterBinding.ensureInitialized();
await initWasm();
You can also download the WebAssembly binary from a URL. Make sure to configure
CORS and to serve the binary with MIME type application/wasm
. You can find
ditto.wasm
in the lib/assets
directory of this package.
await initWasm("https://example.com/ditto.wasm");,
Find the next steps for how to initialize a Ditto instance and start working with documents in the documentation for package:ditto_live
.
Known issues #
Certain features of package:ditto_live
are not supported by this plugin. This plugin does not support:
- identites other than
OnlinePlaygroundIdentity
andOnlineWithAuthenticationIdentity
, - any presence APIs such as
Ditto.presence.observe()
.
For API docs about any of these features, consult the API docs for package:ditto_live
. For docs about Ditto in general, go to <docs.ditto.live>.
Errors thrown by all of this plugin's APIs may have different types and messages than those thrown by package:ditto_live
.