refactor(ui): rework text gradient and text wrapper
This commit is contained in:
@@ -15,10 +15,11 @@
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:wyatt_ui_components/src/core/utils/text_wrapper.dart';
|
||||
import 'package:wyatt_ui_components/wyatt_wyatt_ui_components.dart';
|
||||
|
||||
extension StringExtension on String? {
|
||||
TextWrapper? wrap({TextStyle? style, List<Color>? gradient}) => this != null
|
||||
? TextWrapper(this!, style: style, gradient: gradient)
|
||||
: null;
|
||||
TextWrapper? wrap({TextStyle? style, MultiColor? gradientColors}) =>
|
||||
this != null
|
||||
? TextWrapper(this!, style: style, gradientColors: gradientColors)
|
||||
: null;
|
||||
}
|
||||
|
||||
@@ -15,17 +15,22 @@
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:wyatt_ui_components/wyatt_wyatt_ui_components.dart';
|
||||
|
||||
/// Wraps [String] and [TextStyle] into one object that can be
|
||||
/// a [Text] or a [RichText].
|
||||
class TextWrapper {
|
||||
const TextWrapper(
|
||||
this.text, {
|
||||
this.style,
|
||||
this.gradient,
|
||||
this.gradientColors,
|
||||
});
|
||||
|
||||
factory TextWrapper.text(String text) => TextWrapper(text);
|
||||
const TextWrapper.text(this.text)
|
||||
: style = null,
|
||||
gradientColors = null;
|
||||
|
||||
final String text;
|
||||
final TextStyle? style;
|
||||
final List<Color>? gradient;
|
||||
final MultiColor? gradientColors;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user