我正在使用FlatButton并通过属性
FlatButton(
splashColor: Colors.transparent,
highlightColor: Colors.transparent,
child: ...,
)
Run Code Online (Sandbox Code Playgroud)
该文件说FlatButton将变得过时,并使用TextButton替代,但它并不需要splashColor或highlightColor性质
TextButton(
splashColor: Colors.transparent,
highlightColor: Colors.transparent,
child: ...,
)
Run Code Online (Sandbox Code Playgroud)
不起作用。不允许
我也试过这样
TextButton(
style: ButtonStyle(
splashColor: Colors.transparent,
highlightColor: Colors.transparent,
),
child: ...,
)
Run Code Online (Sandbox Code Playgroud)
我怎样才能做到这一点?谢谢
我知道“动作必须是普通对象。对异步动作使用自定义中间件。” 已被问过很多次,但我找不到解决方案。
问题只发生在酶测试中。
这是我的 componentDidMount,它记录响应:
componentDidMount () {
this.props.dispatch(fetchUsers())
.then(response => console.log(response))
}
Run Code Online (Sandbox Code Playgroud)
日志响应:用户:(27) [{…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, { …}、{…}、{…}、{…}、{…}、{…}、{…}、{…}、{…}、{…}、{…}、{…}、{…} , {...}, {...}, {...}, {...}] 类型:“GET_USERS_SUCCESS”
这是我的行动
export const fetchUsers = () => (dispatch) => {
dispatch(fetchUSersRequest())
const request = axios({
method: 'GET',
url: `${BASE_URL}users.json`,
headers: []
})
return request.then(
response => dispatch(fetchUsersSuccess(response.data)),
err => dispatch(fetchUsersError(err))
)
}
Run Code Online (Sandbox Code Playgroud)
该组件是连接组件。这是测试
import React from 'react'
import configureMockStore from 'redux-mock-store'
import { shallow } from 'enzyme'
import …Run Code Online (Sandbox Code Playgroud) 我正在做一个 TextButton,我需要将其放置在页面的右侧部分。
按钮内容位于右侧,但按钮本身占据了页面的整个宽度。我怎样才能不这样呢?
这是我的代码:
Padding(
padding: const EdgeInsets.only(bottom: 14.0, right: 7.0),
child: TextButton(
onPressed: onPressed,
style: ButtonStyle(
backgroundColor: MaterialStateProperty.resolveWith<Color>(
(Set<MaterialState> states) {
if (states.contains(MaterialState.pressed))
return Theme.of(context).colorScheme.primary.withOpacity(0.5);
return Colors.red;
},
),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(right: 9.5, top: 1.6),
child: Icon(Icons.back_arrow, color: Colors.blue),
),
Text( "Home",
style: Theme.of(context)
.textTheme
.bodyText2
.merge(TextStyle(color: Colors.blue)
)
),
]),
),
);
Run Code Online (Sandbox Code Playgroud)
我尝试将按钮包裹在“对齐”中,但没有用
我正在尝试一些单元测试,我创建了一个带有虚假示例的沙箱https://codesandbox.io/s/wizardly-hooks-32w6l(实际上我有一个表单)
class App extends React.Component {
constructor(props) {
super(props);
this.state = { number: 0 };
}
handleSubmit = (number1, number2) => {
this.setState({ number: this.handleMultiply(number1, number2) })
}
handleMultiply = (number1, number2) => {
return number1 * number2
}
render() {
const { number } = this.state;
return (
<div className="App">
<form onSubmit={e => this.handleSubmit(3, 7)}>
<input type="submit" name="Submit" value="Multiply" />
</form>
<Table number={number} />
</div>
);
}
}
export default App;
Run Code Online (Sandbox Code Playgroud)
所以我最初的想法是尝试测试乘法函数。这样做了,这显然不起作用
import App from "../src/App";
test("Multiply", …Run Code Online (Sandbox Code Playgroud) 我正在 React 中将内联样式应用于 div
如果我做
<div style={{ backgroundImage: `url(${process.env.IMAGES}/${ID}.png)` }}>{children}</div>
Run Code Online (Sandbox Code Playgroud)
它工作正常,但改变为
<div style={{ maskImage: `url(${process.env.IMAGES}/${ID}.png)` }}>{children}</div>
Run Code Online (Sandbox Code Playgroud)
该样式甚至不会显示在代码检查器中。
可能出什么问题了?谢谢
我正在使用这样的东西在段落内的文本中建立链接
RichText(
text: TextSpan(
children: [
TextSpan(text: 'This is a going to be a Text which has '),
TextSpan(
text: 'single tap',
style: style,
recognizer: TapGestureRecognizer()
..onTap = () {
// single tapped
},
),
],
),
)
Run Code Online (Sandbox Code Playgroud)
现在,它工作正常,但是在文本上滚动时我不能有手形光标?
我正在寻找如何做到这一点并找到了这个
MouseRegion(
cursor: SystemMouseCursors.click,
child: Container(
height: 30,
width: 30,
color: Colors.red,
),
),
Run Code Online (Sandbox Code Playgroud)
但不可能将 TextSpans 之一包装在 Container 和 MouseRegion 中。
我为一个组织创建了一个存储库,而不是为我自己。创建存储库时,我输入了老板的电子邮件(或 github 句柄,我现在不记得了)。
现在我被要求转移存储库的所有权,但出现错误
You can only transfer a repository from an organization to yourself at this time
Run Code Online (Sandbox Code Playgroud)
这是什么意思?
谢谢
澄清一下,我使用不是来自公司的电子邮件创建了此存储库,因此我是“外部协作者”。
由于我是外部合作者,我可以转让为组织创建的存储库吗?
我是扑的新手。
我安装了这个库以便能够使用谷歌字体。
现在我需要在主题数据定义中这样做,并尝试这样但不允许
ThemeData appTheme() {
return ThemeData(
...
fontFamily: GoogleFonts.openSans(),
);
}
Run Code Online (Sandbox Code Playgroud)
我该怎么做呢?非常感谢
我需要使用 Web 和 html 中不同的 File 类(据我所知)
我希望能够做到
import if (dart.library.io) 'dart:io' if (dart.library.io) 'dart:html';
Run Code Online (Sandbox Code Playgroud)
但这行不通。
在移动应用程序上从 dart:io 和在网络中从 dart:html 读取文件的解决方案是什么?
谢谢
我正在根据此处解释的条件将元素推送到数组http://2ality.com/2017/04/conditional-literal-entries.html
const arr = [
...(cond ? ['a'] : []),
'b',
];
Run Code Online (Sandbox Code Playgroud)
现在,这很好用,但是当我尝试时
const arr = [
...(cond && ['a']),
'b',
];
Run Code Online (Sandbox Code Playgroud)
相反,它停止工作。
我想知道为什么它不再起作用,以及是否有办法使用扩展运算符和 && 而不是 ? 有条件地推送。
谢谢
flutter ×5
flutter-web ×4
reactjs ×3
javascript ×2
arrays ×1
css ×1
enzyme ×1
file ×1
fonts ×1
github ×1
google-fonts ×1
jestjs ×1
mask ×1
redux ×1
unit-testing ×1