Skip to content

Commit

Permalink
update to Dart SDK 3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
greensopinion committed Dec 29, 2024
1 parent 9441687 commit d38d4ec
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 27 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## 5.2.2
## 6.0.0

* add `raster-resampling` to raster layer
* require Dart SDK minimum version 3.0

## 5.2.1

Expand Down
2 changes: 1 addition & 1 deletion lib/src/features/icon_renderer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class IconRenderer extends SymbolIcon {
.reduce((a, b) => a.expandToInclude(b));
final contentArea = segments
.map((e) => e.contentArea)
.whereNotNull()
.nonNulls
.firstOrNull
?.translate(renderedArea.left, renderedArea.top) ??
renderedArea;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/themes/paint_factory.dart
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class PaintStyle {
return null;
}
if (opacity != null && opacity < 1.0) {
color = color.withOpacity(opacity);
color = color.withAlpha((255.0 * opacity).round());
}
double? strokeWidth;
if (paintingStyle == PaintingStyle.stroke) {
Expand Down
4 changes: 1 addition & 3 deletions lib/src/themes/sprite_reader.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import 'dart:convert';

import 'package:collection/collection.dart';

import '../logger.dart';
import 'sprite.dart';

Expand All @@ -13,7 +11,7 @@ class SpriteIndexReader {
SpriteIndex read(Map<String, dynamic> json) {
return SpriteIndex(Map.fromEntries(json.entries
.map((e) => _readSprite(e))
.whereNotNull()
.nonNulls
.map((e) => MapEntry(e.name, e))));
}

Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version: 5.2.2
homepage: https://github.com/greensopinion/dart-vector-tile-renderer

environment:
sdk: ">=2.17.0 <4.0.0"
sdk: ">=3.0.0 <4.0.0"
flutter: '>=3.2.0'

dependencies:
Expand Down
44 changes: 24 additions & 20 deletions test/src/themes/color_parser_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,28 @@ void main() {
test('parses a hex RGB color', () {
final color = ColorParser.toColor('#90d86c');
expect(color, isNotNull);
expect(color!.alpha, 0xff);
expect(color.red, 0x90);
expect(color.green, 0xd8);
expect(color.blue, 0x6c);
expect(color!.a, 1.0);
expect(color.r.toColorChannel(), 0x90);
expect(color.g.toColorChannel(), 0xd8);
expect(color.b.toColorChannel(), 0x6c);
});

test('parses an RGB color', () {
final color = ColorParser.toColor('rgb(239, 238,12)');
expect(color, isNotNull);
expect(color!.alpha, 0xff);
expect(color.red, 239);
expect(color.green, 238);
expect(color.blue, 12);
expect(color!.a, 1.0);
expect(color.r.toColorChannel(), 239);
expect(color.g.toColorChannel(), 238);
expect(color.b.toColorChannel(), 12);
});

test('parses an RGBA color with numeric alpha', () {
final color = ColorParser.toColor('rgba(239, 238, 12, 0.36)');
expect(color, isNotNull);
expect(color!.alpha, 92);
expect(color.red, 239);
expect(color.green, 238);
expect(color.blue, 12);
expect(color!.a, closeTo(0.3607, 0.0001));
expect(color.r.toColorChannel(), 239);
expect(color.g.toColorChannel(), 238);
expect(color.b.toColorChannel(), 12);
});

test('parses an RGBA color with floating point alpha', () {
Expand All @@ -38,19 +38,19 @@ void main() {
test('parses an hsl color', () {
final color = ColorParser.toColor('hsl(248, 7%, 66%)');
expect(color, isNotNull);
expect(color!.alpha, 0xff);
expect(color.red, 0xA4);
expect(color.green, 0xA2);
expect(color.blue, 0xAE);
expect(color!.a, 1.0);
expect(color.r.toColorChannel(), 0xA4);
expect(color.g.toColorChannel(), 0xA2);
expect(color.b.toColorChannel(), 0xAE);
});

test('parses an hsla color with floating point alpha', () {
final color = ColorParser.toColor('hsla(96, 40%, 49%, 0.36)');
expect(color, isNotNull);
expect(color!.alpha, 92);
expect(color.red, 0x73);
expect(color.green, 0xAF);
expect(color.blue, 0x4B);
expect(color!.a, closeTo(0.3607, 0.0001));
expect(color.r.toColorChannel(), 0x73);
expect(color.g.toColorChannel(), 0xAF);
expect(color.b.toColorChannel(), 0x4B);
});

test('parses an hsla color with percentage alpha', () {
Expand All @@ -59,3 +59,7 @@ void main() {
expect(floatAlphaColor, percentAlphaColor);
});
}

extension _ColorChannelExtension on double {
int toColorChannel() => (this * 255).round();
}

0 comments on commit d38d4ec

Please sign in to comment.