Skip to main content

infinite_math_plot 0.1.0 copy "infinite_math_plot: ^0.1.0" to clipboard
infinite_math_plot: ^0.1.0 copied to clipboard

A Flutter package that renders interactive mathematical graphs on a simulated infinite coordinate plane.

Changelog #

All notable changes to this package will be documented here.

The format follows Keep a Changelog, and this project uses Semantic Versioning.


0.1.0 - 2026-05-12 #

First public release. This is the initial version of the package, so everything listed here is new.

Added #

Core widget

  • InfiniteMathPlot — a StatefulWidget that accepts an equation string and renders an interactive graph
  • Single-equation mode via the equation parameter
  • Multi-equation mode via the equations parameter (list of EquationConfig)
  • Mutual exclusion assertion: providing both equation and equations, or neither, throws at construction time
  • xMin, xMax, yMin, yMax parameters to set the initial viewport (default: -10 to 10 on both axes)
  • showGrid, showAxes, enableZoom, enablePan boolean flags, all defaulting to true
  • graphColor and strokeWidth for single-equation styling
  • samplingPrecision to control sample density (default: 2.0 points per logical pixel)
  • Adaptive layout via LayoutBuilder — fills available space and maintains math aspect ratio on resize

Equation parser

  • Parses Cartesian (y = f(x)), implicit (F(x,y) = 0), parametric (x = f(t), y = g(t)), and polar (r = f(θ)) equations from plain strings
  • Supported functions: sin, cos, tan, asin, acos, atan, sqrt, abs, exp, log, pow
  • Supported constants: pi, π, e, theta, θ
  • ParseException with a human-readable message and character position on invalid input
  • Canonical serialization via serialize(Expression) — stable across round-trips

Sampling

  • Cartesian sampling: iterates x over the viewport, evaluates y = f(x)
  • Polar sampling: iterates θ from 0 to 2π, computes x = r·cos(θ), y = r·sin(θ)
  • Parametric sampling: iterates t from 0 to 2π, evaluates x = f(t) and y = g(t) independently
  • Implicit sampling: marching squares over a 50×50 grid, linear interpolation of zero-crossings
  • Sample cache keyed on (equation, viewport, samplingPrecision, screenWidth) — no recomputation when nothing changes

Discontinuity detection

  • isUndefined: classifies NaN, +Infinity, -Infinity as undefined — path is lifted at these points
  • isAsymptote: detects true vertical asymptotes (values straddling the viewport from above and below) without breaking steep-but-continuous functions like y = x³

Rendering

  • GraphPainter (CustomPainter) draws grid → axes → curves in that order
  • Grid interval snaps to "nice" numbers (1, 2, 5, 10, 20, 50, …) based on the current viewport scale
  • Axes drawn only when x=0 or y=0 is within the viewport
  • Tick marks with numeric labels on both axes
  • Curve paths use moveTo after null entries (discontinuities) and lineTo otherwise
  • shouldRepaint returns false when nothing has changed — avoids unnecessary redraws

Gesture handling

  • Pinch-to-zoom: applies incremental scale delta each frame (not cumulative), centered on the focal point
  • Scroll-wheel zoom: scroll down = zoom out (×0.9), scroll up = zoom in (×1.1)
  • Drag-to-pan: converts screen delta to math units via the coordinate transformer
  • All gestures respect enableZoom and enablePan flags

Coordinate transformer

  • toScreen(x, y) — linear mapping from math coordinates to screen pixels, Y-axis inverted
  • toMath(screenOffset) — algebraic inverse of the forward transform
  • Round-trip accuracy within floating-point tolerance (< 1e-10)

Data models

  • Viewport — immutable value class with copyWith, structural equality, and hashCode
  • ParsedEquation — holds the expression tree, equation type, and canonical serialized form
  • ParseException — implements Exception with message and position
  • EquationConfig — equation string + color + strokeWidth with structural equality
  • SampleCacheKey — composite cache key with structural equality on all four fields
  • GraphState — runtime state with copyWith
  • EquationType enum — cartesian, implicit, parametric, polar

Example app

  • Interactive demo in example/ with 8 presets, a custom equation input field, and toggles for all display and gesture options

Tests

  • 241 tests covering all components
  • Property-based round-trip tests for the equation parser and coordinate transformer
  • Property-based classification test for the discontinuity detector
  • Unit tests for all components
  • Widget tests for InfiniteMathPlot

Upcoming #

Things I'm planning for future releases:

  • Configurable parametric t-range (currently fixed at 0 to 2π)
  • Tap-to-inspect: show the y-value at a tapped x position
  • Isolate-based sampling for very high precision or many simultaneous equations
  • Animation support for time-varying equations
  • Export to image

1
likes
130
points
12
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A Flutter package that renders interactive mathematical graphs on a simulated infinite coordinate plane.

Homepage

License

MIT (license)

Dependencies

flutter, math_expressions

More

Packages that depend on infinite_math_plot