Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: Not found: 'dart:js' import 'dart:js';

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';
       ^

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

like image 487
Himanshu Sharma Avatar asked Dec 25 '19 15:12

Himanshu Sharma


1 Answers

Go to your flutter installed directory/.pub-cache/hosted/pub.dartlang.org/js-0.6.3-nullsafety.1/lib/js.dart

Delete or comment this line:

export 'dart:js' show allowInterop, allowInteropCaptureThis;

Then try again

like image 134
Aqeel Avatar answered Sep 20 '22 20:09

Aqeel