Short Intro:
Math expression editing using an on-screen software keyboard or physical keyboard input in a typeset input field in Flutter.
math_keyboard is a Flutter package that allows editing math expressions using a typeset input field (so-called “math field”) and a custom-made fully integrated math keyboard in Flutter only – no plugins, no web views.
About math_keyboard
The math_keyboard package provides a widget that behaves like a Flutter TextField with the same full integration , i.e. focus tree support, input decoration support, and both an on-screen software keyboard as well as physical keyboard input support. On top of that, the math field typesetting uses TeX and the package supports converting to math expressions (that e.g. can be used for calculation).
math_keyboard is an open source project with the aim of providing a way to edit math expression providing the best user experience in terms of input and UI as well as allowing accurate evaluation of the mathematical expressions entered by the user. This is used by the simpleclub app , hence, the association. It is also maintained by simpleclub (see the LICENSE file).
Features & usage
See the package README for features and usage information.
You can also try the demo app or view the package on Pub →
Implementation
In the following, some high-level information regarding the implementation of the package is described. This is useful in case you are curious or intend to contribute.
For information on implementing math_keyboard into your own app , please see the package README .
Math expressions
Notice how the math_keyboard package includes a major feature that allows working with the input expressions in a mathematical matter, i.e. by converting them into “math expressions” (this is how we refer to the format in the context of this project).
We achieve this by essentially working with two formats:
The typeset display format, powered by TeX (see below). A data format, i.e. math expressions.
This “data format” depends on the math_expressions package . Handling the expressions in this format allows you to e.g. evaluate the expressions.
TeX typesetting
Both the math field content, i.e. the expressions typed by the user, as well as some symbols on the keyboard itself are typeset using TeX. For TeX typesetting in Flutter, we created our own proof of concept renderer in early 2020, called CaTeX . This project is on-hold for now and in the meantime, we collaborated on the flutter_math package that aims to achieve something similar. Due to lack of maintenance on that repo, we are currently using our forked version, flutter_math_fork . Note that our ultimate goal is fully integrating the math_keyboard package with the catex package, which would give us maximum control over the rendering of the typeset math.
Contributing
Our mission with open source repositories like math_keyboard in particular is creating an ecosystem of science and education related packages for Flutter, allowing users on all platforms to use the optimal tools for learning.
This is also why we want to share and collaborate on this software as a way to give back to the community. Any contributions are more than welcome!
See our contributing guide for more information.
Missing features
You might notice that some features that you would expect from the math_keyboard package are missing or something is not working as expected. In that case, please file an issue .
In general, we can of course never fully solve every use case, however, especially in this case we are aware of a few shortcomings. For example the customization options of the keyboard are currently limited because this has simply not yet been a requirement in our internal usage. In that case, please consider contributing pull requests to this repo in order to allow as many use cases to be covered as possible 🙂 Please refer to the contributing guide for that.
Repo structure
The math_keyboard repository is divided into multiple packages. These packages are the following:
Num++ inspiration
During the research phase of this project, we came across the Num++ app , which served as an inspiration for the math expression parsing part of the package. The main difference between that app and this package (apart from one being a calculator app and the other being a generalized usable package) is the fact that Num++ uses a web view and MathQuill for editing the expression while we built the input field and editing ourselves.
Download Math expression editing software source code on GitHub
Math expression editing using an on-screen software keyboard or physical keyboard input in a typeset input field in Flutter. https://github.com/simpleclub/math_keyboard 74 forks. 145 stars. 30 open issues. Recent commits: ci: run pana directly instead of the stale package analyzer action (#94)* ci: run pana directly instead of the stale package analyzer actionaxel-op/dart-package-analyzer ships a Docker image with Dart 3.10.7, whichcannot resolve the package since it requires Dart >=3.13. Run pana onFlutter stable instead, failing when more than 40 of 160 points are lost.The pana workflow now runs on pull_request, so it analyzes the PR's codeand needs no write token.Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>* ci: refresh apt lists before installing webp and pin panaCo-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>* ci: run the required checks when any workflow changesCo-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>———Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> , GitHub chore: migrate to the standalone material_ui package (#93)* chore: migrate to the standalone material_ui packageFlutter 3.50 deprecates the in-framework Material library in favor ofpackage:material_ui. Rewrites the imports with`dart fix –apply –code=migrate_design_widgets`, switches the example andtests to `GlobalMaterialLocalizations.delegates` from material_ui, and dropsthe now unused flutter_localizations dependency.The public API now uses the material_ui types, so this is released as thebreaking 0.5.0.Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>* chore: tidy up the material_ui migrationSorts the material_ui imports alphabetically, points the README'sInputDecoration and TextFormField links at the material_ui docs, and raisesthe example's and demo's minimums to Flutter 3.47 / Dart 3.13, whichmaterial_ui requires. The new language version reformats both apps.Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>———Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> , GitHub Make the decimal separator configurable (#92)* Make the decimal separator configurableThe decimal separator was derived from the ambient locale with no way tooverride it, so an app that lets users choose between `.` and `,` had tooverride the whole `Localizations` locale to get one.Add a `DecimalSeparator` enum, settable on `MathKeyboardTheme` or as anargument to `MathField`, `MathFormField` and `MathKeyboard`. It resolvesargument > theme > locale, matching how `style` and `semantics` alreadyresolve. Defaults to `null`, which keeps the locale-based behaviour.The separator now also applies to the TeX reported by `onChanged` and`onSubmitted`, so rendering the reported value shows the same number thefield shows, and to the screen reader's announcement of the field value,which previously said "1 . 5" while the key announced ",". `TeXParser`reads every `DecimalSeparator`, grouped (`1{,}5`) or plain, deriving thegrammar from the enum so that emitting and parsing cannot drift apart.Fields in a dot locale report exactly what they reported before.Also fixes `decimalSeparator(BuildContext)` throwing an `ArgumentError`for locales intl does not know, instead of falling back to `.` as itdocumented. It becomes `DecimalSeparator.of`.Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>* Address review: keep MathFormField's value in one format`didChangeDependencies` does not run when only the `decimalSeparator`argument changes, so the form value kept the old format while the child`MathField` already used the new one. Resolve in one place and call itfrom `didUpdateWidget` too.`_handleControllerChanged` compared the canonical value against the formvalue, which now carries the separator. For a comma field that comparisonwas always unequal, defeating the guard's purpose and notifying`Form.onChanged` with the canonical value before the field reported thelocalized one.Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>* Announce numbers as numbers to screen readersThe accessible value joined every leaf with a space, so "1.5" reached thescreen reader as "1 , 5". At a default punctuation verbosity a loneseparator is dropped and space separated digits are spelled out one byone, which is why it was heard as "1 5" (and "23" as "2 3").Coalesce a run of adjacent numeric leaves into a single token instead, sothe value carries "1,5" and "23". Inside a number the separator stays aglyph on purpose: the speech engine's own number formatting then reads itcorrectly and in the right language. A cursor sitting inside a number doesnot break the run.Standing on its own the separator needs a word, because punctuationembedded in a sentence is dropped: `tokenMappings` now maps `.` to"point" so the cursor announcement says "before point" rather than just"before". It is localized through the same seam as the rest ofMathKeyboardSemantics. The decimal key keeps the bare glyph, which ascreen reader names in the user's own language.Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>* ci: redeploy the web demo when the package changesThe demo depends on math_keyboard by path, so the deployed page is builtfrom the package sources, but the workflow only triggered on changes undermath_keyboard_demo/ and on the package's pubspec. Changes to the packageitself therefore never reached the live demo.Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>* Ignore the demo's ephemeral iOS build outputflutter pub get regenerates ios/Flutter/ephemeral/ (the generatedSwiftPM package and the LLDB helpers) on every run, and the demo's.gitignore was missing the rule for it. It is otherwise identical to theexample's, which already has it.Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>* fixes———Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com> , GitHub ci: update web demo deploy workflow to maintained action versions (#91)* ci: update web demo deploy workflow to maintained action versions* ci: update checkout action in checks workflow , GitHub Feat/math keyboard redesign theme a11y (#90)* feat: redesign math keyboard with theming API and accessibilityRestyle the on-screen keyboard to the simpleclub design and add aconfigurable theme plus first-class accessibility, keeping the publicAPI backwards compatible.Theming:- MathKeyboardStyle + MathKeyboardTheme inherited widget with a Figma-default fallback, plumbed through MathField/MathFormField.- Per-tier key tokens: digits on the secondary surface, operators and variables on the neutral filled-button surface, delete on secondary/weak, submit on primary; focus keeps the idle surface + ring.- Function-key labels show example variables (x/y, x^2, sqrt{x}, …) instead of empty placeholders, matching the design.Accessibility:- Localizable MathKeyboardSemantics seam for all screen-reader strings, including keyboard/section group labels.- Keyboard is focus-reachable: tab hands focus from the field into the keys, arrow keys traverse the grid, escape returns to the field, and the keyboard stays open while either the field or a key holds focus.- Keys expose single button nodes with spoken labels; sections are wrapped as Variables/Functions/Numbers/Submit groups inside a top-level "Math keyboard" group.- Landscape focus order walks the number panel before the functions.- Variable row shrinks keys past five so a partial key bleeds off the edge, and auto-scrolls the focused item into view.- Keep the keyboard open under a screen reader so the keys can be reached.Fixes:- Hover now works on web (driven by MouseRegion instead of the highlight-mode-gated FocusableActionDetector callback).Adds characterization and a11y tests covering behavior, focus, hover,states, the variable bar, screen-reader survival, and semantic grouping.* fix: use secondary/base for delete key hover and pressedThe delete/back key stays on secondary/weak at idle but darkens tosecondary/base on hover and pressed (matching the design). This alsocovers the page-toggle key, which shares the utility tier.* feat: WCAG-compliant keyboard navigation and screen-reader accessRework the on-screen keyboard's focus model to the WAI-ARIA compositepattern and improve screen-reader access.Keyboard navigation:- The keyboard is a single tab stop: arrow keys move between all keys as a grid, Enter/Space activate, and tab leaves the keyboard for the next page control (shift+tab returns to the field) so focus is never trapped (WCAG 2.1.2).- Escape dismisses the keyboard and returns focus to the field without reopening it.Screen reader:- The field exposes an onTap semantics action so an accessibility activation (e.g. VoiceOver double-tap) opens the keyboard without a pointer.- The keyboard stays open while focus is on the keys so it can be reached.- Each section (variables, formula, numbers, submit) is a labelled landmark region, so a screen reader can jump straight to a section via landmark/rotor navigation. The keyboard wrapper stays a plain group.Other:- Rename the function keyboard's user-facing label to "Formula" (English fallback; consumers still inject their own translations).- Center the magnified label within the large-content-viewer overlay.Updates the focus, screen-reader, and semantics-group tests for the newmodel.* chore: bump to 0.4.0, raise Flutter floor, add changelogThe redesign adds new API, a new dependency, and changes the defaultappearance, so bump the minor version and document it. Raise the SDKfloor to Flutter 3.35.1 / Dart 3.9, required by SemanticsRole.region(used for the keyboard's section landmarks).* fix: drop redundant submit landmark, tidy focus-listener teardown- Landscape submit is a single button, so wrap it only in a semantics boundary (to stay a sibling of the section landmarks) instead of a labelled region — a screen reader no longer announces "Submit" twice.- Remove the _keyboardFocusScopeNode listener before disposing it and guard its callback with a mounted check, matching the other teardown.* docs: neutral theme docs; default MathKeyboardTheme.style to fallback- Rephrase the public dartdoc for MathKeyboardStyle/fallback to drop simpleclub- and design-token-specific wording that is meaningless to third-party consumers.- Default MathKeyboardTheme.style to MathKeyboardStyle.fallback so a theme that only overrides semantics (for localization) no longer has to pass a full style.* docs: correct key-tier doc comments after the color reworkDigits are on the function tier (secondary surface), not neutral; theneutral tier is operators, decimal, parentheses, cursor keys, andvariables. Update the MathKeyboardKeyTier docs to match.* docs: drop internal token names from fallback style commentsThe inline comments on MathKeyboardStyle.fallback referenced internaldesign-token names (filledButton/neutral, secondary/base, primary/…),which are meaningless outside simpleclub. Describe each tier's keys andits idle/hover behaviour in neutral terms instead.* docs: document theming, accessibility, and large-text features in READMEThe Features list didn't mention the 0.4.0 additions. Add bullets forthe configurable MathKeyboardTheme/MathKeyboardStyle, the accessibilitysupport (landmarks, arrow-key navigation, localizable semantics), andthe long-press large-text magnification, noting the large_content_viewerdependency it relies on.* feat: tab through the keys as buttons with boundary exitThe keys are ordinary buttons, so tab now traverses them one by one (the expected behaviour) rather than the keyboard being a single tab stop with arrows-only movement; the arrow keys stay as a bonus for 2-D grid movement. To avoid trapping focus, tab past the last key exits to the control after the field and shift+tab past the first key returns to the field, instead of wrapping within the keys (WCAG 2.1.2). Escape still closes.* Order keyboard tab traversal: numbers, then formula, then submitTab entered the on-screen keys in raw geometric order, zig-zagging acrossthe two side-by-side landscape columns. Give each section an explicitFocusTraversalOrder so tab visits the number pad first, then the formulasection, then submit, and switch the keyboard to an OrderedTraversalPolicy.The boundary-exit check uses the same policy so tab still leaves thekeyboard at the ends instead of wrapping.* Pin per-key tab order within keyboard sectionsThe section-level traversal order left keys inside a section to geometricreading order, which zig-zagged across the unevenly sized number cells.Assign each key an explicit FocusTraversalOrder under the singleOrderedTraversalPolicy (numbers 0.., variables 100, functions 200..,submit 300) so tab follows the configured row-major layout end to end.Keeping the orders global (no nested groups) means the boundary-exitcheck still sees the true first and last key.* Drop the page-toggle magnifier under a screen readerThe page toggle is a mode switch, not content, so the long-presslarge-content magnifier adds no value there for a screen-reader user.Gate it on MediaQuery.accessibleNavigation: sighted users keep thelong-press magnifier on the '123' key, screen-reader users don't.* docs: fix changelog traversal wording, document landscape, modernize README example* test: drop low-value hover, variables, and value-type tests* revert: keep the empty-box placeholders on function-key labels* chore: use plain 500/800 keyboard max-width literals; drop pubspec comment* chore: format with the Dart tall formatter (Dart 3.9+)* test: silence containsSemantics deprecation for newer Flutter analyze* fix: expose validation error and speak operator tokens to screen readers* fix: order-independent semantics hash, escape caret blink, text-scale assert, number-only page guard* chore: git-ignore and untrack Flutter iOS ephemeral files* docs: note the keyboard focus callbacks are optional and auto-wired by MathField* fix: dismiss the keyboard on escape while the field holds focus (F4)* fix: don't swallow or crash Tab when the keyboard is closed (F1)* fix: split keyboard mounted vs open to fix close-animation edge cases (F2)* fix: report key focus via onFocusChange for touch/switch-access (F7)* fix: expose key focusable/focused flags in semantics (F6)* feat: let consumers supply the field's spoken value and harden a11y reading- MathField/MathFormField gain an optional `semanticsValue` that overrides the built-in expression linearization, so a consumer can inject speech from a dedicated TeX-to-speech engine. When null, the field falls back to `readableExpression`, keeping the package dependency-free and accessible on its own.- tokenLabel now speaks function-like leaves (e.g. the trig keys' `cos(`) as words and strips any remaining TeX control chars, so a screen reader never reads out a raw backslash.- Guard the text-scale clamp with `math.max` so a sub-1 maxTextScaleFactor can't throw in release builds (asserts stripped).- A stray `togglePage()` on a number-only keyboard keeps the numbers layout and its region label in agreement (no null `page2` unwrap, no mislabel).- Skip the field's auto-scroll when the scroll view isn't attached, avoiding a "ScrollController not attached" assertion on rebuild.* refactor: remove the inert highlighted field from keyboard button configThe key tier now derives from asTex/isDigit, so BasicKeyboardButtonConfig.highlighted was read nowhere; the config class is unexported, so this has no consumer impact.* docs: document MathKeyboard's direct-use focus contract and assert itA bare MathKeyboard contains tab focus in its keys; focus only leaves via onExitToField/onExitToNext, which need focusScopeNode to work. Document that on the class and assert callbacks are never supplied without a scope (the silent case that never fires). , GitHub
Provides the list of the opensource Flutter apps collection with GitHub repository.