Sr. Content Developer at Microsoft, working remotely in PA, TechBash conference organizer, former Microsoft MVP, Husband, Dad and Geek.
165398 stories
·
33 followers

Stop Hand-Writing Your Flutter Network Layer: vexana 6 + AI Skills

1 Share

A typed, testable networking layer on top of dio, and AI skills that write it for you

https://pub.dev/packages/vexana

Every Flutter app has the same chore hiding in it: the network layer. A Dio instance, a base URL, an error model, a model class per endpoint with fromJson and toJson, a service that wraps the calls, and — if you are disciplined — tests with fixtures and mocks.

None of it is hard. All of it is repetitive. And in 2026 it is exactly the kind of work you should not be typing by hand.

This post covers four things:

  1. Why vexana: what it handles for you that plain dio doesn’t.
  2. Building a user list, step by step, from model to screen.
  3. The live playground, so you can try it without installing anything.
  4. The new vexana AI skills: four skills your AI assistant can follow to set up the layer, turn JSON into models, services, fakes and tests, and migrate old projects.

1. Why vexana?

vexana is a networking layer for Flutter built on dio. You keep everything dio gives you (interceptors, adapters, CancelToken, FormData) and stop rewriting the parts every app ends up needing.

Where does the name come from? Vexana is a hero in Mobile Legends, and the one I loved playing the most. When I was writing a library whose whole job is to pull data in from the network, her name was the first thing that came to mind, and it stuck.

Typed models and a sealed result

You parse into your own classes, not Map<String, dynamic>, and every request returns a NetworkResult: either NetworkSuccessResult with your data or NetworkErrorResult with the error. It's a sealed class, so a switch that forgets the error case doesn't compile.

final result = await manager.sendRequest<User, List<User>>(
'/users',
parseModel: const User(),
method: RequestType.GET,
);

final message = switch (result) {
NetworkSuccessResult(:final data) => '${data.length} users',
NetworkErrorResult(:final error) => 'Failed: ${error.description}',
};

Prefer callbacks? result.fold(onSuccess: ..., onError: ...) does the same.

Refresh tokens without the race conditions

When a request comes back 401, vexana calls your onRefreshToken callback and retries the original request with the new token. 401s are handled one at a time in a queue, so parallel requests don't race each other with half-refreshed tokens; once the token is refreshed, they all go through. If the retried request still fails after maxRetryCount attempts, onRefreshFail runs, which is where you send the user back to login.

final manager = NetworkManager<EmptyModel>(
options: BaseOptions(baseUrl: 'https://api.example.com'),
onRefreshToken: (error, newService) async {
final token = await authRepository.refresh(newService);
error.requestOptions.headers['Authorization'] = 'Bearer $token';
return error;
},
onRefreshFail: () => router.goToLogin(),
maxRetryCount: 3,
);

newService is a separate manager without the refresh interceptor, so your refresh call can't end up refreshing itself.

Your API’s error body, parsed

Give the manager your error model and error responses are parsed into it, so the UI reads error.model?.message instead of digging through a raw response.

final manager = NetworkManager<ApiError>(
options: BaseOptions(baseUrl: 'https://api.example.com'),
errorModel: const ApiError(),
);

Cache with one parameter

Pass a fileManager (LocalFile or LocalPreferences) to the manager, then add expiration to any request. Until it expires, the same request is answered from the cache: no network call, typically in about a millisecond. cache.removeAll() clears it, for example on logout.

final manager = NetworkManager<EmptyModel>(
options: BaseOptions(baseUrl: 'https://api.example.com'),
fileManager: LocalFile(), // or LocalPreferences()
);

await manager.sendRequest<User, List<User>>(
'/users',
parseModel: const User(),
method: RequestType.GET,
expiration: const Duration(minutes: 10),
);
await manager.cache.removeAll(); // e.g. on logout

No-network retry, built in

Pass noNetwork: NoNetwork(context) and a request that fails for lack of a connection shows a bottom sheet with a retry button. You can supply your own widget with customNoNetwork.

NetworkManager<EmptyModel>(
options: BaseOptions(baseUrl: 'https://api.example.com'),
noNetwork: NoNetwork(
context,
customNoNetwork: (onRetry) => TextButton(
onPressed: onRetry,
child: const Text('No connection. Try again'),
),
),
);

