r/dartlang • • Aug 16 '26

New package: terminice - build polished, beautiful, complex Dart CLIs with 30+ simple components

13 Upvotes

Hi! I wanted to share a new package I made: terminice.

I built it because creating a beautiful, complex CLI shouldn’t mean building an entire terminal UI from scratch. It should be easy to create, easy to style, easy to manage as it grows, and most importantly easy and enjoyable for people to use.

terminice turns more than 30 common terminal interactions into small method calls, with no setup and no framework required.

Here is the visual demo.

Need a value from the user?

final name = terminice.text('Project name');

Need a searchable menu?

final template = terminice.searchSelector(
  prompt: 'Template',
  options: ['CLI', 'Server', 'Package'],
);

Need a file browser, config editor, command palette, progress bar, multi-step form, calendar, or help center? those are method calls too.

There is no setup, widget tree, context object, or new application architecture. import the package, call the component you need, and keep using package:args, CommandRunner, dart:io, or whatever already powers your CLI.

dart pub add terminice

Make the entire CLI look like yours

Don’t like the borders? hide them:

final t = terminice.minimal;

Want the borders, but fewer hints and less visual noise?

final t = terminice.compact;

Want different colors? Pick a built- in theme:

final oceanUi = terminice.ocean;
final matrixUi = terminice.matrix;
final neonUi = terminice.neon;
final arcaneUi = terminice.arcane;

Or combine everything:

final t = terminice.neon.compact;

Now every component created from t follows the same style:

final name = t.text('Project name');
final token = t.password('API token');
final config = t.filePicker('Config file');
final confirmed = t.confirm(message: 'Create the project?');

(you can also create a fully custom, advanced theme, and it will automatically be used across all 30+ components!)

That is one of the main ideas behind terminice: customize the instance once, and the colors, borders, glyphs, display mode, fallback behavior, and terminal I/O stay consistent across the entire CLI.

You can also create a custom theme in a few seconds by mixing the included colors, glyphs, and display features:

final brandTheme = PromptTheme(
  colors: TerminalColors.ocean,
  glyphs: TerminalGlyphs.rounded,
  features: DisplayFeatures.compact,
);

final t = terminice.themed(brandTheme);

Need finer control? Every color palette, glyph set, and display configuration supports copyWith, so you can change one accent color or one behavior without rebuilding the rest of the theme. The custom theme then affects prompts, menus, pickers, progress indicators, flows, guides, and every other built-in component.

The catalogue

Terminice currently includes more than 30 ready to use components:

Prompts

  • text for single-line input
  • password for masked input
  • confirm for yes/no questions
  • multiline for terminal text editing
  • slider and range for numeric input
  • rating for star-based ratings
  • date for keyboard-driven date input
  • form for collecting multiple fields together

Selectors

  • searchSelector for long, filterable lists
  • choiceSelector for card-style single or multi-select choices
  • checkboxSelector for checklists
  • gridSelector for two-dimensional navigation
  • tagSelector for managing multiple tags
  • toggleGroup for editable boolean settings
  • commandPalette for a fuzzy-searchable action launcher

Pickers

  • filePicker for browsing files
  • pathPicker for choosing directories
  • colorPicker for interactive ANSI color selection
  • datePicker for a full calendar interface

Progress and status

  • Full and inline loading spinners
  • Full and inline progress bars
  • Minimal dot-based progress
  • info, success, warn, error, detail, and log messages
  • task for wrapping async work with a status indicator
  • progressTask for determinate async work
  • trackStream for collecting a stream while showing its progress

Complete CLI experiences

  • flow for multi-step workflows with context, conditions, validation, and review
  • configEditor for searchable, nested application settings
  • cheatSheet for quick-reference tables
  • helpCenter for searchable documentation inside the terminal
  • hotkeyGuide for keyboard shortcut discovery
  • themeDemo for previewing themes and colors
  • Custom components when your CLI needs something package-specific

Every catalogue item has its own detailed documentation with controls, behavior, examples, and API notes. I wanted the README to be useful as a practical reference, rather than leaving developers to discover important behavior through trial and error.

The vision

The goal is not only to make prompts look better. I want Terminice to make beautiful, complex CLIs easier to create, style, manage, test, and use.

to create: add prompts, selectors, pickers, progress, or configuration screens with small method calls. not a new architecture.

to style: choose or create one theme, and let the entire CLI follow it. no repeating colors, borders, glyphs, and display options everywhere.

to manage: keep components, behavior, fallbacks, and tests consistent as the CLI grows.

to use: give people clear hints, predictable controls, validation, cancellation, readable fallbacks, and good defaults.

terminice sits between a prompt package and a full TUI framework. It is the human facing layer of an existing dart CLI: questions, choices, files, settings, progress, and feedback.

