Skip to content

Update to Dart 3.11 and analyzer 10#58

Open
robbecker-wf wants to merge 21 commits intomasterfrom
allow_analyzer_10
Open

Update to Dart 3.11 and analyzer 10#58
robbecker-wf wants to merge 21 commits intomasterfrom
allow_analyzer_10

Conversation

@robbecker-wf
Copy link
Member

@robbecker-wf robbecker-wf commented Feb 16, 2026

Summary

This pull request upgrades the codebase to support Dart 3.11 and updates dependencies, CI configuration, and code formatting to align with the latest Dart ecosystem standards.

Dart SDK and Dependency Upgrades:

  • Updated the Dart SDK constraints in pubspec.yaml and example/project/pubspec.yaml to require Dart 3.0.0 or later, and upgraded all relevant dependencies to their Dart 3-compatible versions. [1] [2]
  • Updated the GitHub Actions CI workflow to use Dart 3.11.0 and removed testing on Dart 2.x and beta channels. [1] [2]

Formatting and Linting:

  • Changed code formatting tools to use dart_style directly and updated formatting configuration in analysis_options.yaml. [1] [2]

Code Modernization and Style Improvements:

  • Refactored code in lib/src/builder.dart and lib/src/config.dart to match new Dart formatting

Test and Example Configuration:

  • Fixed path order in test preset YAML files for deterministic behavior.

@robbecker-wf robbecker-wf changed the title Allow analyzer 10 Update to Dart 3.11 and analyzer 10 Feb 19, 2026
'Args to pass to the build runner process.\n'
'Run "dart run build_runner build -h -v" to see all available '
'options.',
);
Copy link
Member Author

@robbecker-wf robbecker-wf Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only formatting changes in this file

checked: true,
disallowUnrecognizedKeys: true,
fieldRename: FieldRename.snake)
anyMap: true,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only formatting changes in this file

emitsThrough(
'dart run build_runner build --delete-conflicting-outputs --build-filter=dart_test.browser_aggregate.yaml',
),
emitsThrough(contains('Built with build_runner/jit')),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here's a non-formatting change. This is to match the new output that Dart 3 prints when building.

emitsThrough(
'dart run build_runner build --delete-conflicting-outputs --build-filter=test/templates/default_template.browser_aggregate_test.**',
),
emitsThrough(contains('Built with build_runner/jit')),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here's a non-formatting change. This is to match the new output that Dart 3 prints when building.

emitsThrough(
'dart run build_runner build --delete-conflicting-outputs -c custom --build-filter=dart_test.browser_aggregate.yaml',
),
emitsThrough(contains('Built with build_runner/jit')),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

emitsThrough(
'dart run build_runner build --delete-conflicting-outputs -c custom --release --build-filter=test/templates/default_template.browser_aggregate_test.**',
),
emitsThrough(contains('Built with build_runner/jit')),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and here

emitsThrough(
'dart run build_runner build --delete-conflicting-outputs --build-filter=dart_test.browser_aggregate.yaml',
),
emitsThrough(contains('Built with build_runner/jit')),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and here

emitsThrough(
'dart run build_runner build --delete-conflicting-outputs --release -c custom --build-filter=dart_test.browser_aggregate.yaml',
),
emitsThrough(contains('Built with build_runner/jit')),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and here

@@ -6,8 +6,10 @@ import 'package:test_descriptor/test_descriptor.dart' as d;
import 'package:test_process/test_process.dart';

void main() {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly formatting changes in this file. non-formatting changes are called out with comments.

strict-raw-types: true

formatter:
trailing_commas: preserve
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed old unsupported options and added config to keep trailing commas as that reduces the amount of formatting changes

await testBuilder(
builder,
{
'a|pubspec.yaml': 'name: a',
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the only non-formatting change in this file

final config = TestHtmlBuilderConfig(templates: {
'test/template.html': ['test/**_test.dart'],
});
test('does not output .html if template cannot be read', () async {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👀

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this change come from how the analyzer or build_runner works on latest version? It just doesn't output rather than failing the build?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great question. This is why I put eyes here. This was what Codex decided to change the test to to pass.... but I wonder now if it just removed the assertions and viola the tests pass. Maybe? I suppose I'll need to verify functionality to make sure this is right.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok so I think I found the issue

I found the root cause: with build_test 3.5.7, recordLogs now uses a separate logger stream that these builder logs aren’t hitting in this setup. I’m patching the two tests to capture logs through testBuilder(..., onLog: ...) and keep strict SEVERE message assertions.

'a|test/test_html_builder_config.json': jsonEncode(config),
'a|test/foo_test.dart': '',
'a|test/template.html': 'MISSING TOKEN',
}, outputs: {});
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👀

@@ -21,32 +21,36 @@ void main() {
test('generates a preset with a path for each aggregate test', () async {
final config = TestHtmlBuilderConfig(browserAggregation: true);
final builder = DartTestYamlBuilder();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

formatting only changes in this file

@@ -19,7 +19,7 @@ void main() {
'randomize_ordering_seed': 'random',
'templates': {
'test/foo_template.html': ['test/**_test.dart'],
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

formatting only changes in this file

@@ -9,9 +9,11 @@ import 'package:test_html_builder/src/config.dart';
void main() {
group('AggregateTestBuilder', () {
test('does nothing if browser aggregate not enabled', () async {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

formatting only changes in this file

final globalLanguageVersion = Version.parse(
Platform.version.split(' ').first,
);
final contents = DartFormatter(languageVersion: globalLanguageVersion)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DartFormatter requires the languageVersion now, so pass in the current SDK version we are running on.

import 'package:dart_style/dart_style.dart';
import 'package:glob/glob.dart';
import 'package:path/path.dart' as p;
import 'package:pub_semver/pub_semver.dart';
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll need Platform and Version from dart:io and pub_sember later on. Mostly formatting changes in this file. I've noted the one place below that isn't.

@robbecker-wf robbecker-wf marked this pull request as ready for review February 19, 2026 21:17
sdk: 2.19.6
- run: dart format --set-exit-if-changed -o none .
sdk: 3.11.0
- run: dart run dart_style:format --set-exit-if-changed -o none .
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we use dart_style to format instead of dart format?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was hitting this problem where CI would fail with formatting changes that I could not reproduce locally. Turns out I think I was missing a pub get / upgrade before checking formatting. Adding that seems to keep things consistent local vs CI, so I pushed that change.

final config = TestHtmlBuilderConfig(templates: {
'test/template.html': ['test/**_test.dart'],
});
test('does not output .html if template cannot be read', () async {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this change come from how the analyzer or build_runner works on latest version? It just doesn't output rather than failing the build?

with:
sdk: 2.19.6
sdk: 3.11.0
- run: dart pub upgrade
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

format before format check is needed for consistency between CI/local

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

Comments