This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Flutter Markdown Plus is a Flutter package that renders Markdown text into Flutter widgets. It's built on top of the Dart markdown package and supports GitHub Flavored Markdown by default. The package provides both Markdown (with scrolling) and MarkdownBody widgets, along with extensive customization options for styling, image handling, and interactive elements.
- Run all tests:
flutter test - Run tests with coverage:
rm -rf coverage && flutter test - Run all tests via test suite:
flutter test test/all.dart - Run a single test file:
flutter test test/[test_name].dart
- Format code:
dart format . -l 120orsh ./scripts/format.sh - Format only staged files:
sh ./scripts/format.sh --only-staged - Format with exit-on-change:
sh ./scripts/format.sh --set-exit-if-changed - Analyze code:
flutter analyze --no-pub . - Full validation:
./validate.sh(runs clean, pub get, format, analyze, and test)
- Get dependencies:
flutter pub get - Clean build:
flutter clean
- Run example app:
cd example && flutter run - Demos are in
example/lib/demos/showcasing various features - Shared widgets in
example/lib/shared/include reusable demo components and sample custom syntax implementations
Main Entry Point (lib/flutter_markdown_plus.dart)
- Exports the three main modules: builder, style_sheet, and widget
Widget Layer (lib/src/widget.dart)
Markdown: Scrollable markdown widget with paddingMarkdownBody: Non-scrollable markdown widget for embeddingMarkdownRaw: Base widget without Material Design theming- Callback typedefs for link taps, selection changes, and custom builders
Builder Layer (lib/src/builder.dart)
MarkdownBuilder: Converts markdown AST nodes to Flutter widgets- Handles all markdown elements: headers, paragraphs, lists, tables, images, etc.
- Manages text styling, link handling, and custom element rendering
- Block vs inline element handling with proper nesting
Style Layer (lib/src/style_sheet.dart)
MarkdownStyleSheet: Comprehensive theming system- Integrates with Material Design themes
- Supports custom text styles, colors, decorations, and spacing
_functions_io.dart: IO platform implementations_functions_web.dart: Web platform implementations- Conditional imports handle platform differences
Custom Builders
imageBuilder: Custom image widget renderingcheckboxBuilder: Custom checkbox renderingbulletBuilder: Custom bullet point rendering
Syntax Extensions
- Supports markdown package's extension system
- Default: GitHub Flavored Markdown
- Can add emoji syntax, custom inline/block syntaxes
Selection & Interaction
- Configurable text selection behavior
- Link tap handling with custom callbacks
- Integration with Flutter's SelectionArea
- Markdown Parsing: Built on
markdownpackage AST - Rich Styling: Material Design integration with custom overrides
- Image Support: Network, local, and asset images with
resource:prefix - Table Rendering: Full table support with custom styling
- Interactive Elements: Checkboxes, links with tap handlers
- Text Selection: Configurable selection with callbacks
- Extensibility: Plugin system for custom syntax and rendering
Tests are comprehensive and organized by feature:
- Individual element tests (headers, lists, images, etc.)
- Style sheet testing
- Selection and interaction testing
- Platform compatibility testing
- Mock-based image testing
The test/all.dart file runs the complete test suite.
- Line length: 120 characters (configured in
pubspec.yaml) - Follows Flutter/Dart team's analysis_options.yaml with minor modifications
- Public API documentation required (
public_member_api_docs) - Strict type checking enabled
- Uses
prefer_single_quotesand other Flutter conventions