Complete refactoring SFM App Source Code
This commit is contained in:
32
lib/product/utils/string_utils.dart
Normal file
32
lib/product/utils/string_utils.dart
Normal file
@@ -0,0 +1,32 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user