And the rest

A request logger (isEnableLogger), file upload with FormData, downloads with progress, CancelToken support, and it runs on mobile and on the web, including WebAssembly.

final manager = NetworkManager<EmptyModel>(
options: BaseOptions(baseUrl: 'https://api.example.com'),
isEnableLogger: true,
);

// Upload
await manager.uploadFile<Map<String, dynamic>>(
'/avatar',
FormData.fromMap({'file': await MultipartFile.fromFile(filePath)}),
);
// Download with progress
await manager.downloadFile(
'/report.pdf',
(received, total) => print('$received / $total'),
);
// Cancel
final cancelToken = CancelToken();
manager.sendRequest<User, List<User>>(
'/users',
parseModel: const User(),
method: RequestType.GET,
cancelToken: cancelToken,
);
cancelToken.cancel();

2. Let’s build a user list, step by step

Let’s fetch users from JSONPlaceholder and show them in a list.

Step 1: Describe the data

A response model extends INetworkModel<T>, which tells vexana how to parse it:

final class User extends INetworkModel<User> {
const User({this.id, this.name, this.email});

factory User.fromMap(Map<String, dynamic> json) => User(
id: json['id'] as int?,
name: json['name'] as String?,
email: json['email'] as String?,
);
final int? id;
final String? name;
final String? email;
@override
User fromJson(Map<String, dynamic> json) => User.fromMap(json);
@override
Map<String, dynamic> toJson() => {'id': id, 'name': name, 'email': email};
}

Step 2: Create one manager

final INetworkManager<EmptyModel> manager = NetworkManager<EmptyModel>(
options: BaseOptions(baseUrl: 'https://jsonplaceholder.typicode.com'),
fileManager: LocalPreferences(),
);

EmptyModel means "this API has no error body to parse". LocalPreferences enables the cache.

Step 3: Fetch the users

Future<NetworkResult<List<User>, EmptyModel>> fetchUsers() =>
manager.sendRequest<User, List<User>>(
'/users',
parseModel: const User(),
method: RequestType.GET,
expiration: const Duration(minutes: 5),
);

The first type argument is the model to parse, and the second is what you get back: List<User> because /users returns a JSON array. With expiration, calls in the next five minutes come from the cache.

Step 4: Show them on screen

FutureBuilder(
future: _users, // = fetchUsers()
builder: (context, snapshot) => switch (snapshot.data) {
null => const Center(child: CircularProgressIndicator()),
NetworkSuccessResult(:final data) => ListView.builder(
itemCount: data.length,
itemBuilder: (context, index) => ListTile(
leading: CircleAvatar(child: Text('${data[index].id}')),
title: Text(data[index].name ?? ''),
subtitle: Text(data[index].email ?? ''),
),
),
NetworkErrorResult(:final error) => Center(
child: Text('Error ${error.statusCode}: ${error.description}'),
),
},
)

The switch covers loading (null), success and error, and the compiler checks that none is missing.

The result

the user list running in the browser

Notice what is not there: no jsonDecode, no try/catch around the request, no Map<String, dynamic> in the UI. The package's example has the same pattern as a complete page, with pull-to-refresh.

3. Try it in your browser: the playground

Reading about a networking library only gets you so far. The vexana playground is a Flutter Web app (compiled to WebAssembly) that runs the real package:

👉 https://vb10.github.io/vexana/

  • Pick an endpoint and send a request.
  • Turn on Cache, set the expiration, and send the same request again. The first call goes to the network (around 400 ms); the second comes back from the cache in about 1 ms and is marked cache hit.
  • Turn on the Logger to see what vexana does under the hood.
  • The Session metrics table shows count, p50, p95, max, errors and cache hits for each endpoint, with network and parse time listed separately.

It’s the quickest way to see how the options behave before you add the package to your app.

4. Let your AI assistant write the boilerplate: vexana AI skills

This is the part I’m most excited about.

You could ask an AI assistant to “write a vexana model for this JSON” and hope for the best. Sometimes you’d get the old API, sometimes a model that doesn’t compile, and almost never tests.

So vexana now ships AI skills: a set of playbooks written by the package maintainers. Each skill contains the exact vexana 6 API, templates that have been compiled and tested, and a procedure that ends by running dart analyze and flutter test. The assistant doesn't improvise the layer; it follows a playbook.

