简体   繁体   English

参数类型“JsObject”不能分配给参数类型“BuildContext”。 - flutter

[英]The argument type 'JsObject' can't be assigned to the parameter type 'BuildContext'. - flutter

How to solve this issue?如何解决这个问题?

This is my code:这是我的代码:

import 'dart:js';

import 'package:flutter/material.dart';

showDataAlert() {
  showDialog(
      context: context,
      builder: (context) {
        return AlertDialog(
          shape: RoundedRectangleBorder(
            borderRadius: BorderRadius.all(
              Radius.circular(
                20.0,
              ),
            ),
          ),
          contentPadding: EdgeInsets.only(
            top: 10.0,
          ),
          title: Text(
            "Create ID",
            style: TextStyle(fontSize: 24.0),
          ),
          content: Container(
            height: 400,
            child: SingleChildScrollView(
              padding: const EdgeInsets.all(8.0),
              child: Column(
                mainAxisAlignment: MainAxisAlignment.start,
                crossAxisAlignment: CrossAxisAlignment.start,
                mainAxisSize: MainAxisSize.min,
                children: <Widget>[
                  Padding(
                    padding: const EdgeInsets.all(8.0),
                    child: Text(
                      "Mension Your ID ",
                    ),
                  ),
                  Container(
                    padding: const EdgeInsets.all(8.0),
                    child: TextField(
                      decoration: InputDecoration(
                          border: OutlineInputBorder(),
                          hintText: 'Enter Id here',
                          labelText: 'ID'),
                    ),
                  ),
                  Container(
                    width: double.infinity,
                    height: 60,
                    padding: const EdgeInsets.all(8.0),
                    child: ElevatedButton(
                      onPressed: () {
                        Navigator.of(context).pop();
                      },
                      style: ElevatedButton.styleFrom(
                        primary: Colors.black,
                        // fixedSize: Size(250, 50),
                      ),
                      child: Text(
                        "Submit",
                      ),
                    ),
                  ),
                  Container(
                    padding: const EdgeInsets.all(8.0),
                    child: Text('Note'),
                  ),
                  Padding(
                    padding: const EdgeInsets.all(8.0),
                    child: Text(
                      'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt'
                          ' ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud'
                          ' exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.'
                          ' Duis aute irure dolor in reprehenderit in voluptate velit esse cillum '
                          'dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident,'
                          ' sunt in culpa qui officia deserunt mollit anim id est laborum.',
                      style: TextStyle(fontSize: 12),
                    ),
                  ),
                ],
              ),
            ),
          ),
        );
      });
}

I deleted "import 'dart:js';"我删除了“import 'dart:js';” but the error still appear, also wrote this "import 'dart:js' as context;"但错误仍然出现,还写了这个“import 'dart:js' as context;” but again no luck, so in this case, what should I do to solve this problem?但又没有运气,所以在这种情况下,我应该怎么做才能解决这个问题?

Do I have to make "context" a variable?我必须使“上下文”成为变量吗? Do I have to add "context" a "?"?我是否必须添加“上下文”一个“?”?

Thank you in advance先感谢您

First delete "import 'dart:js and save the file. then Pass context on method.首先删除"import 'dart:js并保存文件。然后在方法上传递上下文。

showDataAlert(BuildContext context) {

Save again, run the app.再次保存,运行应用程序。 If fails do flutter clean and rebuild the app.如果失败flutter clean并重建应用程序。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法将参数类型“ JsObject”分配给参数类型“ BuildContext” - The argument type 'JsObject' can't be assigned to the parameter type 'BuildContext 错误:无法将参数类型“JsObject”分配给参数类型“BuildContext” - Error: The argument type 'JsObject' can't be assigned to the parameter type 'BuildContext' 参数类型“JsObject”不能分配给参数类型“BuildContext”。dart - The argument type 'JsObject' can't be assigned to the parameter type 'BuildContext'.dart 参数类型“JsObject”不能分配给参数类型“BuildContext” - The argument type 'JsObject' can't be assigned to the parameter type 'BuildContext' 无法将参数类型“jsObject”分配给“buildContext”参数? - The argument type 'jsObject' can't be assigned to 'buildContext' parameter? 导航器错误在颤振导航器错误参数类型&#39;JsObject&#39;不能分配给参数类型&#39;BuildContext&#39; - navigator error in flutter navigator error The argument type 'JsObject' can't be assigned to the parameter type 'BuildContext' 使用简单代码时,无法将参数类型“JsObject”分配给参数类型“BuildContext” - The argument type 'JsObject' can't be assigned to the parameter type 'BuildContext' while using simple code 出现错误“无法将参数类型‘JsObject’分配给参数类型‘BuildContext’” - Getting error "The argument type 'JsObject' can't be assigned to the parameter type 'BuildContext'" 类型“JsObject”不能分配给类型“BuildContext” - Type 'JsObject' can't be assigned to type 'BuildContext' Argument 类型 &#39;Context&#39; 不能分配给参数类型 &#39;BuildContext&#39; - Flutter - The Argument type 'Context' can't be assigned to the parameter type 'BuildContext' - Flutter
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM