mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 23:34:24 +01:00
New feat
- SFTP download - open downloaded files in other apps
This commit is contained in:
@@ -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,
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user