The skills are plain Markdown files (SKILL.md), so they aren't tied to one tool.

Install

Claude Code has a ready-made plugin:

/plugin marketplace add VB10/vexana
/plugin install vexana@vexana

Other AI assistants (Cursor, GitHub Copilot, Codex, Gemini CLI, …): copy the plugins/vexana/skills folder into your project and ask the assistant to follow a skill, for example "follow skills/add/SKILL.md for this JSON".

There are four skills. The examples below use Claude Code’s command syntax; with another assistant, describe the same request in plain words.

/vexana:init: set up the layer

/vexana:init base URL https://api.example.com, cache LocalFile

It reads your project first and puts files where your structure expects them. If you already have lib/product/… or lib/core/…, it uses that instead of inventing a new layout. Then it:

  • adds vexana and mocktail (dev),
  • creates a single AppNetworkManager whose base URL can be overridden with --dart-define=BASE_URL=...,
  • generates an error model if you paste an error response,
  • adds a small fixture helper for tests.

Run it twice and nothing changes. It never overwrites your files.

/vexana:add: JSON in, typed code out

/vexana:add GET /posts and GET /posts/{id}, feature post, JSON in api/posts.json

From one JSON sample you get:

  • a Post model (nested objects become their own classes),
  • a PostService behind an IPostService interface, using sendRequest,
  • the sample saved as a test fixture,
  • a round-trip test: fixture → fromJson → toJson → same JSON.
@override
Future<NetworkResult<List<Post>, EmptyModel>> fetchPosts() {
return _manager.sendRequest<Post, List<Post>>(
'/posts',
parseModel: const Post(),
method: RequestType.GET,
);
}

It also handles the awkward parts of real APIs:

  • Keys like class, default, 2fa or user-name become valid Dart fields (class_, default_, n2fa, userName), while the original JSON keys are kept for parsing.
  • 1 in one element and 1.5 in another means double.
  • An empty array or a field that is always null is typed as Object?, and the report lists it so you can decide the real type instead of the tool guessing.

/vexana:multiple-add: a whole API at once

Point it at a folder of JSON responses:

/vexana:multiple-add api_samples/ — GET /posts, GET /users, GET /comments, GET /companies

It first shows a plan (model, feature, endpoint) and waits for your OK. Then, for each feature, it writes:

  • the model(s), with shared types deduplicated: if users.json has a nested company and companies.json has the same shape, you get one Company class;
  • the service and its interface;
  • a Fake service with a few embedded sample items, so you can build UI before the backend is ready;
  • mocktail service tests (success and error for every method) and model tests.

In my test run, four JSON files became 20 files and 16 passing tests, with dart analyze reporting no issues.

/vexana:refactor: bring old projects to vexana 6

/vexana:refactor

For projects on vexana 4.x or 5.x, it:

  • runs your tests first to record a baseline,
  • shows the planned changes and asks before touching anything,
  • bumps the dependency and fixes imports that no longer exist,
  • flags the calls whose behaviour changed, with an explanation. For example, removeAll() now clears only that manager's cache, and sendPrimitive now runs through your interceptors.

At the end it compares your tests against the baseline, so a regression isn’t mistaken for a failure that was already there.

Why skills and not just a prompt?

Because the skills already contain the parts you would otherwise have to check yourself:

  • The right API. The skills carry a reference of the vexana 6 surface, so there are no hallucinated methods.
  • Tested templates. Every template was compiled and tested in a real Flutter project before it went into the plugin.
  • Verification. Every command ends with dart analyze and flutter test, and reports failures as they are instead of claiming success.
  • Safe defaults. It asks before overwriting, asks on name collisions, and waits for confirmation on bulk changes.

Get started

If the skills save you an afternoon of boilerplate, a star on GitHub helps other Flutter developers find it. And if a skill generates something you’d write differently, open an issue: the templates are plain Markdown and easy to improve.


Stop Hand-Writing Your Flutter Network Layer: vexana 6 + AI Skills was originally published in Flutter Community on Medium, where people are continuing the conversation by highlighting and responding to this story.

Read the whole story
alvinashcraft
15 seconds ago
reply
Pennsylvania, USA
Share this story
Delete

Crashlytics for web is now in public preview

