Flutter 定位小部件无效|如何定位容器

Flutter 定位小部件无效|如何定位容器,flutter,Flutter,我还是个新手,我想在下面的屏幕截图中定位框,不是在屏幕的中心,而是在离左侧一定距离的地方,框内有文本 我尝试了定位小部件,但仍然没有成功 关于我将使用什么小部件,以及如何正确使用,有什么建议吗 @override Widget build(BuildContext context) { return DecoratedBox( decoration: BoxDecoration( image: DecorationImage(

我还是个新手,我想在下面的屏幕截图中定位框,不是在屏幕的中心,而是在离左侧一定距离的地方,框内有文本

我尝试了
定位
小部件,但仍然没有成功

关于我将使用什么小部件,以及如何正确使用,有什么建议吗

@override
  Widget build(BuildContext context) {
    return DecoratedBox(
        decoration: BoxDecoration(
          image: DecorationImage(
              image: AssetImage("assets/startbackground.jpg"),
              fit: BoxFit.cover),
        ),
        child: Center(
          child: Container(
            height: 500.0,
            width: 120.0,
            color: Colors.blue[50],
            child: Align(
              alignment: Alignment.topRight,
              child: FlutterLogo(
                size: 60,
              ),
            ),
          ),
        ));
  }
}


试试那个代码。我主要使用容器、填充物、对齐特性以及柱的轴对齐。有了这些,我实现了你可以在下面的截图上看到的目标。为了在所有这些后面使用一个映像,我只建议使用一个堆栈,然后对整个代码进行一些修改。这些颜色只是说明性的。您可以将它们全部设置为透明

以下是截图:

代码如下:

import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.blue,
      appBar: AppBar(
        title: Text("EXAMPLE"),
      ),
      body: Container(
        color: Colors.orangeAccent,
        height: double.infinity,
        width: double.infinity,
        alignment: Alignment.bottomLeft,
        child: UnconstrainedBox(
          child: Padding(
            padding: const EdgeInsets.only(left: 50, bottom: 50),
            child: Container(
              height: 400,
              width: 200,
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Expanded(
                    flex: 1,
                    child: Container(
                      child: Text("Text", style: TextStyle(fontSize: 30, fontWeight: FontWeight.w700),textAlign: TextAlign.left,),
                      color: Colors.purpleAccent,
                    ),
                  ),
                  Expanded(
                    flex: 3,
                    child: Container(
                      child: Text("Some Text", style: TextStyle(fontSize: 60, fontWeight: FontWeight.w700),),
                      color: Colors.purpleAccent,
                    ),
                  ),
                  Expanded(
                    flex: 3,
                    child: Container(
                      child: Text("Some Text", style: TextStyle(fontSize: 60, fontWeight: FontWeight.w700),),
                      color: Colors.teal,
                    ),
                  ),
                  Expanded(
                    flex: 2,
                    child: Padding(
                      padding: EdgeInsets.all(15),
                      child: FlatButton(
                        minWidth: 200,
                        onPressed: (){},
                        child: Text(
                          "HI",
                          style: TextStyle(
                              color: Color(0xff7638c9),
                              fontSize: 11),
                        ),
                        color: Colors.transparent,
                        shape: RoundedRectangleBorder(
                          side: BorderSide(color: Colors.purple),
                          borderRadius: BorderRadius.circular(18.0),
                        ),
                      ),
                    ),
                  ),
                ],
              ),
            ),
          ),
        ),
      ),
    );
  }
}

容器有一个属性-
align
useit@theiskaa但这是标志,而不是容器本身。有什么想法吗?好的,现在你应该用新容器包装你的容器,并让这个新容器对齐。试试这个OK。我看到你添加了图像。请给我几分钟这个问题没有答案。我已回滚/编辑您的问题并删除了答案。只在答案部分添加答案。谢谢,伙计。如果我有任何后续问题,我会在帖子中评论!伟大的你让我知道!