Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added selectable text property for web #113

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/auto_size_text.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ library auto_size_text;

import 'dart:async';

import 'package:flutter/widgets.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';

part 'src/auto_size_text.dart';
part 'src/auto_size_group.dart';
Expand Down
84 changes: 56 additions & 28 deletions lib/src/auto_size_text.dart
Original file line number Diff line number Diff line change
Expand Up @@ -412,35 +412,63 @@ class _AutoSizeTextState extends State<AutoSizeText> {

Widget _buildText(double fontSize, TextStyle style, int? maxLines) {
if (widget.data != null) {
return Text(
widget.data!,
key: widget.textKey,
style: style.copyWith(fontSize: fontSize),
strutStyle: widget.strutStyle,
textAlign: widget.textAlign,
textDirection: widget.textDirection,
locale: widget.locale,
softWrap: widget.softWrap,
overflow: widget.overflow,
textScaleFactor: 1,
maxLines: maxLines,
semanticsLabel: widget.semanticsLabel,
);
if (kIsWeb) {
return SelectableText(
widget.data!,
key: widget.textKey,
style: style.copyWith(fontSize: fontSize),
strutStyle: widget.strutStyle,
textAlign: widget.textAlign,
textDirection: widget.textDirection,
textScaleFactor: 1,
maxLines: maxLines,
semanticsLabel: widget.semanticsLabel,
);
} else {
return Text(
widget.data!,
key: widget.textKey,
style: style.copyWith(fontSize: fontSize),
strutStyle: widget.strutStyle,
textAlign: widget.textAlign,
textDirection: widget.textDirection,
locale: widget.locale,
softWrap: widget.softWrap,
overflow: widget.overflow,
textScaleFactor: 1,
maxLines: maxLines,
semanticsLabel: widget.semanticsLabel,
);
}
} else {
return Text.rich(
widget.textSpan!,
key: widget.textKey,
style: style,
strutStyle: widget.strutStyle,
textAlign: widget.textAlign,
textDirection: widget.textDirection,
locale: widget.locale,
softWrap: widget.softWrap,
overflow: widget.overflow,
textScaleFactor: fontSize / style.fontSize!,
maxLines: maxLines,
semanticsLabel: widget.semanticsLabel,
);
if (kIsWeb) {
return SelectableText.rich(
widget.textSpan!,
key: widget.textKey,
style: style,
strutStyle: widget.strutStyle,
textAlign: widget.textAlign,
textDirection: widget.textDirection,
textScaleFactor: fontSize / style.fontSize!,
maxLines: maxLines,
semanticsLabel: widget.semanticsLabel,
);
} else {
return Text.rich(
widget.textSpan!,
key: widget.textKey,
style: style,
strutStyle: widget.strutStyle,
textAlign: widget.textAlign,
textDirection: widget.textDirection,
locale: widget.locale,
softWrap: widget.softWrap,
overflow: widget.overflow,
textScaleFactor: fontSize / style.fontSize!,
maxLines: maxLines,
semanticsLabel: widget.semanticsLabel,
);
}
}
}

Expand Down