1 Share
Firebase Crashlytics now supports web apps: JavaScript error monitoring for Next.js, React, and Angular, with stack traces that point to the exact line.
Read the whole story
alvinashcraft
26 seconds ago
reply
Pennsylvania, USA
Share this story
Delete

scroll-state()

1 Share

The CSS scroll-state() query, surprisingly, has nothing to do with whether you’re doom-scrolling in a state of existential dread. It does, however, allow you to change the CSS used based on scrolling behavior.


scroll-state() originally handwritten and published with love on CSS-Tricks. You should really get the newsletter as well.

Read the whole story
alvinashcraft
1 minute ago
reply
Pennsylvania, USA
Share this story
Delete

Hybrid intelligence on the Web: Introducing Aion Instruct and Prompt API in Microsoft Edge

1 Share
Rapidly evolving AI capabilities are redefining what sites can do for users on the web. With on-device AI in Microsoft Edge, sites can use task-specific and small language models for capabilities such as writing assistance, summarization, language detection, translation, and speech recognition. Through the Prompt API, they can also use a small language model for more general-purpose intelligence. Together, these capabilities provide a foundation for hybrid intelligence on the web: developers can leverage on-device AI models when they are available in the browser and well-suited, and switch to a configured cloud provider to extend device coverage or access more powerful inference when needed. To make on-device inference more broadly available, we're introducing three updates today:
  • General availability of Aion Instruct as an open-weights model on Hugging Face, and as Microsoft Edge's built-in small language model.
  • An origin trial for the Prompt API, so you can use the Prompt API and Aion Instruct on your live site today.
  • A developer preview of an experimental Decisions API, which gets you fast, structured answers about text.
These announcements build on our earlier developer preview of Aion-1.0-Instruct. Since then, we've heard from early adopters, incorporated your feedback, and refined the model's training to improve quality and performance for on-device AI needs on the web.

Aion Instruct is now generally available in Edge

Aion Instruct is available today as an open-weights model on Hugging Face and is coming to Windows later this year, laying the foundation for richer on-device AI experiences across Windows and Copilot+ PCs. In Microsoft Edge, Aion now replaces Phi-4-mini as the browser's built-in small language model. At 2.3B parameters, Aion is smaller, faster, and available on many more devices than Phi, while delivering comparable quality for common web tasks such as text synthesis and generation, summarization, instruction following, and structured outputs. Edge downloads Aion Instruct only when a site or feature first needs it, and only on devices that can run it well. Users stay in control and can turn off on-device AI in Edge settings, which removes the model and stops future downloads.

Test the Prompt API on your live site

Until now, the Prompt API has been available as a developer preview only in Edge Canary and Dev channels. Now, with the Prompt API origin trial, you can call the API from your live site in Microsoft Edge and test it with a much broader audience. The origin trial lets you bring on-device AI features to your site, evaluate them under real-world conditions, and refine your implementation based on actual usage. Along the way, please share feedback on the API's design, the model's performance, and any interoperability challenges you encounter across different browsers and models. This will help inform discussions with other browser vendors and the web community as the Prompt API is considered for standardization. To get started, register for the Prompt API Origin Trial, read the developer documentation, try out the playground sample, and engage with us on the GitHub discussion about the API.

Developer preview of the Decisions API

We're also exploring new uses for on-device AI with an early implementation of the experimental Decisions API, powered by Aion Instruct. It is available as a developer preview in Edge Canary and Dev channels for prototyping. Expect both the API and its implementation to change as we learn from developer feedback. The Decisions API enables sites to ask yes/no, multiple-choice, or scoring questions about text input and get back probabilities and a confidence value, computed in a single pass without any text generation. For instance, you can use the Decisions API to understand a user's intent and act on it, sort and route user-generated content, or score and rank items in real-time, all with a few lines of client-side JavaScript code:
// Ask three questions about a product review in a single pass
const model = await DecisionModel.create({
  "context": "Customer reviews for an online electronics store",
  "questions": [
    {
      "id": "topic",
      "type": "choice",
      "prompt": "What is the review mainly about?",
      "options": [
        { "label": "quality", "description": "How the product works or feels" },
        { "label": "shipping", "description": "Delivery, packaging, or delays" },
        { "label": "price", "description": "Cost or value for money" }
      ]
    },
    {
      "id": "rating",
      "type": "score",
      "prompt": "How satisfied is the customer, from 1 to 5?"
    },
    {
      "id": "needs_reply",
      "type": "boolean",
      "prompt": "Is the customer asking for help?"
    }
  ]
});

