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:

  1. Create a map called literalsMap that maps certain characters to their corresponding StyleTypeEnum values.
  2. Initialize currentStyle as StyleTypeEnum.plain and create an empty StringBuffer called currentContent.
  3. Iterate over each character in the input string.
  4. 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 to currentContent.
  5. If the current character is a key in literalsMap and the currentStyle is StyleTypeEnum.plain, add any existing plain text in currentContent to the list as a TypeValueModel object. Then clear currentContent and update currentStyle to the corresponding style type.
  6. If the current character is a key in literalsMap and the corresponding style type is equal to currentStyle, add the current content in currentContent to the list as a TypeValueModel object. Then clear currentContent and reset currentStyle to StyleTypeEnum.plain.
  7. If none of the above conditions are met, add the current character to currentContent.
  8. After the loop, if there is any leftover text in currentContent, add it to the list as plain text.
  9. Return the list of TypeValueModel objects.

Outputs:

  • list : A list of StyleTypeValueModel objects 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 TypeValueModel objects 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