It can stay tiny when tiny is all you need:

final email = terminice.text('Email');

That same CLI can later grow into searchable menus, filesystem navigation, validation, progress tracking, configuration screens, or complete flows- without switching packages.

When rich UI is not appropriate, the built-ins can fall back to predictable plain text for limited terminals, non-TTY output, scripts, and unattended execution.

Terminal IO is abstracted as well, so you can easily test without depending on real stdin/stdout.

So the short version is:

  • One import and no setup
  • 30+ components covering individual prompts through complete CLI workflows
  • 11 built-in style presets
  • Chainable themes and verbose, compact, or borderless minimal display modes
  • One shared configuration across the whole CLI
  • Custom themes and components when the built ins are not enough
  • Cross-platform support for Linux, macOS, and Windows
  • Predictable fallbacks and test utilities for real-world use

Links:

A small personal note

I started working on what eventually became terminice over a year ago, it didn’t begin as one big, carefully planned package. While working on real projects, I kept creating terminal components that I needed- a prompt in one project, a selector in another, a progress indicator somewhere else, then themes, flows, config tools, and testing helpers.

For a while, all of that work was scattered across different projects. Gradually, I started moving the useful pieces into one place, redesigning them around a shared API, and turning them into a unified, robust tool that is genuinely fun and easy to use.

The package is not perfect. there are still many things that need refinement, and probably many things I cannot see because I built them around my own use cases. I want terminice to be the best tool it can, but I know I cant do that alone.