// Get a label, probabilities, and a confidence value for each question
const result = await model.decide(
  "Love the headphones, but the box arrived crushed. Can I get a replacement?"
);
https://youtube.com/watch?v=v7mzf5u1SQQ To experiment with the Decisions API, read the explainer and developer documentation, try the playground sample, and share your thoughts on GitHub.

Try it out and let us know

These updates are another step toward bringing hybrid intelligence to the web, giving developers more options to use on-device AI when it's well-suited and combine it with cloud inference when needed. With Aion Instruct now smaller, faster, and more broadly available, we're excited to see the new web experiences you'll build. We're actively looking for feedback on model performance and interoperability for the Prompt and Summarizer APIs. If you try the experimental Decisions API, let us know what you're building, if the API design works for you, and whether your latency requirements warrant a smaller model. We look forward to you testing the Prompt API using the Origin Trial, checking out the developer documentation and playground samples, and sharing your feedback with us on GitHub.
Read the whole story
alvinashcraft
1 minute ago
reply
Pennsylvania, USA
Share this story
Delete

PIX 2611.19 – misc bug fixes and improvements

1 Share

Today we released PIX 2611.19 which can be downloaded here. This release includes everything in the previous 2610.28 release, plus the bug fixes and improvements listed below.

Thank you to everyone who reported issues and suggestions to us. Please keep them coming! The best ways to contact us are via the DirectX Discord and via the Send Feedback buttons in PIX.

GPU Captures

  • Various performance improvements when using Tiled Resources
    • Including fixing severe frame rate drops in some scenarios
  • Raytracing improvements
    • Greatly reduce GPU capture time and memory usage in applications with many raytracing acceleration structures
    • Fix stalls in application Release() calls during GPU capture of raytracing applications
  • Shader Debugger: fix crash when debugging a Dispatch that uses a pipeline state stream PSO
  • GPU Counters
    • Fix plugin counter columns showing the wrong counter name after a plugin update
    • Fix engine crash when a GPU plugin fails during counter collection
  • VS Output: fix crash when getting VS output for draws inside an outstanding query
  • Texture Viewer: show YUV textures (NV12, P010, AYUV, Y410 etc.) as RGB instead of luma only
  • Fix debug layer warning during capture caused by the initial state of an internal PIX buffer
  • Fix crash when replaying DXBC captures on GPUs that require DXIL conversion
  • Timeline: color GPU wait events orange to make them easier to spot
  • Custom Visualizers: fix occasional crash when a visualizer includes another file

Shader Explorer

  • Use the offline compiler installed with your driver for live profiling, so profiling still works when PIX’s bundled compiler doesn’t match the driver
  • Support hex input in pipeline state fields

Timing Captures

  • Much faster opening of large captures with GPU timing data
  • Fix missing resources when the D3D runtime reuses an object’s address
  • Fix GPU timeline ordering of command lists with identical start times

Misc

  • Fix black title-bar tabs on systems that use a decimal comma (e.g. French, Polish, German)
  • Fix vague errors (e.g. “0x8ABC0001”) shown instead of actionable errors (e.g. Developer Mode message)
  • System Monitor: fix race condition that could cause some counters to never appear
  • DirectX Dump Files: update NVIDIA plugin to fix incorrect memory access types reported for page faults
  • Remote PC: fix crash when connecting to a remote PC from ARM64 PIX
  • Text Editor: add an option to turn off highlighting of word occurrences

The post PIX 2611.19 – misc bug fixes and improvements appeared first on PIX on Windows.

Read the whole story
alvinashcraft
1 minute ago
reply
Pennsylvania, USA
Share this story
Delete

Datadog LLM Observability: Features, Pricing, and Alternatives

1 Share
Datadog LLM Observability: Features, Pricing, and Alternatives

If you’re evaluating Datadog LLM Observability, you’ll want to know how it fits alongside your existing application performance monitoring (APM) tools and what it costs as your LLM applications scale.

Read the whole story
alvinashcraft
2 minutes ago
reply
Pennsylvania, USA
Share this story
Delete
Next Page of Stories