Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Вивчайте Function print() in Dart | First Acquaintance with Dart
Introduction to Dart

bookFunction print() in Dart

Let's take a detailed look at how to use the print() function:

Print with Text

main.dart

main.dart

copy
123
void main() { print("Text you want to output"); }

The program prints information to the console from the parentheses of the print() function. If we want to output the text to the console, we must write it inside the quotation marks.

main.dart

main.dart

copy
1234
void main() { print('Hi, Codefinity!'); print("I want know more"); }

Rules

The text can be written in single quotation marks:

'Hi, Codefinity!'

The text also can be written in double quotation marks:

"I want know more"

The main rule when using the print() function is that it's important for the quotation marks surrounding the text to match on both sides. For example, if we use single quotes to print text ('like this'), we must close them with single quotes as well. This allows Dart to correctly recognize it as text to be printed, rather than a variable name or instruction. If the quotation marks do not match, or if they are absent altogether, it can lead to a runtime error in the program.

Print with Numbers

Working with numbers is different from working with text. Suppose you want to display numbers. Since we work with number values, you don't need to use quotes (" " or ' ').

main.dart

main.dart

copy
123
void main() { print(2); }
question mark

Find the line of code with the error.

Select the correct answer

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 1. Розділ 3

Запитати АІ

expand

Запитати АІ

ChatGPT

Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат

Suggested prompts:

Запитайте мені питання про цей предмет

Сумаризуйте цей розділ

Покажіть реальні приклади

Awesome!

Completion rate improved to 4.55

bookFunction print() in Dart

Свайпніть щоб показати меню

Let's take a detailed look at how to use the print() function:

Print with Text

main.dart

main.dart

copy
123
void main() { print("Text you want to output"); }

The program prints information to the console from the parentheses of the print() function. If we want to output the text to the console, we must write it inside the quotation marks.

main.dart

main.dart

copy
1234
void main() { print('Hi, Codefinity!'); print("I want know more"); }

Rules

The text can be written in single quotation marks:

'Hi, Codefinity!'

The text also can be written in double quotation marks:

"I want know more"

The main rule when using the print() function is that it's important for the quotation marks surrounding the text to match on both sides. For example, if we use single quotes to print text ('like this'), we must close them with single quotes as well. This allows Dart to correctly recognize it as text to be printed, rather than a variable name or instruction. If the quotation marks do not match, or if they are absent altogether, it can lead to a runtime error in the program.

Print with Numbers

Working with numbers is different from working with text. Suppose you want to display numbers. Since we work with number values, you don't need to use quotes (" " or ' ').

main.dart

main.dart

copy
123
void main() { print(2); }
question mark

Find the line of code with the error.

Select the correct answer

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 1. Розділ 3
some-alt