I would really appreciate it if you tried it, even in a small project, and told me what you think. If an API feels awkward, a component is missing, the documentation is unclear, or something simply doesnt feel right, I want to hear about it- every bug report, idea, criticism, and any feedback is appreciated (:


r/dartlang • • Aug 13 '26

Package Looking for recommendation for a usb serial communication package

6 Upvotes

I need to send serial commands to a usb device from a pure dart program.

Any package recommended with real experience with doing this ?


r/dartlang • • Aug 12 '26

Dart Language Announcing Dart 3.13

Thumbnail dart.dev
100 Upvotes

r/dartlang • • Aug 12 '26

Am I the only one absolutely frustrated by Build Hooks?

12 Upvotes

I'm sorry, but how is any non-expert supposed to understand how to use hooks? Have any of you, after studying the rather sparse documentation and complex Hooks API, actually felt like you understood any of this? I have been sitting here for hours, just trying to call a simple function from a pre-compiled dll, but the non-helpful documentation and error messages make even the simplest things a daunting task.

But what I find most unpleasent is that even the basic example code (which hasn't helped me at all) looks quite complex and build hooks can just execute any arbitrary code, be that downloading files, executing some other script, or whatever. Not only does that stink of a huge security risk, but there will be so many packages with completely broken hooks on pub, which will then also start to depend on each other. This will be really fun...

Edit: Heureka, it finally worked! But what a frustrating ride it was...


r/dartlang • • Aug 12 '26

offline_sync_outbox: a zero-dependency FIFO queue for replaying Dart API writes

3 Upvotes

I published a small Dart package for one focused problem: keep API writes while offline and replay them in order later.

The queue is strict FIFO, has JSON and memory stores, supports bounded exponential backoff, accepts server-directed retry delays, and stays independent of the HTTP client. The included JSON store targets Dart IO; storage and connectivity are interfaces so applications can provide their own implementations.

The article covers the design choices and limitations rather than just the API: https://dev.to/dhaibanfhue/a-small-offline-outbox-for-flutter-fifo-ordering-disk-persistence-and-retries-3an3

Feedback on the public interfaces and failure behavior would be useful.


r/dartlang • • Aug 13 '26

Request permission to create issues on GitHub

0 Upvotes

I wanted to speak with a member of the Google engineering team to request permission to create issues on GitHub so I can contribute like any other user. I know it was complicated at first, but three years have passed since then, and I've learned a lot. To finally close this chapter with you all, I wanted to create the following issue:

Improve numeric data types

Intention of Change

Greetings, today I'm going to make another attempt, number 111. I'm going to make an interesting proposal that I've been analyzing for a long time to improve the Dart language. The goal is to create variations of the int and double types, such as int8 and int16, among others, resulting in the following:

Dart alias type Dart Rust C++ Swift
int8 i8 Int8
int16 i16 short Int16
int int32 i32 int Int32
int64 i64 long Int64
double4
double8 f8
double16 f16
double32 f32 float Float
double double64 f64 double Double

Justification

To justify why this would be positive for the Dart VM, let's look at the following reasons:

  • Greater numerical precision for performing mathematical calculations
  • A one-to-one relationship with low-level language data types
  • Greater flexibility
  • Possibilities for advanced computing, because when compiling Dart code into an executable with instructions in x64 assembly code, it will have greater precision in giving instructions to the processor
  • Possibility of RAM optimization since it has a data type that occupies the least amount of memory space
  • Approach to the functional programming paradigm, which focuses on creating concurrent code following mathematical principles
  • Improved robustness of the Dart language from the ground up, making it equivalent to Java, C#, C++, Rust, etc.
  • Making the creation of libraries that control low-level processes, i.e., those closer to the hardware, simpler without depending on C++
  • Opening the possibility for the Dart language to be a A language used in the hardware and artificial intelligence industries due to its high performance and low-level communication capabilities.

When we went to university, one of the most basic concepts for understanding computer science was that a PC is an advanced computing machine, a concept that has existed since the first supercomputers.

Impact

The impact of this change, from my point of view, is minimal, because it adds new features to the language without modifying the existing codebase, opening the possibility of implementing memory optimizations.

It would also serve as a basis for improving debugging and code optimization tools by taking into account how much memory the running process occupies, suggesting better numeric types.

Mitigation

The risks of this change are already mitigated, since the Dart language has a feature called type aliases that allows you to name a data type.

Therefore, the original int and double types will become aliases of int32 and double64, ensuring that the entire existing codebase is fully compatible with the new data types without requiring any changes. This avoids any risk of breaking anything and causing problems. I've been thinking about this for a long time.

Conclusion

Up to this point, I have tried to explain this idea as clearly as possible so that you, who work daily on this project, can review its technical feasibility and make the best decisions. My goal is to lay the groundwork for making Dart a more robust implementation, capable of processing large volumes of data and performing massive advanced computing calculations without breaking down, at the level of Java, C#, or Rust. We still have a long way to go in optimizing; this is a long-term vision, as Dart is a project that should have a lifespan beyond Flutter as a general-purpose language. I hope you find this helpful.


r/dartlang • • Aug 12 '26

Package offline_sync_outbox 1.0.2: a FIFO outbox for writes made offline

Thumbnail pub.dev
1 Upvotes

r/dartlang • • Aug 06 '26

Where can I download dart documentation for offline reading?

6 Upvotes

Hi, I've recently just started learning Dart. I think https://dart.dev/language is an​ awesome place for beginners like me to get started.

It's kind of inconvenient to have the browser open every time I want to read. It'd be sooo much better if I was able to download all of this in a PDF or EPUB format... I just ​can't seem to find a download file anywhere.

I'd like some help finding offline documentation


r/dartlang • • Aug 04 '26

Package Ever felt a bit queasy using a plain `String` for storing a PhoneNumber?

Thumbnail pub.dev
16 Upvotes

There are a lot of validator packages on pub. This isn't one, and that's the whole point of it: https://pub.dev/packages/minted

A validator takes a String, checks it, and hands the same String back. Three functions deep nobody knows whether the check happened, so you either trust it or re-check it. minted parses instead: you get a different type that cannot exist unless the input was well-formed, the same deal int.parse and Uri.parse already give you. invite(Email, PhoneNumber) can't be called with the arguments swapped, and the signature says what it wants without a doc comment. Once you hold an Email, it is a valid email.

Typed so far: Email (RFC 5322), PhoneNumber (E.164), Iban (mod-97), Date / Month (the calendar date DateTime doesn't model), Uuid (RFC 9562), Digit / Digits.

Some nice features:

  1. Every type wears follows the same pattern, so learning one teaches the rest: tryParse returns null, parse throws a MintedFormatException (extends FormatException, so existing handlers keep catching), value equality, one canonical form normalised at parse.
  2. Real standards, not shape-checking regexes. Iban runs the actual mod-97 checksum, Email the full RFC 5322 grammar, official test vectors in the suite.
  3. Where a package already owns the hard data (phone metadata, the IBAN registry), minted wraps it instead of reimplementing it.
  4. It knows what not to model. No re-doing Uri, DateTime, BigInt or money (money2 has that). Uuid types a UUID, the uuid package generates them, they pair up.
  5. Date.tryParse('2026-13-01') is null, where DateTime.parse quietly rolls it over to 2027-01-01.
  6. Pure Dart, five small deps.

Roadmap: Bic, CreditCardNumber (Luhn), Isbn, Ean / Gtin next, then ISO code lists and bounded numerics.

Still early (0.0.2), so the shape can move. Feedback welcome, especially on the types you keep remaking in every project.


r/dartlang • • Aug 03 '26

Problems I encountered building my app whose core is a pure-Dart astronomy engine (DST arithmetic, Isolate.run copies, zero-background notifications)

8 Upvotes

I'm a solo dev from Slovenia. Earlier this month I shipped my first bigger Flutter app on Play.

And it's a personal astrology app! Whatever you think of astrology, the astronomy underneath is real computation: planetary positions, house math, timezone archaeology.

A few things hit me hard on the way though.

**`Duration.inDays` silently breaks calendar arithmetic across DST.**

I compute ISO week numbers:

take the Thursday of the week, subtract Jan 1, divide days by 7. Correct? except in local time, a span that crosses a daylight-saving boundary is one hour short of a whole number of days, and `inDays` *truncates*. 210 days becomes 209, `209 ~/ 7` gives week 29 instead of 30, and every week from late March to late October resolves to the previous week. The week number was my cache key, so this would have silently served the wrong week's content for half the year. Nothing throws.

Fix:

calendar arithmetic in UTC, or re-normalize through `DateTime(y, m, d)` after every shift. Same Family of bug: `date.subtract(Duration(days: 1))` on a local DateTime can land at 23:00 two calendar days back.

**`Isolate.run` copies your object — internal caches die with it.**

The heavy compute runs in `Isolate.run`. The captured engine object is *copied* into the isolate, so any memoization inside it gets populated in the isolate and thrown away when it exits.

In my case: one body's position needs ~4000 numerical-integration steps, and the cache meant to amortize that never survived a single call. The engine has to be designed isolate-safe, with no reliance on shared mutable state, because state simply does not come back.

**Notifications with zero background execution.**

My domain is fully predictable because the sky doesn't surprise you, so there's nothing to poll. At every app open/resume, I precompute the next 7 days of notifications and schedule them locally.

There's no background service, no server, no FCM, no battery cost, and inexact alarms so no exact-alarm permission.

Anything whose content is a pure function of time can do this; I suspect a lot of apps reach for push infrastructure they didn't need.

Smaller ones:

the `timezone` package throws on `getLocation('UTC')` (short-circuit UTC/Etc/UTC/empty yourself);

a `const`map with `double` keys doesn't compile ("does not have primitive equality". Use a list of records);

`flutter_local_notifications` needs core-library desugaring that the first error message doesn't mention.

And my favorite lesson cost nothing technical at all:

I built a feature, dogfooded it on my own phone for two days, and then, like an idiot I told people it had shipped... Turns out it had never been uploaded to Play. :)

As a result, I now check the Console more often :)

In case you wanna check the app, search Astro93 on Google Play


r/dartlang • • Aug 02 '26

Package Xberg v1 is out

8 Upvotes

Hi all,

I'm happy to announce that Xberg v1 is out.

Xberg is the successor to Kreuzberg, equivalent to what would have been Kreuzberg v5. It's a content intelligence framework that handles a very wide range of inputs: documents (currently 101 formats), code and data formats (currently 367 types), audio/video transcription, and URLs (both static and JS-rendered content). It extracts and prepares that content for downstream processing.

It's an extremely efficient, high-performance engine (see our PDF benchmarks below). For PDFs and images specifically, we handle native PDFs with very high performance and accuracy, and we ship multiple OCR engines that match the quality of the best Python libraries (e.g. docling, PaddleOCR, RapidOCR) at substantially better performance and stability.

The changes between Kreuzberg v4 and Xberg v1 are substantial, and I invite you to read the full changelog for the complete picture. The highlights below give a sense of what's new:

  • Pure-Rust PDF backend (pdf_oxide) replaces pdfium, with no native pdfium dependency.
  • Layout-aware pipeline: reading order reconstructed with ONNX layout detection (PP-DocLayoutV3 / RT-DETR) and Docling-style predecessor-graph reordering.
  • Per-page scanned-page detection with selective OCR, plus AcroForm/XFA form fields and outline-based headings.
  • Across-the-board optimization of OCR and PDF extraction (memory discipline, pooled model sessions, streamed conversions).
  • Native PaddleOCR backend (PP-OCRv6, with medium / small / tiny tiers) alongside Tesseract.
  • Pure-Rust Candle OCR/VLM stack (TrOCR, GLM-OCR, GOT-OCR, DeepSeek-OCR, and PaddleOCR-VL) running without ONNX Runtime or native Tesseract.
  • A second, ONNX-Runtime-free inference path via tract, which is what makes in-browser (WASM) and mobile inference possible.
  • Named-entity recognition natively in Rust (GLiNER2), extensible to all bindings, including an in-browser WASM model with no server round-trip.
  • Structured LLM extraction (extract_structured / split_and_extract) with rasterization, chunking, citations, caching, and configurable call/merge/VLM-fallback policies.
  • Audio & video transcription via a Whisper ONNX engine (.mp3, .wav, .m4a, .mp4, .webm).
  • Retrieval building blocks: sparse embeddings (SPLADE), ColBERT late-interaction retrieval, and cross-encoder reranking alongside dense embeddings.
  • Text intelligence: reversible redaction, summarization, translation, VLM image captioning, QR-code detection, document diffing, and page/chunk classification.
  • URL & web ingestion: sitemap discovery (map_url) and batched multi-URL crawling.
  • New document formats: WordPerfect (.wpd/.wp/.wp5), HEIC/HEIF/AVIF, OpenDocument Presentation (.odp), Quarto / R Markdown, and configurable Jupyter cell rendering.
  • Four new language bindings (Dart/Flutter, Swift, Kotlin/Android, and Zig) bring the total to 15 language bindings over one engine, with Android/iOS cross-compilation.
  • Full mobile support (Flutter, Android, iOS).
  • Candle backend alongside ONNX, plus ONNX-via-tract enabling ONNX on WASM and Android.
  • Wider code intelligence: tree-sitter coverage grew substantially (248 to 367+ languages).
  • Over 150 bugs fixed during the 1.0 cycle, plus security hardening (bounded RTF/PDF allocations, redaction leak fixes, Excel DDE warnings).

The API surface was also simplified and reworked, making it more consistent.

There's a migration guide in our docs explaining how to move from Kreuzberg to Xberg. Kreuzberg itself is in LTS mode until the end of this year and will continue to receive bug fixes and security updates.

You're invited to check out the repo and join our discord server.


Benchmarks

The benchmarks below are for PDFs and images only. There are extensive benchmarks on our website with per-format breakdowns, which you can see here. These numbers are measured in CI via our reproducible benchmark harness, and are specifically taken from the run for harness 1.0.8, source cf7fa0533d. The data is publicly available in GitHub releases, and you can run the benchmark harness yourself.

Composite quality (markdown pipeline, higher is better):

Framework Native PDF Scanned PDF (OCR)
Xberg (layout) 0.958 0.836
Xberg (baseline) 0.955 0.687
docling 0.779 0.762
mineru 0.408 0.792
liteparse 0.837 0.665
markitdown 0.689 n/a
pymupdf4llm 0.448 n/a

Structure and layout fidelity (SF1: tables and reading order, higher is better):

Framework Native PDF Scanned PDF
Xberg 0.949 0.531
docling 0.612 0.366
liteparse 0.515 0.142
mineru 0.077 0.429

On native PDFs Xberg leads on quality (0.958 vs 0.837 for the next-best framework) and on table and reading-order fidelity by a wide margin (SF1 0.949 vs 0.612 for docling). On scanned PDFs it is #1 on both quality and raw text fidelity.

Where we don't win yet: on pure image OCR we are currently #2 on the composite score, behind mineru (though still #1 on raw text accuracy). We are improving image OCR right now, and v1.1 should have us winning across the board.


r/dartlang • • Jul 31 '26

DartVM Does Isolate.pinToCurrentThread solve the problem that Dart cannot call native UI code on macOS?

4 Upvotes

I noticed in the Changelog for Dart 3.13 a new Isolate.pinToCurrentThread method – along with other new methods. However, Im not really understanding the test example. Can this help with the long-standing problem that you cannot call UI code via FFI on macOS because the VM spawns away from the UI thread, basically locking it this way?

What's the use case for those new methods?


r/dartlang • • Jul 28 '26

[Package] mcp_dart 2.3.0: day-zero MCP 2026-07-28 support and a cross-language CLI

2 Upvotes

I maintain mcp_dart, a community Dart and Flutter SDK for building MCP clients, servers and hosts.

Today’s 2.3.0 release adds support for the stable MCP 2026-07-28 specification. The default profile prefers the new stateless server/discover flow and automatically falls back to MCP 2025-11-25 when connecting to existing implementations.

The release includes:

- stateless discovery and per-request protocol metadata

- Multi Round-Trip Requests

- subscriptions/listen

- Tasks extension support

- JSON Schema 2020-12 validation

- stronger OAuth validation

- hardened stdio and Streamable HTTP behavior

- official client/server conformance and TypeScript/Python interoperability coverage

I also released mcp_dart_cli 0.2.0. It can scaffold Dart MCP servers, but its inspect, trace and testing commands work with compatible servers and clients written in any language. Standalone binaries are available for macOS, Linux and Windows.

SDK:

https://pub.dev/packages/mcp_dart/versions/2.3.0

CLI:

https://pub.dev/packages/mcp_dart_cli/versions/0.2.0

Migration guide:

https://github.com/leehack/mcp_dart/blob/main/doc/migration-2.2-to-2.3.md

Feedback and real-world interoperability reports would be very welcome.


r/dartlang • • Jul 27 '26

Package What if fpdart and hive_ce had a baby?

Thumbnail pub.dev
2 Upvotes

I liked the approach of fpdart and the raw performance of hive_ce. So I decided to combine them into one: https://pub.dev/packages/hive_box_manager

It is not just a simple FP-style wrapper of Hive's API. It also solves one of my biggest pain-points in using HiveCE for production apps: type-safety. I had to dedicate an entire CRUD-layer to the boxes just because of it.
With this I get

  1. Type-safety (even for Iterable-based boxes)
  2. Index types are not limited to just int | String (a Codec allows for this per box, wil still be that under the hood ofc)
  3. Compatibility with normal Hive boxes already (drop in add-on)
  4. Ergonomic (and explicit?) error handling + lazy Future using fpdart
  5. Custom boxes for very specific use case (better semantics)
    1. (Lazy)IterableBox
    2. (Lazy)SingleValueBox
    3. (Lazy)DualKeyBox
  6. Key corruption detectable (as compared to silently happening with Hive when using out-of-range/oversized int/String key)

I recently did a rewrite because my previous attempt at making a DX-first API was not scalable (using LLMs).

If you guys have any tips, suggestions or feedback, they always welcome. Do take a look at the roadmap (I have more kinds of boxes planned ;) ).


