Files
sfm_app_final/lib/product/utils/string_utils.dart
2024-12-15 00:59:02 +07:00

33 lines
814 B
Dart

import 'package:flutter/material.dart';
class StringUtils {
StringUtils._init();
static StringUtils? _instance;
static StringUtils get instance => _instance ??= StringUtils._init();
List<InlineSpan> parseAddressFromMapAPI(String addressString) {
RegExp regex = RegExp(r'<span class="([^"]+)">([^<]+)</span>');
List<InlineSpan> textSpans = [];
Iterable<Match> matches = regex.allMatches(addressString);
for (Match match in matches) {
String cssClass = match.group(1)!;
String text = match.group(2)!;
if (cssClass == 'country-name') {
continue;
}
textSpans.add(
TextSpan(
text: text,
),
);
textSpans.add(
const TextSpan(text: ', '),
);
}
textSpans.removeLast();
return textSpans;
}
}