TextstylesetController class
The 'TextstylesetController' class is responsible for manipulating a given input string and converting it into a list of TypeValueModel objects based on certain style types defined in a literals map.
Example Usage:
final controller = TextstylesetController('This is *bold* and _italic_.');
final result = controller.manipulateString();
Inputs:
input(String): The input string to be manipulated.
Flow:
- Create a map called
literalsMapthat maps certain characters to their correspondingStyleTypeEnumvalues. - Initialize
currentStyleasStyleTypeEnum.plainand create an emptyStringBuffercalledcurrentContent. - Iterate over each character in the
inputstring. - If the current character is a forward slash ('/') and the
next character is a key in
literalsMap, skip the escaping character and add the next literal character as normal text tocurrentContent. - If the current character is a key in
literalsMapand thecurrentStyleisStyleTypeEnum.plain, add any existing plain text incurrentContentto thelistas aTypeValueModelobject. Then clearcurrentContentand updatecurrentStyleto the corresponding style type. - If the current character is a key in
literalsMapand the corresponding style type is equal tocurrentStyle, add the current content incurrentContentto thelistas aTypeValueModelobject. Then clearcurrentContentand resetcurrentStyletoStyleTypeEnum.plain. - If none of the above conditions are met, add the current character to
currentContent. - After the loop, if there is any leftover text in
currentContent, add it to thelistas plain text. - Return the
listofTypeValueModelobjects.
Outputs:
list: A list ofStyleTypeValueModelobjects representing the manipulated string. Each object contains a style type and the corresponding text segment.
Constructors
- TextstylesetController({required String input})
- The constructor for the TextstylesetController class.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- input → String
-
The input string to be manipulated.
final
-
list
↔ List<
StyleTypeValueModel> -
A list of
TypeValueModelobjects representing the manipulated string.getter/setter pair - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
manipulateString(
) → List< StyleTypeValueModel> - Manipulates a given string by identifying specific characters and assigning corresponding style types to them.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited