# Dart Data Types: Dart String & String Literals

In Dart, strings are used to represent sequences of characters. Dart supports both single-line and multi-line string literals. Here's an overview of Dart strings and string literals:

### String Literals:

1. **Single-Line String:**
    
    * Created using single quotes (`'`) or double quotes (`"`).
        
    * No difference in functionality between single and double quotes.
        
    
    ```dart
    String singleLine1 = 'This is a single-line string.';
    String singleLine2 = "This is also a single-line string.";
    ```
    
2. **Multi-Line String:**
    
    * Created using triple single quotes (`'''`) or triple double quotes (`"""`).
        
    * Useful for representing strings that span multiple lines.
        
    
    ```dart
    String multiLine1 = '''
      This is a multi-line string.
      It can span across several lines.
    ''';
    
    String multiLine2 = """
      Another multi-line string.
      This one uses triple double quotes.
    """;
    ```
    

### String Interpolation:

Dart supports string interpolation, allowing you to embed expressions within strings using `${}`.

```dart
String name = 'John';
int age = 25;
String greeting = 'Hello, my name is $name and I am $age years old.';
```

### Raw Strings:

Dart provides raw strings, denoted by the `r` prefix. In a raw string, escape sequences are treated as literal characters.

```dart
String rawString = r'This is a raw string \n with an escaped backslash.';
```

### Escaping Characters:

You can escape characters in strings using the backslash (`\`) followed by the character to be escaped.

```dart
String escapedString = 'This string contains a newline character.\nAnother line.';
```

### Unicode and Runes:

Dart strings support Unicode characters and can represent them using escape sequences or directly using the character.

```dart
String unicodeString = 'Dart supports Unicode characters: \u{1F604}'; // 😄
```

### Operations on Strings:

Dart provides various methods and operators for string manipulation, such as concatenation (`+`), length retrieval (`length`), substring extraction (`substring`), and more.

```dart
String firstName = 'John';
String lastName = 'Doe';
String fullName = firstName + ' ' + lastName; // Concatenation
int length = fullName.length; // Length retrieval
String part = fullName.substring(0, 4); // Substring extraction
```

Understanding these features of Dart strings and string literals is essential for effective string manipulation in Dart programming.
