Skip to content
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