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) { return new Scaffold( appBar: detectOrientationForAppBar(), backgroundColor: Colors.black, key: _scaffoldKey, body: new Column(

我有一个堆栈中的视图,我希望它保持固定在手机底部时,它是转向景观。目前我有以下几点:

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: detectOrientationForAppBar(),
      backgroundColor: Colors.black,
      key: _scaffoldKey,
      body: new Column(
        children: <Widget>[
          new Expanded(
            child: new Stack(
              children: <Widget>[
                new Container(
                  height: double.infinity,
                  width: double.infinity,
                  child: new Padding(
                    padding: const EdgeInsets.all(1.0),
                    child: new Center(
                      child: _cameraPreviewWidget(),
                    ),
                  ),
                ),
                _captureControlRowWidget()
              ],
            ),
          ),
        ],
      ),
    );
  }
我试过一些方法,比如使用横轴和主轴对齐,但它总是粘在手机最低的边缘。e、 g如果我将手机放在手机的底部,如果我将手机向任一方向旋转90度,手机的小部件应该位于手机的右侧。

此时,你的主体是一个柱,因此,正如预期的那样,你的控制小部件位于相机预览下方。在横向模式下,您希望控制小部件位于相机预览的右侧,这意味着您希望主体成为一行

您可以通过将顶部列更改为Flex来实现这一点,Flex是一个开关可选的行/列

@override
Widget build(BuildContext context) {
  bool landscape = MediaQuery.of(context).orientation == Orientation.landscape;
  return new Scaffold(
    appBar: detectOrientationForAppBar(),
    backgroundColor: Colors.black,
    key: _scaffoldKey,
    body: new Flex(
      direction: landscape ? Axis.horizontal : Axis.vertical,
您必须在captureControlRowWidget中进行相同的更改,将其列和行设置为方向敏感的Flex

@override
Widget build(BuildContext context) {
  bool landscape = MediaQuery.of(context).orientation == Orientation.landscape;
  return new Scaffold(
    appBar: detectOrientationForAppBar(),
    backgroundColor: Colors.black,
    key: _scaffoldKey,
    body: new Flex(
      direction: landscape ? Axis.horizontal : Axis.vertical,