Answers for "how to use $ input in dart as a string"

1

dart get String input from user

import 'dart:io'; 
  
void main() 
{ 
    print("Enter your name?"); 
    // Reading name of the Geek 
    String name = stdin.readLineSync(); 
  
    // Printing the name 
    print("Hello, $name! \nWelcome to GeeksforGeeks!!"); 
}
Posted by: Guest on November-08-2020
0

how to use $ input in dart as a string

// Importing dart:io file
import 'dart:io';
 
void main()
{
    // Asking for favourite number
    print("Enter your favourite number:");
 
   // Scanning number
    int? n = int.parse(stdin.readLineSync()!);
   // Here ? and ! are for null safety
 
    // Printing that number
    print("Your favourite number is $n");
}
Posted by: Guest on July-12-2021

Code answers related to "how to use $ input in dart as a string"

Code answers related to "Dart"

Browse Popular Code Answers by Language