- SFTP download
- open downloaded files in other apps
This commit is contained in:
Junyuan Feng
2022-05-07 22:15:09 +08:00
parent 74a933eb6e
commit b824e06736
33 changed files with 1223 additions and 198 deletions

View File

@@ -1,3 +1,4 @@
import 'package:flutter/material.dart';
import 'package:toolbox/data/model/distribution.dart';
extension StringX on String {
@@ -21,4 +22,40 @@ extension StringX on String {
Uri get uri {
return Uri.parse(this);
}
Widget omitStartStr(
{TextStyle? style, TextOverflow? overflow, int? maxLines}) {
return LayoutBuilder(builder: (context, size) {
bool exceeded = false;
int len = 0;
for (; !exceeded && len < length; len++) {
// Build the textspan
var span = TextSpan(
text: 'A' * 7 + substring(length - len),
style: style ?? Theme.of(context).textTheme.bodyText2,
);
// Use a textpainter to determine if it will exceed max lines
var tp = TextPainter(
maxLines: maxLines ?? 1,
textDirection: TextDirection.ltr,
text: span,
);
// trigger it to layout
tp.layout(maxWidth: size.maxWidth);
// whether the text overflowed or not
exceeded = tp.didExceedMaxLines;
}
return Text(
(exceeded ? '...' : '') + substring(length - len),
overflow: overflow ?? TextOverflow.fade,
softWrap: false,
maxLines: maxLines ?? 1,
style: style,
);
});
}
}