我在AppBar部分中创建一个PopupMenuButton()。这是我的文件:
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, ], ), ], ), }
现在,我在控制台日志中遇到错误:
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,但仍然遇到相同的错误。
编辑:我已经切换到主频道,并且一切正常。尽管我看不到dart.js您当前代码中的任何要求。所以你也可以删除 它
dart.js
原始答案:我相信您正在使用stable channel,请尝试切换到beta channel。打开终端并运行,
stable channel
beta channel
$ flutter channel beta