简体   繁体   中英

The requested built-in library is not available on Dartium - library handler failed import 'dart:io';

I am beginner in Dart. I have build a simple application in Dart.

import 'dart:math';
import 'dart:io';

void main() {
  int guess;
  Random rand = new Random();
  int answer = rand.nextInt(100);
  do{
    print("Enter your guess number: ");
    String temp = stdin.readLineSync();
    guess = int.parse(temp);
    if (guess < answer){
      print("Too low");
    }else if (guess > answer){
      print("Too high");
    }
  }while(guess != answer);
  print("Got it!");
}

But, when i run it on Dartium. It has an error.

错误

What can I do to solve this? Thanks.

dart:io is for console/server applications. If you want to run the code in the browser you must not import it. Maybe dart:html is what you want instead. It exposes the browser API.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM