mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-04-20 03:06:59 +08:00
43 lines
963 B
Dart
43 lines
963 B
Dart
import 'package:PiliPlus/common/widgets/flutter/selectable_text/selectable_text.dart';
|
|
import 'package:PiliPlus/common/widgets/flutter/selectable_text/selection_area.dart';
|
|
import 'package:PiliPlus/utils/platform_utils.dart';
|
|
import 'package:flutter/material.dart' hide SelectableText, SelectionArea;
|
|
|
|
Widget selectableText(
|
|
String text, {
|
|
TextStyle? style,
|
|
}) {
|
|
if (PlatformUtils.isDesktop) {
|
|
return SelectionArea(
|
|
child: Text(
|
|
style: style,
|
|
text,
|
|
),
|
|
);
|
|
}
|
|
return SelectableText(
|
|
style: style,
|
|
text,
|
|
scrollPhysics: const NeverScrollableScrollPhysics(),
|
|
);
|
|
}
|
|
|
|
Widget selectableRichText(
|
|
TextSpan textSpan, {
|
|
TextStyle? style,
|
|
}) {
|
|
if (PlatformUtils.isDesktop) {
|
|
return SelectionArea(
|
|
child: Text.rich(
|
|
style: style,
|
|
textSpan,
|
|
),
|
|
);
|
|
}
|
|
return SelectableText.rich(
|
|
style: style,
|
|
textSpan,
|
|
scrollPhysics: const NeverScrollableScrollPhysics(),
|
|
);
|
|
}
|