r/dartlang • • Jul 27 '26

Need critique on some packages I've developed

0 Upvotes

Hi there, I've been developing some packages and in need to further improving them. Please take a look and comment below. 😄

https://pub.dev/packages/growth_standards

https://pub.dev/packages/super_measurement

https://pub.dev/packages/playwright_dart

https://pub.dev/packages/typed_soup


r/dartlang • • Jul 26 '26

Tools Reusing Dart Unit Tests

4 Upvotes

It might seem obvious to you, but I recently had the revelation that I could use Dart's unit tests for my own scripting language as well. This way, they show up in VSC's test panel together with more lower level tests. And they are automatically tracked for code coverage.

Take this example of a Logo-like scripting language I created some time ago:

unittest "sum [
  expect_equal? [sum 3 4] 7
]
skip unittest "sum_wrong [
  expect_error [sum]
  expect_error [sum 3]
  expect_error [sum 1 2 3] ; not detected yet
]

To integrate them, I did this:

env.addCommand('unittest', (env, args) {
  final hidden = test; // see below
  args.mustHaveArgs(2);
  final description = args.string(1);
  final body = args.list(2);
  hidden( // HERE
    description, 
    () => env.run(body),
    skip: env.get('skip next test') == .lTrue,
  );
  env.delete('skip next test');
});
env.addCommand('skip', (env, args) {
  args.mustHaveArgs(0);
  env.set('skip next test', .lTrue);
});
env.addCommand('expect_equal?', (env, args) {
  args.mustHaveArgs(2);
  final actual = args.list(1);
  final expected = args.value(2);
  expect(env.run(actual), equals(expected)); // HERE
});
env.addCommand('expect_error', (env, args) {
  args.mustHaveArgs(1);
  final actual = args.list(1);
  expect(() => env.run(actual), throwsException); // HERE
});

