DEV Community

Saina
Saina

Posted on

Exploring Dart: Datatypes, Conditional Statements, and Operators

Datatypes:
Numbers: Dart supports integers and doubles. Integers represent whole numbers, while doubles represent floating-point numbers.

Strings: Strings are sequences of characters, enclosed within single (' ') or double (" ") quotes.

Booleans: Booleans represent two values: true and false, used for logical operations.

Lists: Lists are ordered collections of objects. They can be created using square brackets ([ ]) and can contain elements of different datatypes.

Maps: Maps are collections of key-value pairs, where each key maps to a value.

Conditional Statements:
if-else: Executes code based on a true/false condition.

int num = 10;
if (num > 0) {
  print("Number is positive");
} else {
  print("Number is not positive");
}

Enter fullscreen mode Exit fullscreen mode

Switch Statements: Switch statements allow a program to execute different blocks of code based on the value of a variable.

String fruit = 'apple';
switch (fruit) {
  case 'apple':
    print('Selected fruit is an apple');
    break;
  default:
    print('Unknown fruit');
}
Enter fullscreen mode Exit fullscreen mode

Operators:
Arithmetic: Addition (+), Subtraction (-), Multiplication (*), Division (/), Modulus (%).
Assignment: Assign (=).
Comparison: Equal to (==), Not equal to (!=), Greater than (>), Less than (<), Greater than or equal to (>=), Less than or equal to (<=).
Logical: Logical AND (&&), Logical OR (||), Logical NOT (!).

int a = 10;
int b = 5;
int maxValue = (a > b) ? a : b;
print('The maximum value is $maxValue');

Enter fullscreen mode Exit fullscreen mode

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read full post →

Top comments (0)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more