Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flutter 将颤振窗口小部件定位到屏幕外_Flutter - Fatal编程技术网

Flutter 将颤振窗口小部件定位到屏幕外

Flutter 将颤振窗口小部件定位到屏幕外,flutter,Flutter,正如标题所提到的,我正试图将我的小部件定位到屏幕外。目前,我已经设法将小部件图像从屏幕上偏移,但这并不是我所期望的结果。屏幕外的图像在状态栏上仍然可见 这就是它的样子 这就是我期望它的样子(在AdobeXD中设计) 我曾尝试在堆栈中使用定位的小部件,但是当我尝试将新小部件添加到堆栈的子级时,它会导致更多的溢出问题 我确信有一个合适的方法将小部件放置在绝对位置。有人能帮我吗 尝试使用并使用MediaQuery定位 @override Widget build(BuildContext co

正如标题所提到的,我正试图将我的小部件定位到屏幕外。目前,我已经设法将小部件图像从屏幕上偏移,但这并不是我所期望的结果。屏幕外的图像在状态栏上仍然可见

这就是它的样子

这就是我期望它的样子(在AdobeXD中设计)

我曾尝试在
堆栈中使用
定位的
小部件,但是当我尝试将新小部件添加到
堆栈的子级时,它会导致更多的溢出问题

我确信有一个合适的方法将小部件放置在绝对位置。有人能帮我吗

尝试使用并使用MediaQuery定位

@override
  Widget build(BuildContext context) {
    return SafeArea(
      child: Scaffold(
      backgroundColor: Palette.primaryBackground,
        body: Container(
          child: Image.network(
            'https://picsum.photos/250?image=9',
            fit: BoxFit.scaleDown,
//             alignment: new Alignment(1.4, -1.2),
          ),
          transform: Matrix4.translationValues(
              MediaQuery.of(context).size.width * .8, -50.0, 0.0),
        ),
      ),
    );
  }

可以在溢出可见的情况下使用堆栈:

 Stack(
  overflow: Overflow.visible,
  children: <Widget>[
    //using Positioned to control position
  ],
)
堆栈(
溢出:溢出。可见,
儿童:[
//使用定位来控制位置
],
)

解决方案

我添加了高度为200的sizedBox,将文本向下推到屏幕中间,如果不是所有列都从顶部开始,则继续子列

@override
Widget build(BuildContext context) {
  return SafeArea(
    child: Scaffold(
      body: Container(
        width: MediaQuery.of(context).size.width,
        color: Palette.primaryBackground,
        child: Stack(
          overflow: Overflow.clip,
          children: <Widget>[
            Positioned(
              top: -60,
              right: -80,
              child: Image.asset('assets/Splash.png'),
            ),
            Center(
              child: Column(
                mainAxisSize: MainAxisSize.max,
                children: <Widget>[
                  SizedBox(
                    height: 200,
                  ),
                  Text('hello'),
                ],
              ),
            )
          ],
        ),
      ),
    ),
  );
}
@覆盖
小部件构建(构建上下文){
返回安全区(
孩子:脚手架(
主体:容器(
宽度:MediaQuery.of(context).size.width,
颜色:Palette.primaryBackground,
子:堆栈(
溢出:overflow.clip,
儿童:[
定位(
前-60,
右:-80,
子级:Image.asset('assets/Splash.png'),
),
居中(
子:列(
mainAxisSize:mainAxisSize.max,
儿童:[
大小盒子(
身高:200,
),
Text('hello'),
],
),
)
],
),
),
),
);
}

发布一张显示您期望的图像。@ArnoldParge添加了将溢出值更改为
溢出。clip
可以工作,但是,如果我在我的列中添加另一个小部件(与堆栈级别相同),它会给我一个错误
底部的RenderFlex溢出无限像素。
。知道为什么吗?它返回相同的结果,图像仍然溢出状态栏上方。
@override
Widget build(BuildContext context) {
  return SafeArea(
    child: Scaffold(
      body: Container(
        width: MediaQuery.of(context).size.width,
        color: Palette.primaryBackground,
        child: Stack(
          overflow: Overflow.clip,
          children: <Widget>[
            Positioned(
              top: -60,
              right: -80,
              child: Image.asset('assets/Splash.png'),
            ),
            Center(
              child: Column(
                mainAxisSize: MainAxisSize.max,
                children: <Widget>[
                  SizedBox(
                    height: 200,
                  ),
                  Text('hello'),
                ],
              ),
            )
          ],
        ),
      ),
    ),
  );
}