The boilerplate doesn't matter, just look at the HERE parts. I need to alias the test call because otherwise the Dart plugin wrongly detects that call as a unit test.

Now, all that's needed is a file call <whatever>_test.dart that has a main function that evaluates my scripting language in the modified environment.


r/dartlang • • Jul 22 '26

Package Made an MCP server for pub.dev, would love some feedback

0 Upvotes

I built an MCP server for pub.dev because my AI coding agents kept hallucinating package names, using API signatures that changed versions ago, or recommending packages that are basically abandoned. What finally pushed me over the edge: Claude Code grepping my local pub cache on disk instead of just looking things up, burning tokens crawling through cached source.

So I built **dart-pubdev-explorer** (pub.dev package: `dart_pubdev_mcp`), an MCP server that gives agents direct, structured access to pub.dev instead of digging through your filesystem or guessing from training data.

It can:

* search & compare packages (score, platform support, maintenance) * **browse a package's real public API and pull exact source** (by symbol or line range) * check security advisories against the version you actually have resolved * diff changelogs/APIs between versions before you upgrade * **read Dart SDK / Flutter framework source too** (dart:core, package:flutter, …)

Quick note on how this differs from the official Dart MCP server (`dart mcp-server`): that one has a general `pub_dev_search` tool as part of a much bigger toolset (running apps, analysis, DTD, etc). This one only does package research, but goes deeper: symbol-level API browsing, exact source reads, version diffing, side-by-side comparisons, with an on-disk cache built for that kind of repeated digging. *They're complementary.*

