Skip to content

fix: Fix bugs and clean up non-idiomatic code - #134

Merged
spydon merged 1 commit into
mainfrom
fix/bugs-and-cleanup
Sep 30, 2026
Merged

spydon merged 1 commit into
mainfrom
fix/bugs-and-cleanup

Conversation

@spydon

@spydon spydon commented Sep 30, 2026

Copy link
Copy Markdown
Member

Description

A pass through the whole package that fixes the bugs I could reproduce and restructures the parts that were not idiomatic Flutter. Every bug below has a regression test.

Bugs fixed

  • Toolbar icons on touch platforms: on Android and iOS with a wide screen, the icons on the right were half clipped and partly untappable, and the close button overlapped the pin icon. DashbookIcon now uses a shrink wrapped tap target.
  • Device settings crashes: pressing "Reset" while "Custom device" was checked threw a null check error, and reopening the panel with a custom device active hit a dropdown assertion. Whether the device is custom is now derived from the settings instead of being kept as separate local state.
  • Theme chooser crash: Dashbook.multiTheme asserted when two entries had equal ThemeData. The selected theme is now tracked by name, and an empty theme map fails with a clear assertion.
  • Stale bookmark: a bookmark pointing at a removed chapter left the preview empty. It now falls back to the first chapter, also when the first story has no chapters.
  • usePreviewSafeArea: it only worked inside a device frame since the device preview feature was added. It applies to the plain preview again.
  • Number property: it only accepted digits, so decimals and negative numbers could not be typed.
  • Edge insets and border radius properties: the values overflowed the properties panel on medium widths, the editor truncated decimals and the text controllers were leaked.
  • Custom device size: the validators never ran, so typing "1" produced a one pixel wide device. Values that are out of range now show the error and are ignored, and editing the size no longer resets the rotation.
  • Web: chapter links and the share button were silently disabled in WebAssembly builds since the conditional import checked dart.library.html. A malformed link hash could leave the app blank, and a deep link stacked two pages.
  • Smaller ones:
    • The pin icon was invisible but still tappable on phones.
    • A failed "See code" launch threw a string and now shows a snack bar.
    • The device panel was titled "Properties" and is now "Device settings".
    • The bookmark tooltips were wrong.
    • setState could be called after dispose during loading.
    • The toolbar now scrolls when it does not fit the screen.

Cleanup

  • The 280 line build method in widget.dart is split into DashbookPage, Toolbar and the theme icon widgets.
  • Property editors no longer pass state through createState, most of them became stateless.
  • Dead code is removed: Link, DeviceDialogButtons, the duplicated DevicePropertyScaffold, the duplicate platform file, unused breakpoints, and mockingjay together with its commented out test.
  • Misspelled files and directories are renamed, and the typos in the README and the outdated code link in the example are fixed.
  • sort_constructors_first, no_logic_in_create_state, only_throw_errors and prefer_function_declarations_over_variables are enabled again in analysis_options.yaml.
  • The test helper for the screen size ignored the device pixel ratio, so tests asking for a 2000 wide screen really ran at 666. That is fixed.

Things that users might notice

  • ControlProperty and PropertyOption now have const constructors, so users with prefer_const_constructors enabled will get new hints.
  • DashbookContext.properties, DashbookContext.actions, Story.chapters and Chapter.ctx are now final.
  • Chapter names in the stories list are indented with padding instead of two leading spaces.
  • The "Same value to all" switch follows the theme instead of using hard coded blue and grey.

Not included

  • flutter_markdown is discontinued in favour of flutter_markdown_plus, and very_good_analysis is four major versions behind. Dependency upgrades are left for a separate change.
  • sliderProperty still only supports the range 0 to 1. Fixing that properly means adding min and max parameters, which is a feature.
  • Chapter.widget(), Decorator.decorate() and Property.createPropertyEditor() are unchanged since they are public API.

Testing

  • dart analyze --fatal-infos . and dart format . --set-exit-if-changed are clean.
  • flutter test passes (74 tests), and so does flutter test --platform chrome.
  • The web build of the example was driven in headless Chrome to check deep links, the properties panel, the custom device flow, the theme toggle and the share button.

Fixes toolbar tap targets on touch platforms, device settings crashes, the multi theme chooser crash, stale bookmarks, the preview safe area, number and edge insets property editors, and web chapter links in WebAssembly builds. Splits the main widget into smaller widgets, removes dead code and adds regression tests.
@spydon
spydon merged commit 25532f7 into main Sep 30, 2026
3 checks passed
@spydon
spydon deleted the fix/bugs-and-cleanup branch September 30, 2026 15:06
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