Dart Tutorial

Dart Tutorial Single-Page Application Architecture Dart Features Dart Installation Guide Dart Basic Program Dart Syntax Dart Keywords Dart Variables Dart Comments Dart Standard Input Output Dart Important Concepts

Data Types

Built-in Data Types Numbers Strings Booleans Lists Sets Maps Runes and Graphemes Symbols Enumerations Constants Queues

Other data types

Objects Future and stream Iterable Miscellaneous types

OPERATORS

Precedence and associativity Arithmetic operators Equality and Relational operators Type Test Operators Assignment Operators Logical Operators Bitwise and Shift Operators Miscellaneous operators

Control Flow Statements

Introduction If statement If-else statement If-else-if statement Loops Switch and case Dart Break And Continue Assert In Dart

FUNCTIONS

Dart function Types of Functions Anonymous function main( ) function Lexical scope and closure Recursion Common Collection Methods

Object Oriented Concepts

Dart Object-Oriented Concepts Dart Classes Dart Constructors Dart This Keyword Dart Super Keyword Static Members Method Overriding Dart Interfaces Inheritance Dart Abstract Classes Dart Builder Classes Dart Callable Classes

Dart Type System

Dart Type System Dart Soundness Dart Type Inference

MISCELLANEOUS

Dart Isolates Dart Typedef Dart Metadata Dart Packages Dart Generics Dart Generators Dart Concurrency Dart Unit Testing Dart Html Dom Dart URIs Dart Extends, With and Implements Keywords Dart Optional Parameters Rust Vs Dart C++ vs Dart Golang Vs Dart Dart Basics Exception Handling

Dart Runes and Graphemes

Runes and Graphemes data types in Dart

Runes and Graphemes

Runes are the special string of Unicode UTF-32 bits that represent the special syntax. Unicode defines a unique numeric value for each letter, digit, and symbol.

The Dart Runes are provided by the ‘ dart : core ’ library or ‘ package : characters ’.

Syntax of representing runes is :

\uXXXX, where XXXX is a 4-digit hexadecimal value

For example,

\u2665 corresponds to a heart character.

Program

import 'package:characters/characters.dart' ;


void main( )
{
  print( ' \u2665 ' ) ;
  print( ' \u{ 1f606 } ' ) ;
}

Output:

Dart Runes and Graphemes

The String code runes can be accessed using the following three methods :

  • Using String.codeUnitAt( ) function
  • Using String.codeUnits property
  • Using String.runes property

String.codeUnitAt( ) Function

This function returns the 16 – bit UTF – 16 code unit corresponding to the string at a particular index passed to the function as an argument.

Implementation = String.codeUnitAt( int index ) ;

Program

void main( ) 
{  
  // initializing string str
  String str = ' Let us understand codeUnits Property ' ;  
  
  // using codeUnitAt function to return the code unit at index 0
  print( str.codeUnitAt( 0 ) ) ;  
  
  // using codeUnitAt function to return the code unit at index 2
  print( str.codeUnitAt( 2 ) ) ;  
} 

Output :

32
101

String.codeUnits Property

This property returns the list of the UTF – 16 code units of the specified string.

Implementation = String. codeUnits ;

Program

void main( )
{ 
   // initializing string str
   String str = ' This tutorial teaches Runes ' ; 
  
   print( ' \n The code units are as follows : \n ' );
  
   // Using codeUnits property to print the code units of each string
   print( str.codeUnits ) ; 
}

Output :

The code units are as follows : 
 [32, 84, 104, 105, 115, 32, 116, 117, 116, 111, 114, 105, 97, 108, 32, 116, 101, 97, 99, 104, 101, 115, 32, 82, 117, 110, 101, 115, 32]

String.runes Property

This property returns an iterable of Unicode code – points of the passed string.Runes.

Implementation = String.runes

Program

void main( )
{ 
   " This teaches Runes ".runes.forEach( ( int rune ){ 
      var character = new String.fromCharCode( rune ) ; 
      print( character ) ; 
   } ) ;  
}

Output:

T
h
i
s
 
t
e
a
c
h
e
s
 
R
u
n
e
s