Skip to content
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
4 changes: 2 additions & 2 deletions packages/data_detector/lib/data_detector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ class TextCheckingResult {
if (timestamp == null) {
return null;
}
return DateTime.fromMicrosecondsSinceEpoch((timestamp * 1e6) as int);
return DateTime.fromMicrosecondsSinceEpoch((timestamp * 1e6).round());
}

Duration get duration =>
Duration(microseconds: (_inner.duration * 1e6) as int);
Duration(microseconds: (_inner.duration * 1e6).round());

Uri? get url {
final url = _inner.URL?.absoluteString;
Expand Down
13 changes: 11 additions & 2 deletions packages/data_detector/test/data_detector_test.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'dart:io';

import 'package:data_detector/data_detector.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter_test/flutter_test.dart';

void main() {
Expand All @@ -10,5 +11,13 @@ void main() {
for (final result in results) {
expect(result.range.textInside(str), "https://mixin.one");
}
}, skip: defaultTargetPlatform != TargetPlatform.macOS);
}, skip: !Platform.isMacOS);

test("date", () {
final detector = DataDetector(NSTextCheckingType.NSTextCheckingTypeDate);
final results = detector.matchesInString("on 2024-01-02 10:00");
expect(results, isNotEmpty);
expect(results.first.date, isNotNull);
expect(results.first.duration, Duration.zero);
}, skip: !Platform.isMacOS);
}
Loading