Created
November 29, 2020 05:26
-
-
Save karabanovbs/e8cacd656f04c105ea3f033a3759cfe5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:convert'; | |
import 'dart:io'; | |
// 2.8 Асинхронность | |
// Напишите функцию, которая считывает данные с клавиатуры. Функция должна возвращать Future. | |
// Напишите код, который дожидается выполнения функции и распечатывает на консоль "Введена строка stroke_name". | |
// Поэкспериментируйте с async/await и then | |
Future<String> waitInput() async { | |
return stdin.readLineSync(encoding: Encoding.getByName('utf-8')); | |
} | |
void main(List<String> arguments) async { | |
print('1 Введена строка ${await waitInput()}'); | |
waitInput().then((stroke_name) => '2 Введена строка $stroke_name').then(print); | |
print('3 Введена строка ${await waitInput()}'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment