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

refactor: Simplifying universal_ui in the example app #1367

Closed

Conversation

LuchoTurtle
Copy link
Contributor

In the example app, in order to embed an image into the editor, we need to use platformViewRegistry.registerViewFactory so the image is properly displayed in web applications.

Because platformViewRegistry.registerViewFactory(...) was introduced in flutter/engine#41877, we don't need to use a fake_ui.dart and real_ui.dart to do conditional imports as a workaround for that not compiling on web.

Therefore, we can simply use:

import 'dart:ui_web' as ui_web; // New import for all web-only stuff...

...

ui_web.platformViewRegistry.registerViewFactory(...); // as usual!

This PR makes this simple change and removes consequential dead code 😃 .

Using `dart:ui_web` to define `platformViewRegistry`.
@LuchoTurtle
Copy link
Contributor Author

Although embedding an image on web still doesn't work on the example app (as shown in #976), I was able to verify this to work by returning an image URL in the _onImagePickCallback function inside lib/pages/home_page.dart.

Future<String> _onImagePickCallback(File file) async {
// Copies the picked file from temporary cache to applications directory
final appDocDir = await getApplicationDocumentsDirectory();
final copiedFile =
await file.copy('${appDocDir.path}/${basename(file.path)}');
return copiedFile.path.toString();
}

Instead of running this, I'm returning a simple URL address, like so (again, just for testing purposes).

  Future<String> _onImagePickCallback(File file) async {
     return "https://i.ytimg.com/vi/CKU8la04tdo/mqdefault.jpg";
  }
image

@LuchoTurtle
Copy link
Contributor Author

Closing this as it doesn't properly work on mobile devices :/

Sorry! You can dismiss this if you want to.

@EchoEllet
Copy link
Collaborator

We have commented the universal_ui since it's already in the flutter_quill_extensions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants