mirror of
https://gitlab.com/veilid/veilidchat.git
synced 2025-05-16 13:12:43 -04:00
pagination work
This commit is contained in:
parent
4082d1dd76
commit
5473bd2ee4
11 changed files with 469 additions and 24 deletions
18
lib/tools/misc.dart
Normal file
18
lib/tools/misc.dart
Normal file
|
@ -0,0 +1,18 @@
|
|||
extension StringExt on String {
|
||||
(String, String?) splitOnce(Pattern p) {
|
||||
final pos = indexOf(p);
|
||||
if (pos == -1) {
|
||||
return (this, null);
|
||||
}
|
||||
final rest = substring(pos);
|
||||
var offset = 0;
|
||||
while (true) {
|
||||
final match = p.matchAsPrefix(rest, offset);
|
||||
if (match == null) {
|
||||
break;
|
||||
}
|
||||
offset = match.end;
|
||||
}
|
||||
return (substring(0, pos), rest.substring(offset));
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue