Him*_*rma 5 android dart flutter
我正在 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,
],
),
],
),
}
Run Code Online (Sandbox Code Playgroud)
现在我在控制台日志中遇到错误:
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';
^
Run Code Online (Sandbox Code Playgroud)
Aqe*_*eel 17
进入你的flutter安装目录/.pub-cache/hosted/pub.dartlang.org/js-0.6.3-nullsafety.1/lib/js.dart
删除或注释此行:
export 'dart:js' show allowInterop, allowInteropCaptureThis;
Run Code Online (Sandbox Code Playgroud)
然后再试一次
编辑:我已切换到主通道并且一切正常。尽管我在您当前的代码中没有看到任何要求dart.js。所以你也可以删除它
原始答案:我相信您正在使用,stable channel因此请尝试切换到beta channel. 打开终端并运行,
$ flutter channel beta
Run Code Online (Sandbox Code Playgroud)