Skip to content

Commit

Permalink
Fix WASM casting bug (#73)
Browse files Browse the repository at this point in the history
* workaround for wasm compiler bug

* flutter_math version bump for 3.27 compatibility

* updated changelog

---------

Co-authored-by: Eric Dhom <[email protected]>
  • Loading branch information
thomasostfeld and edhom authored Jan 13, 2025
1 parent 332ab0e commit d7aac6a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
4 changes: 4 additions & 0 deletions math_keyboard/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.3.2

* Workaround for dart2wasm [bug](https://github.com/dart-lang/sdk/issues/59782).

## 0.3.1

* Updated README
Expand Down
13 changes: 8 additions & 5 deletions math_keyboard/lib/src/foundation/tex2math.dart
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,8 @@ class TeXParser {
final result = <Expression>[];
Expression left;
Expression right;
for (var i = 0; i < _outputStack.length; i++) {
switch (_outputStack[i]) {
for (final element in _outputStack) {
switch (element) {
case '+':
right = result.removeLast();
left = result.removeLast();
Expand Down Expand Up @@ -391,11 +391,14 @@ class TeXParser {
// ignore: empty_catches
} catch (e) {}
break;
// workaround for WASM casting bug, needs at least one non-string case
// remove when https://github.com/dart-lang/sdk/issues/59782 is fixed
case 0:
default:
if (_outputStack[i] is String) {
result.add(Variable(_outputStack[i]));
if (element is String) {
result.add(Variable(element));
} else {
result.add(Number(_outputStack[i]));
result.add(Number(element));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion math_keyboard/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: math_keyboard
description: >-2
Math expression editing using an on-screen software keyboard or physical keyboard input in a
typeset input field in Flutter.
version: 0.3.1
version: 0.3.2
homepage: https://github.com/simpleclub/math_keyboard/tree/main/math_keyboard

environment:
Expand Down

0 comments on commit d7aac6a

Please sign in to comment.