小编Kos*_*lav的帖子

在 Flutter 中将 inputDecorationTheme 转换为 InputDecoration

我正在编写一个FormBuilderField扩展,它可以从 main 中获取所有装饰属性,ThemeObjecthintText我希望能够手动传递的属性除外。

从我的角度来看,主要问题如下:themeObject仅包含InputDecorationTheme没有属性的实例,因此我决定通过将实例转换为来hintText创建,然后使用方法注入缺少的属性。您可以查看下面的代码示例。InputDecorationInputDecorationThemeInputDecorationcopyWith

class MyNewAwsomeField extends FormBuilderField<String>{
# code that gets the theme object out of context (with is working fine)
static final theme = getThemeData();

MyNewAwsomeField ({
   Key? key,
   required String name,
   required String hintText,
   ValueChanged<String?>? onChanged,
}) : super(
   key:key,
   decoration: (theme.inputDecorationTheme as InputDecoration).copyWith(
   hintText: hintText,
   onChange: onChange,
   name:name
 )
}
Run Code Online (Sandbox Code Playgroud)

我收到的错误是“预期为‘InputDecoration’类型的值,但得到了‘InputDecorationTheme’类型之一......”。我理解这个错误,所以我想知道是否有一种方法可以InputDecoration从一个实例中获取 的实例InputDecorationTheme并向其添加自定义属性?

很高兴听到任何建议。

dart flutter

3
推荐指数
1
解决办法
2951
查看次数

使用watchify制作一个包后得到blob错误

我想做什么? 我想使用节点模块和es6 javascript语法创建一个项目.为了使其尽可能模块化和独立,我决定改用watchify.我的html页面看起来像这样

...some unrelated html code

<dib id='content'></div>
<script type='text/javascript' src='correct(checked) path to my bundle.js file'></script>

...some unrelated html code
Run Code Online (Sandbox Code Playgroud)

我的whatchify命令看起来像这样

watchify src/app.js -o destination/bundle.js -t [babelify --presets [ es2015 ] ]
Run Code Online (Sandbox Code Playgroud)

虽然我的受抚养人看起来像这样

"dependencies": {
    "bluebird": "^3.5.1",
    "jquery": "^3.3.1",
    "three": "^0.92.0",
    "three-obj-exporter": "0.0.1",
    "three-obj-loader": "^1.1.3"
  },
  "devDependencies": {
    "babel-cli": "^6.26.0",
    "babel-core": "^6.26.3",
    "babel-preset-env": "^1.6.1",
    "babel-preset-es2015": "^6.24.1",
    "babel-preset-stage-2": "^6.24.1",
    "babelify": "^8.0.0",
    "nodemon": "^1.17.4"
  }
Run Code Online (Sandbox Code Playgroud)

现在我的src文件中没有多少我只是从test.js文件中导入了一个测试函数,并且需要jquery.

import print from './taskobject';

function test(){
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

现在,我不明白? 字面上我什么都不做,但我仍然在控制台中得到以下错误

GET blob:http://127.0.0.1/fbfa8eff-f538-42cf-aa2d-ae2940247aaf 0 () …
Run Code Online (Sandbox Code Playgroud)

javascript ecmascript-6 watchify

1
推荐指数
1
解决办法
1425
查看次数

标签 统计

dart ×1

ecmascript-6 ×1

flutter ×1

javascript ×1

watchify ×1