Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save karabanovbs/e8cacd656f04c105ea3f033a3759cfe5 to your computer and use it in GitHub Desktop.
Save karabanovbs/e8cacd656f04c105ea3f033a3759cfe5 to your computer and use it in GitHub Desktop.
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