Skip to content

Commit

Permalink
Enable --wasm flag for production builds (#3039)
Browse files Browse the repository at this point in the history
* Enable --wasm flag for production builds

* Use Future.delayed to ensure that Codemirror refresh is consistent

* Use delay to call refresh() in intersection observer, add comment.
  • Loading branch information
johnpryan committed Aug 14, 2024
1 parent f70ef45 commit 5f58825
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .cloud_build/dart_pad.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
steps:
- name: gcr.io/$PROJECT_ID/flutter:main
args: ['build', 'web']
args: ['build', 'web', '--wasm']
dir: pkgs/dartpad_ui
- name: gcr.io/$PROJECT_ID/firebase
args: ['deploy', '--project=$PROJECT_ID', '--only', 'hosting:dartpad']
Expand Down
10 changes: 8 additions & 2 deletions pkgs/dartpad_ui/lib/editor/editor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,10 @@ class _EditorWidgetState extends State<EditorWidget> implements EditorService {
// darkmode
_updateCodemirrorMode(darkMode);

Timer.run(() => codeMirror!.refresh());
// Use a longer delay so that the platform view is displayed
// correctly when compiled to Wasm
Future.delayed(
const Duration(milliseconds: 80), () => codeMirror!.refresh());

codeMirror!.on(
'change',
Expand Down Expand Up @@ -258,7 +261,10 @@ class _EditorWidgetState extends State<EditorWidget> implements EditorService {
for (final entry in entries.toDart) {
if (entry.isIntersecting) {
observer.unobserve(web.document.body!);
Timer.run(() => codeMirror!.refresh());
// Use a longer delay so that the platform view is displayed
// correctly when compiled to Wasm
Future.delayed(
const Duration(milliseconds: 80), () => codeMirror!.refresh());
return;
}
}
Expand Down

0 comments on commit 5f58825

Please sign in to comment.