我对 Flutter 和 BLoC 模式比较陌生,所以我仍然试图把我的头脑围绕在所有事情上。
假设我有一个测验应用程序,其中有一个名为 BLoC 的应用程序,QuestionBloc
它使用存储库从文件中获取问题。事件发生QuestionBloc
FetchQuestion
状态 QuestionBloc
QuestionEmpty
QuestionLoading
QuestionLoaded
其中包含一个问题对象QuestionError
然后我调用了另一个 BLoC QuestionValidatorBloc
,它负责验证问题的答案。答案被输入到一个文本字段中,并且有一个提交按钮来触发验证。事件发生QuestionValidatorBloc
ValidateQuestion
状态 QuestionValidatorBloc
ValidateInitial
ValidateInProgress
ValidateSuccess
ValidateError
这是相当直接的。不过,现在我需要二者结合QuestionBloc
并QuestionValidatorBloc
在同一个部件,因为其中一人负责获取和显示问题和其他处理验证动作。我怎样才能做到这一点?
<div class="p-4">
<div class="grid gap-4 sm:gap-8 grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 xl:grid-cols-6">
<img src="https://m.media-amazon.com/images/I/41bffUhJ4xL._SL500_.jpg" />
<img src="https://m.media-amazon.com/images/I/41bffUhJ4xL._SL500_.jpg" />
<img src="https://m.media-amazon.com/images/I/41bffUhJ4xL._SL500_.jpg" />
<img src="https://m.media-amazon.com/images/I/41bffUhJ4xL._SL500_.jpg" />
<img src="https://images.unsplash.com/photo-1612476464716-431a2751e006" />
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
如果我有这样的网格,如何强制图像具有 1:1 的宽高比?是的,我可以使用object-cover
,但是我需要设置固定的宽度/高度。有没有办法在保持动态宽度的同时做到这一点?
我的持续时间为14秒。
const duration = moment.duration(end.diff(startTime));
Run Code Online (Sandbox Code Playgroud)
如果我想将此持续时间显示为格式化字符串,则可以使用 .humanize()
duration.humanize(true)
// in a few seconds
Run Code Online (Sandbox Code Playgroud)
这可以正常工作,但是有没有办法暂时将其格式化为确切的持续时间,例如,in 14 seconds
或者更长的时间,in 2 days and 5 hours
而不是in 2 days
?
假设我有一条路线/ressource
。我可以使用查询参数来调用此路由,/ressource?param=ABC
我可以使用以下命令在 Node 中检索该参数:
app.get('/ressource', function (req, res) {
const parameter = req.query.param
})
Run Code Online (Sandbox Code Playgroud)
/ressource
现在,是否有一种预定义的方式,我可以要求该参数,该参数会在请求without时抛出错误?param=ABC
。
我正在尝试创建一个如下所示的布局:
_________
| | |
|1 | 2 |
|__|______|
| 3 | 4 |
|____|____|
Run Code Online (Sandbox Code Playgroud)
基本上,我希望第一行的单元格比单元格2薄,但第二行的单元格3和4应该具有相等的宽度。
甚至可以在PyQt4中使用QGridLayout创建这样的布局吗?
我有以下代码:
return Scaffold(
appBar: AppBar(
title: Text('Sample Code'),
),
body: ListView(
padding: const EdgeInsets.all(20.0),
children: <Widget>[
TextField(
decoration: InputDecoration(labelText: "Text"),
),
TextField(
decoration: InputDecoration(labelText: "Text"),
),
TextField(
decoration: InputDecoration(labelText: "Text"),
),
],
),
bottomNavigationBar: BottomAppBar(
child: Container(
height: 50.0,
),
),
floatingActionButton: FloatingActionButton(
onPressed: () {},
child: Icon(Icons.add),
),
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
);
Run Code Online (Sandbox Code Playgroud)
每当键盘出现并输入文本时,就会TextField
向上FloatingActionButton
移动到键盘顶部,如下所示:
我想要的是按钮保留在底部导航栏中,并且在键盘显示时不移动。我添加resizeToAvoidBottomPadding: false,
了Scaffold
,它可以防止按钮移动,但也阻止我ListView
移动以在键盘出现时保持可见。
我有三张桌子
旅程 |
---|
ID |
用户身份 |
... |
部分 |
---|
ID |
旅程_id |
... |
停止 |
---|
ID |
节号 |
... |
我想使用行级安全性来确保用户只能插入 astop
如果与via -> ->引用的the 相uid()
匹配。user_id
journey
stop
stops.section_id
sections.journey_id
journeys.user_id
换句话说,用户应该只能设置stops.section_id
为a section
,从而设置为journey
属于他的a。
如何在 Supabase 中通过行级安全连接实现此目的?
我正在使用Ant Design Upload组件。有没有一种方法可以将选定文件的内容作为JavaScript中的字符串来显示在页面上?
理想情况下,我想访问file.data
什么。
<Upload
accept=".txt, .csv"
showUploadList={false}
beforeUpload={(file, fileList) => {
// Access file content here and do something with it
console.log(file);
// Prevent upload
return false;
}}
>
<Button>
<Icon type="upload" /> Click to Upload
</Button>
</Upload>
Run Code Online (Sandbox Code Playgroud)