Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/dart/3.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/9.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
Dart 颤振:向图像添加浮动动作按钮_Dart_Flutter - Fatal编程技术网

Dart 颤振:向图像添加浮动动作按钮

Dart 颤振:向图像添加浮动动作按钮,dart,flutter,Dart,Flutter,我正在尝试将浮动操作按钮添加到图像中。该按钮将用于更改所选图像。我希望按钮浮动在图像的右下角。到目前为止,我所能做的就是在图像的正下方添加浮动操作按钮。谢谢你的帮助 @override Widget build(BuildContext context) { // Create the view scaffold. Use a list view so things scroll. return new Scaffold( appBar: new AppBar( t

我正在尝试将浮动操作按钮添加到图像中。该按钮将用于更改所选图像。我希望按钮浮动在图像的右下角。到目前为止,我所能做的就是在图像的正下方添加浮动操作按钮。谢谢你的帮助

@override
Widget build(BuildContext context) {

  // Create the view scaffold. Use a list view so things scroll.
  return new Scaffold(
    appBar: new AppBar(
      title: new Text("My Title"),
    ),
    body: new ListView(
      children: [
        new Container(
          padding: EdgeInsets.zero,
          child: new Image.asset(
            "assets/images/background_image.png",
            fit: BoxFit.fitWidth,
          ),
        ),
        new FloatingActionButton(
          child: const Icon(Icons.camera_alt),
          backgroundColor: Colors.green.shade800,
          onPressed: () {},
        ),
        new Divider(),
        new ListTile(
          title: new Text('Email'),
          leading: const Icon(Icons.email),
          onTap: () {},
        ),
        new Divider(),
      ],
    ),
  );
}

您可以使用
堆栈
定位
小部件,您可以在此处阅读这些小部件:

堆栈:

定位:

返回新脚手架(
appBar:新的appBar(
标题:新文本(“我的标题”),
),
正文:新列表视图(
儿童:[
堆叠(
儿童:[
新容器(
填充:EdgeInsets.zero,
子:新建Image.asset(
“assets/images/background_image.png”,
适合:BoxFit.fitWidth,
)),
定位(
右:0.0,
底部:0.0,
子:新的浮动操作按钮(
子项:常量图标(Icons.camera_alt),
背景颜色:Colors.green.shade800,
按下:(){},
),
),
],
),
新分隔符(),
新ListTile(
标题:新文本(“电子邮件”),
引导:常量图标(Icons.email),
onTap:(){},
),
新分隔符(),
],
),
);

这正是我所需要的。谢谢
        return new Scaffold(
              appBar: new AppBar(
                title: new Text("My Title"),
              ),
              body: new ListView(
                children: [
                  Stack(
                    children: <Widget>[
                      new Container(
                          padding: EdgeInsets.zero,
                          child: new Image.asset(
                        "assets/images/background_image.png",
                        fit: BoxFit.fitWidth,
                      )),
                      Positioned(
                        right: 0.0,
                        bottom: 0.0,
                        child: new FloatingActionButton(
                          child: const Icon(Icons.camera_alt),
                          backgroundColor: Colors.green.shade800,
                          onPressed: () {},
                        ),
                      ),
                    ],
                  ),
                  new Divider(),
                  new ListTile(
                    title: new Text('Email'),
                    leading: const Icon(Icons.email),
                    onTap: () {},
                  ),
                  new Divider(),
                ],
              ),
            );