NEW: moved Link class to be with main Linkify class for type saftey, code completion, all good

This commit is contained in:
JohnE 2025-10-06 21:46:43 -07:00
parent 40330ad1af
commit 46d21c5244
3 changed files with 20 additions and 17 deletions

View File

@ -1,3 +1,8 @@
## 1.2.0
- Improved with J3G skillz
- Merged updates from other branches, improves regex
## 1.1.5
- Enforce lint rules

View File

@ -3,7 +3,6 @@ import 'dart:ui' as ui show BoxHeightStyle, BoxWidthStyle;
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:linkify_text/src/enum.dart';
import 'package:linkify_text/src/model/link.dart';
import 'package:linkify_text/src/utils/regex.dart';
/// Linkify [text] containing urls, emails or hashtag
@ -414,3 +413,18 @@ TextSpan _linkify({
return TextSpan(children: spans);
}
/// Model class for Link data
class Link {
late final String? _value;
late final LinkType? _type;
String? get value => _value;
LinkType? get type => _type;
/// construct link from matched regExp
Link.fromMatch(RegExpMatch match) {
final String _match = match.input.substring(match.start, match.end);
_type = getMatchedType(_match);
_value = _match;
}
}

View File

@ -1,16 +0,0 @@
import 'package:linkify_text/src/enum.dart';
import 'package:linkify_text/src/utils/regex.dart';
class Link {
late final String? _value;
late final LinkType? _type;
String? get value => _value;
LinkType? get type => _type;
/// construct link from matched regExp
Link.fromMatch(RegExpMatch match) {
final String _match = match.input.substring(match.start, match.end);
_type = getMatchedType(_match);
_value = _match;
}
}