2

I am new bee to flutter and web. I got follow error when i run my app in Chrome which works well in android.

   require.js:1959 Not allowed to load local resource: file:///E:/project/flutter_afast/lib/model/builder.dart
   req.load @ require.js:1959
   require.js:143 Uncaught Error: Script error for "E:/project/flutter_afast/lib/model/builder.dart", needed by: web_entrypoint.dart
    http://requirejs.org/docs/errors.html#scripterror
        at makeError (require.js:168)
        at HTMLScriptElement.onScriptError (require.js:1738)

build.dart code as follows

import 'package:flutter/material.dart';
import 'package:flutter_afast/generated/l10n.dart';
import 'package:flutter_afast/model/result.dart';
import 'package:flutter_afast/model/user.dart';
import 'package:flutter_afast/screen/login.dart';
import 'package:progress_dialog/progress_dialog.dart';
import 'package:shared_preferences/shared_preferences.dart';



typedef Widget SuccessCallback(BaseResult data);


ProgressDialog getCommonProgressDialog(BuildContext context){
  return ProgressDialog(
    context,
    type: ProgressDialogType.Normal,
    textDirection: TextDirection.ltr,
    isDismissible: false,
//      customBody: LinearProgressIndicator(
//        valueColor: AlwaysStoppedAnimation<Color>(Colors.blueAccent),
//        backgroundColor: Colors.white,
//      ),
  );
}

// ignore: must_be_immutable
class AsyncBuilder extends FutureBuilder<BaseResult> {
  Widget loading ;
  Widget onError ;
  final Future<BaseResult> f;
  final SuccessCallback callback;



  AsyncBuilder(this.f, this.callback, {this.loading, this.onError})
      : super(
            future: f,
            initialData: Result(BaseResult.RESULT_LOADING, null, null),
            builder: (context, snapshot) {

              Widget w;
              if (snapshot.hasError) {
                if(onError == null){
                  w = Center(
                    child: Text(S.of(context).prompt_load_failed),
                  );
                }else{
                  w = onError;
                }

              } else if (snapshot.hasData) {
                if (snapshot.data.status == Status.LOADING) {
                  if(loading == null){
                    w =  Center(child: CircularProgressIndicator());
                  }else{
                    w= loading;
                  }
                } else if (snapshot.data.status == Status.SUCCESS) {
                  w = callback.call(snapshot.data);
                } else if (snapshot.data.status == Status.UNAUTHENTICATED) {
                  SharedPreferences.getInstance().then((value) =>   {
                    value.setString(UserModel.KEY_TOKEN, null)
                  });
                  w = MyLogin();
                }
              }
              return w;
            });
}

Any idea for this problem? Thanks!

1 Answer 1

1

I had a similar problem and I solved it by checking that the imports in the darts file were using the package-relative path (package:app/...) instead of your local path ("E:/.."). That solved it for me.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.