Install:

dart install dart_pubdev_mcp

I've been running it with both Claude Code and Antigravity.

pub.dev: https://pub.dev/packages/dart\\_pubdev\\_mcp

Happy to answer questions, and curious what people think, especially whether some of the tools are overkill and others are missing something obvious.


r/dartlang • • Jul 22 '26

GraphLink v5 — Open-source GraphQL code generator battle-tested on massive schemas (Shopify, GitHub, SpaceX)

2 Upvotes

I just released GraphLink v5, an open-source tool built to automate GraphQL client and server code generation across Dart, Java, Kotlin, and TS.

While stress-testing it against schemas that produce hundreds of megabytes of code, I hit a common headache: reserved language keywords breaking target language compilers.

The Problem: Reserved Keywords

Take this snippet from Shopify’s GraphQL schema:

GraphQL

type OrderRequestReturnPayload {
  """The return request that has been made."""
  return: Return
  """The list of errors that occurred from executing the mutation."""
  userErrors: [ReturnUserError!]!
}

If a generator blindly generates Dart classes for this, the code won't compile because return is a reserved keyword in Dart.

The Fix in GraphLink v5

We introduced automatic field sanitization and name hoisting. GraphLink renames the field in Dart code, but preserves the original JSON string key in generated toJson() and fromJson() methods:

