我有一个垂直的scrollView,然后是一个水平的pageView,其中包含包裹在其中的图像InteractiveViewer。
但当我尝试使用 InteractiveViewer 进行放大时,情况相当混乱。所有这些滚动视图都在争夺手势,我想找到一种更简单的方法来解决这个问题。
编辑:所以问题似乎出在 onScale 手势(GestureDetector())或 2 个指针手势上
我有类似的东西
CustomScrollView(
slivers: [
const SliverToBoxAdapter(
child: Container(
width: double.infinity,
height: 400,
child: PageView(
...
InteractiveViewer()
...
)
)
),
]
)
Run Code Online (Sandbox Code Playgroud) 我一直在努力解决这个 1H30 的问题,以及如何用二分搜索来解决。我找到了答案,但我无法理解其背后的逻辑。得到它的人可以引导我完成这个答案吗?
这是问题
任务描述
给定整数 K、M 和一个由 N 个整数组成的非空零索引数组 A。数组的每个元素都不大于M。
您应该将此数组分为 K 个连续元素块。块的大小是 0 到 N 之间的任何整数。数组的每个元素都应该属于某个块。
从 X 到 Y 的块的总和等于 A[X] + A[X + 1] + ... + A[Y]。空块的总和等于0。
大和是任何块的最大和。
例如,给定整数 K = 3、M = 5 和数组 A,使得:
A[0] = 2 A[1] = 1 A[2] = 5 A[3] = 1 A[4] = 2 A[5] = 2
A[6] = 2例如,该数组可以分为以下块:
[2, 1, 5, 1, 2, 2, 2], [], [] 且总和为 15;[2], [1, 5, 1, 2], [2, 2] …
我有一个分隔线,我想在其上创建一个底部阴影,所以基本上我想要一条带有底部阴影的线。
我怎样才能做到这一点?
Divider(height:1)
Run Code Online (Sandbox Code Playgroud) 我正在尝试将容器 appBar 的子项(即文本)垂直居中,我是 flutter 新手,所以我在这里缺少什么。它只是水平居中
小部件
import 'package:flutter/material.dart';
class MyAppbar extends StatelessWidget implements PreferredSizeWidget {
final Widget title;
const MyAppbar({Key key, this.title}) : super(key: key);
@override
Widget build(BuildContext context) {
return Material(
elevation: 0.0,
color: Colors.white,
child: Container(
padding: const EdgeInsets.all(0.0),
alignment: Alignment.center,
decoration: BoxDecoration(
color: Colors.red,
border: Border(
bottom: BorderSide(
color: Color(0xffd9d9d9),
width: .8,
style: BorderStyle.solid,
),
),
),
child: Center(child: title),
),
);
}
final Size preferredSize = const Size.fromHeight(kToolbarHeight);
}
Run Code Online (Sandbox Code Playgroud)
我在哪里称呼它
Scaffold(
appBar: MyAppbar(title: Text('Welcome to Ikaze', …Run Code Online (Sandbox Code Playgroud) 所以我有一些表格,我试图按日期分类,标题像(今天,昨天,上周,......),我试图根据视口中的当前表格使它们具有粘性。我尝试react-sticky专门使用该库,the stacked example因为它似乎是我正在寻找的效果,但我无法重新创建它。
拜托,我是否遗漏了一些关于图书馆使用的东西。
也非常欢迎没有图书馆的解决方案
我一直在尝试的
export default function CustomizedTables() {
const classes = useStyles();
return (<StickyContainer>
<Sticky topOffset={20}>
{(props) => (<div className={reduceCSS.tableHistoryTitle_day}>Today</div>)}
</Sticky>
<TableContainer component={Paper} elevation={0}>
<Table className={classes.table} aria-label="customized table">
<TableBody>
{rows.map((row) => (
<StyledTableRow key={row.name} elevation={0}>
<StyledTableCell align="left" className={classes.iconCell}><AssignmentReturnedSharpIcon className={classes.inputIcon} /></StyledTableCell>
<StyledTableCell align="left">{row.calories}</StyledTableCell>
<StyledTableCell component="th" scope="row">
{row.name}
</StyledTableCell>
<StyledTableCell align="right">{row.fat}</StyledTableCell>
<StyledTableCell align="right">{row.carbs}</StyledTableCell>
<StyledTableCell align="right">{row.protein}</StyledTableCell>
</StyledTableRow>
))}
</TableBody>
</Table>
</TableContainer>
</StickyContainer>
);
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试使嵌套的 Sliver 标题具有粘性。
我无法将“today”标题粘在“bruh”标题(粘性的)下方。让它感觉像一些折叠的标题。
有人可以帮忙吗
class ListExample extends StatelessWidget {
const ListExample({
Key key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return AppScaffold(
title: 'List Example',
slivers: [
SliverToBoxAdapter(child: SoldEntryPage(),),
_StickyHeaderDateSort(index: 34),
],
);
}
}
Run Code Online (Sandbox Code Playgroud)
class _StickyHeaderDateSort extends StatelessWidget {
const _StickyHeaderDateSort({
Key key,
this.index,
}) : super(key: key);
final int index;
@override
Widget build(BuildContext context) {
return SliverStickyHeader(
header: HeaderDatePicker(), // this the 'bruh' sticky header
sliver: SliverToBoxAdapter(
child: ShrinkWrappingViewport( // THis me trying to nest …Run Code Online (Sandbox Code Playgroud) 我需要带有两部分的圆角圆圈图标,具有不同的颜色。
我尝试使用 ShadeMask 我的尝试似乎非常失败。
注意:我不需要渐变,只需一部分是一种颜色,另一部分是另一种颜色
class HalfFilledIcon extends StatelessWidget {
HalfFilledIcon(
this.icon,
this.size,
this.gradient,
);
final IconData icon;
final double size;
final Gradient gradient;
@override
Widget build(BuildContext context) {
return ShaderMask(
child: SizedBox(
width: size,
height: size,
child: Icon(
icon,
size: size,
color: Colors.grey[300],
),
),
shaderCallback: (Rect bounds) {
final Rect rect = Rect.fromLTRB(0, 0, size / 2, 0);
return gradient.createShader(rect);
},
);
}
}
Run Code Online (Sandbox Code Playgroud) 在对其数据执行验证后,我试图用它的数据恢复上下文。我需要数据在下一个函数中根据需要继续移动。
我是 golang 的新手,下面的代码是我所能做的。非常感谢任何帮助和更好的方法。
提前致谢。
验证中间件
func SignupValidator(c *gin.Context) {
// Read the Body content
// var bodyBytes []byte
// if c.Request.Body != nil {
// bodyBytes, _ = ioutil.ReadAll(c.Request.Body)
// }
var user entity.User
if err := c.ShouldBindJSON(&user); err != nil {
validate := validator.New()
if err := validate.Struct(&user); err != nil {
c.JSON(http.StatusBadRequest, gin.H{
"error": err.Error(),
})
c.Abort()
return
}
// c.Request.Body = ioutil.NopCloser(bytes.NewBuffer(bodyBytes))
}
// Read the Body content
var bodyBytes []byte
if c.Request.Body != nil { …Run Code Online (Sandbox Code Playgroud) 所以我去了传单文档并复制粘贴的示例,我在那里找到了看看是否可以重现地图,但是,地图不仅损坏了,而且还与它所在的容器重叠。我试图给出宽度和.leaflet-container高度的固定值,但是他们甚至没有被认可。
所以我的问题是我有什么遗漏的吗?
传单组件示例
import 'leaflet/dist/leaflet.css';
export default class LeafletMap extends Component {
constructor() {
super()
this.state = {
lat: 51.505,
lng: -0.09,
zoom: 13
}
}
render() {
const position = [this.state.lat, this.state.lng];
return (
<Map center={position} zoom={this.state.zoom}>
<TileLayer
attribution='© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
url='https://{s}.tile.osm.org/{z}/{x}/{y}.png'
/>
<Marker position={position}>
<Popup>
A pretty CSS3 popup. <br/> Easily customizable.
</Popup>
</Marker>
</Map>
);
}
}
Run Code Online (Sandbox Code Playgroud)
它正在被导入,就像
<div className="hotel_description_card_right">
<div className="hotel_description_card_right_container">
<LeafletMap /> // here
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
现在看起来怎么样
尝试学习 golang,但我对在验证中间件中使用context.Request.Body及其感到迷失struct
简要说明它们如何相互连接,预先感谢您的帮助
我的中间件
package validations
import (
"github.com/bihire/ikaze_server_app/entity"
"net/http"
"github.com/gin-gonic/gin"
"github.com/go-playground/validator/v10"
)
func SignupValidator(c *gin.Context) {
// user := c.Request.Body
var user entity.User
validate := validator.New()
if err := validate.Struct(&user); err != nil {
c.JSON(http.StatusBadRequest, gin.H{
"error": err.Error(),
})
}
}
Run Code Online (Sandbox Code Playgroud)
我的结构
package entity
type User struct {
Username string `json:"username" validate:"required"`
Email string `json:"email" validate:"email"`
Password string `json:"password" validate:"min=8,max=32,alphanum"`
ConfirmPassword string `json:"confirm_password" validate:"eqfield=Password,required"`
}
Run Code Online (Sandbox Code Playgroud)
返回响应错误
{
"error": "Key: 'User.Username' Error:Field validation for 'Username' failed on …Run Code Online (Sandbox Code Playgroud) 例如在 ExpressJS 中我的路线看起来像这样
router.patch('/:id/approve', AuthMiddleware.verifyToken,
AuthMiddleware.isSuperAdmin, AccommodationMiddleware.param, Accommodation.accommodationApprove);
Run Code Online (Sandbox Code Playgroud)
我会创建一个全局变量并在任何地方访问它,就像
req.somevariable = somevariable
这在 go-gin 中可能吗,那么怎么做呢?我需要跨中间件传递数据,但我不知道如何
我正在尝试使用组件方法来访问createRef(),但是我收到了TypeError: modalRef.current is null错误。
我以前从未使用过参考文献,因此如果它错误,则会指导如何实现我想要做的事情。
这是我的尝试
const parent = () => {
const modalRef = createRef();
const onBtnClick = () => {
modalRef.current.upadeState();
}
return(
<div>
<button onclick={onBtnClick}>bro</button>
<Modal ref={modalRef} />
</div>
)
}
Run Code Online (Sandbox Code Playgroud)
莫代尔
export default Modal = () => {
const upadeState = () => {
console.log('It works fam');
}
return(
<div>
bro we here
</div>
)
}
Run Code Online (Sandbox Code Playgroud) flutter ×5
javascript ×4
go ×3
go-gin ×3
reactjs ×3
algorithm ×1
css ×1
dart ×1
gesture ×1
html ×1
leaflet ×1
next.js ×1
react-hooks ×1
react-sticky ×1