错误:找不到:'dart:js'导入'dart:js'; [英] Error: Not found: 'dart:js' import 'dart:js';

查看:1296
本文介绍了错误:找不到:'dart:js'导入'dart:js';的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在AppBar部分中创建一个PopupMenuButton().
这是我的文件:

I am creating a PopupMenuButton() in the AppBar section.
This is my file:

import 'dart:js';
import 'package:bfdi_app/settings.dart';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';

class ProfilePage extends StatefulWidget {

  @override
  _ProfilePageState createState() => _ProfilePageState();
}

class _ProfilePageState extends State<ProfilePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(
          'App_Name',
          ),
        actions: <Widget>[
            PopupMenuButton(
              icon: Icon(Icons.settings),
              onSelected:(value){
                if(value==0){
                  Navigator.push(
                    context,
                    MaterialPageRoute(builder: (context)=>SettingPage())
                  );
                }
              },
              itemBuilder: (context) => [
                    PopupMenuItem(
                      child: Text("Settings"),
                      value:0,
               ],
            ),
          ],
       ),
      }

现在我在控制台日志中遇到错误:

Now I am facing an error in Console Log:

Compiler message:
lib/Pages/addPost.dart:1:8: Error: Not found: 'dart:js'
import 'dart:js';
       ^
lib/Profile/profile.dart:1:8: Error: Not found: 'dart:js'
import 'dart:js';
       ^

我已经添加了dart:js依赖项,但仍然遇到相同的错误. 错误:

I have already added the dependency dart:js, but still getting the same error. Error:

推荐答案

我已经切换到主频道,并且一切正常.尽管我在您当前的代码中看不到dart.js的任何要求.所以你也可以删除它

I have switched to the master channel and all working fine. Although I don't see any requirement of dart.js in your current code. so you can remove that too

原始答案: 我相信您正在使用stable channel,因此请尝试切换到beta channel. 打开您的终端并运行,

ORIGINAL ANSWER: I believe you are using stable channel so try to switch to beta channel. Open your terminal and run,

$ flutter channel beta

这篇关于错误:找不到:'dart:js'导入'dart:js';的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