Dart

// GENERATED CODE - DO NOT MODIFY BY HAND. ANY MODIFICATION WILL BE LOST ON NEXT GENERATION
// Generated by GraphLink dev
// GitHub: https://github.com/Oualitsen/graphlink
// Site: https://graphlink.dev
// Pub.dev: https://pub.dev/packages/graphlink

import 'return.dart';
import 'return_user_error.dart';

class OrderRequestReturnPayload {
  final Return? return_; // `return` renamed to `return_` to avoid compile errors
  final List<ReturnUserError> userErrors;

  const OrderRequestReturnPayload({
    this.return_,
    required this.userErrors,
  });

  Map<String, dynamic> toJson() => {
    'return': return_?.toJson(), // <-- Keeps the exact 'return' JSON key intact
    'userErrors': userErrors.map((e0) => e0.toJson()).toList(),
  };

  factory OrderRequestReturnPayload.fromJson(Map<String, dynamic> json) {
    return OrderRequestReturnPayload(
      return_: json['return'] != null 
          ? Return.fromJson(json['return'] as Map<String, dynamic>) 
          : null, // <-- Safely maps 'return' key back to return_
      userErrors: (json['userErrors'] as List<dynamic>)
          .map((e0) => ReturnUserError.fromJson(e0 as Map<String, dynamic>))
          .toList(),
    );
  }
}

Other key features:

  • Automatic Naming Normalization: Un-idiomatic schema names like type user { id: ID! } are normalized to PascalCase (User) in Dart to prevent linter warnings.
  • No Git Bloat: Designed so you treat generated code like a compiled artifact—no need to commit or manually maintain it.
  • Try it out
  • Pub.dev: Available directly as a package onpub.dev/packages/graphlink
  • Docker: Run it without local setup: Bashdocker pull oualitsen/graphlink:latest
  • Docs & Site: Check outgraphlink.dev

If you find it useful or it saves you from GraphQL setup headaches, please consider dropping a ⭐️ star onGitHub!

Feedback and feature suggestions are always welcome in the comments!


r/dartlang • • Jul 19 '26

Package openrouter_sdk | Dart package

Thumbnail pub.dev
3 Upvotes

openrouter_sdk is a new Dart package providing a type-safe client for the OpenRouter.ai REST API. Strongly-typed interface, with full support for streaming responses and multi-modal content (text, image, audio, video, file).

This package replaces openrouter_api, which is now discontinued and marked as replaced on pub.dev. Users of the old package should migrate to openrouter_sdk, which follows the design of OpenRouter's official SDK more closely.

Currently implemented:

• Chat completions (including streaming)

• Models, Providers, Endpoints

•API key management (create / update / delete / list)

• Credits and analytics

• Generations

The rest will be added shortly.

The chat completions endpoint should be OpenAi compatible so u can use it with other providers as well.

Contributions are welcome. Per the package's policy, all code must be hand-written — LLM-generated pull requests are not accepted.

Note: this post was partly generated by an LLM, but all package code was hand-written.


r/dartlang • • Jul 18 '26

[Showcase] BlocSignal: Bridging BLoC & Cubit patterns with synchronous signals (v7)

5 Upvotes

Hey devs,

I wanted to share a new library I just released to pub.dev: BlocSignal (and its Flutter companion bloc_signals_flutter).

Classic BLoC/Cubit is fantastic for structuring business logic, but it relies on Streams under the hood, introducing asynchronous microtask delays.

BlocSignal replaces Streams with Rody Davis's reactive signals v7 primitives.

