Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move away from linted/deprecated Map constructor #6450

Merged
merged 2 commits into from
Feb 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions examples/misc/test/language_tour/generics_test.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// ignore_for_file: argument_type_not_assignable, prefer_collection_literals
// ignore_for_file: type_annotate_public_apis
import 'dart:collection';

import 'package:examples/language_tour/generics/base_class.dart';
import 'package:test/test.dart';

Expand All @@ -9,14 +11,14 @@ void main() {
var names = <String>[];
names.addAll(['Seth', 'Kathy', 'Lars']);
// #docregion constructor-1
var nameSet = Set<String>.from(names);
var nameSet = Set<String>.of(names);
// #enddocregion constructor-1
expect(nameSet.length, 3);
});

test('constructor-2', () {
// #docregion constructor-2
var views = Map<int, View>();
var views = SplayTreeMap<int, View>();
// #enddocregion constructor-2
expect(views.length, 0);
});
Expand Down
8 changes: 4 additions & 4 deletions src/content/language/generics.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,15 @@ angle brackets (`<...>`) just after the class name. For example:

<?code-excerpt "misc/test/language_tour/generics_test.dart (constructor-1)"?>
```dart
var nameSet = Set<String>.from(names);
var nameSet = Set<String>.of(names);
```

The following code creates a map that has integer keys and values of
type View:
The following code creates a `SplayTreeMap` that has
integer keys and values of type `View`:

<?code-excerpt "misc/test/language_tour/generics_test.dart (constructor-2)"?>
```dart
var views = Map<int, View>();
var views = SplayTreeMap<int, View>();
```


Expand Down