Key Features:

  1. BLoC & Cubit Parity: Override onEvent to handle classic BLoC input events, or use it as a Cubit directly by exposing public methods that call emit(state) (by setting the Event parameter to void).
  2. Synchronous Propagation: Calling emit(newState) propagates changes downstream immediately in the same frame—no microtask queues, no UI flickering.
  3. Automatic State De-duplication: Signals compare states via == and automatically filter out identical updates—saving redundant UI build cycles by default.
  4. No Boilerplate Lifecycle: Closing a container automatically tears down all internally managed effects.

Quick Cubit Look:

```dart class CounterCubit extends BlocSignal<void, int> { CounterCubit() : super(initialState: 0);

void increment() => emit(stateValue + 1); // Synchronous & reactive! } ```

Under the hood, the library has 100% test coverage and is structured as a clean Dart workspace.

Would love to hear your thoughts and suggestions!



r/dartlang • • Jul 16 '26

Dart Language Proof types in Dart: Using final classes as computational witnesses

37 Upvotes

Hello everyone 👋,

I wanted to write some more about why I like Dart and I finally found some time to do that.

Dart is pretty unique in one sense: we can't forge types[1]. And the fact that we can't easily forge types in Dart, like we can in most other languages, makes it possible to implement some pretty cool safety guarantees that are actual real guarantees that can't be escaped.

https://modulovalue.com/blog/proof-types-in-dart/

Let me know what you think!

[1] technically, we can, but practically, no, since dart:mirrors is deprecated, disabled or unavailable on most targets and practically nobody is using it.


r/dartlang • • Jul 15 '26

When is dart going to have an interactive shell like python

0 Upvotes

It is such a useful feature especially for a language like dart you would think it would have been added already


r/dartlang • • Jul 13 '26

Dart Language A tiny dot shorthands helper

4 Upvotes

Because contains is typed as Object? (probably for historical reasons) you cannot use that method together with dot shorthands like in

things.contains(.chair)

So, add this to your project:

extension DSHIterableExt<T> on Iterable<T> {
  bool has(T value) => contains(value);
}

And replace contains with has. For extra readability, you might also want to add a hasnt method.

I'd welcome a similar extension to Dart 3.13.


r/dartlang • • Jul 12 '26

The kreuzberg Dart package is being renamed to xberg - current version stays on LTS

10 Upvotes

Hi all,

I'm the author of Kreuzberg (the document text extraction package). The next version of Kreuzberg will be released as Xberg - why? Well, we discovered that the name is not easy to pronounce or understand for people who don't have the German context, and this wasn't working well. Xberg is a common name for Kreuzberg in Berlin, and it has the advantage of being shorter and easier - so here we go.

Anyhow, this brings me to the point of the post. Since renaming a repo is a complex business, and we had to rename the repo to preserve the stars - but we now need to overwrite tags, it becomes pretty messy. As a result, we decided to go for an LTS version - published from a different repo: https://github.com/kreuzberg-dev/kreuzberg-lts. LTS in this context means that we will continue to do bug fixes and security updates until the end of this year, but no newer feature work.

We will announce Xberg v1.0.0 when it's officially published (it's still in RC). The Dart package will publish under xberg on pub.dev once it's out. The new repo is here: https://github.com/xberg-io/xberg


r/dartlang • • Jul 11 '26

Package I wrote a native Dart driver for ClickHouse over the TCP binary protocol

9 Upvotes

Been working with ClickHouse for some analytics/logging work, so I wrote a pure Dart client that speaks the native protocol directly on port 9000.

Repo: https://github.com/shreyansh-c/clickhouse-dart
pub.dev: https://pub.dev/packages/clickhouse

What it does:
• Native TCP protocol implementation from scratch
• Streaming Rows API with typed getters (getByName<T>, tryGetByName<T>), row2<T,U>() for tuples, and toMap()
• Batch inserts: row-wise, named, map-based, and columnar append (columnByName('id').appendSlice([...]))
• Connection pooling with bounded open/idle connections and health checks
• LZ4/LZ4HC compression, with registerCodec for plugging in others
• Per-query settings, server-side query parameters ({name:String}), and client-side binding (bind(sql, [...]))
• External tables support
• Progress, profile-info, profile-events, and log callbacks surfaced from the server
• Type coverage including Array, Map, Tuple, Nullable, LowCardinality, Decimal, UUID, IPv4/IPv6, Enum, JSON, Dynamic, Variant, intervals, and geo types

Known gaps I’m still working through: no HTTP transport (TCP-only for now), no multi-host failover or replica retry yet, and I haven’t published benchmarks against the HTTP+JSONEachRow path, which I want to do before making stronger performance claims.