dart - 如何设置CrossAxisAlignment的值?

标签 dart alignment flutter

我想在flutter中设置Column类的位置值(作为列表)。通常设置诸如CrossAxisAlignment.center之类的设置会将所有子代的位置设置为中心。但是,还有一个称为const List的“values”参数,该参数会相应地设置列表中子级的值,但会给我错误“Error:setter values not found”(我找不到Lister.values),但它给出了同样的错误。定义CrossAxisAlignment值的正确方法是什么?
这是类(class)引用:https://docs.flutter.io/flutter/rendering/CrossAxisAlignment-class.html

这是整个代码lib / main.dart:

import 'package:flutter/material.dart';

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

class SoundRecorder extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
   return MaterialApp(
     home: DefaultTabController(
        length: 2,
        child: Scaffold(
         appBar: AppBar(
            bottom: TabBar(
              tabs: [
               Tab(text: 'Record'),
            Tab(text: 'Saved Recordings'),
          ],
        ),
        title: Text('Tabs Demo'),
      ),
      body: TabBarView(
        children: [ 


                new Column(               
          crossAxisAlignment:CrossAxisAlignment.values = [CrossAxisAlignment.center, CrossAxisAlignment.center],
          mainAxisSize: MainAxisSize.max,
          children: [ new Text("this is it"),
          new FloatingActionButton(
          elevation: 0.0,
          child: new Icon(Icons.check),
          backgroundColor: new Color(0xFFE57373),
          onPressed: (){}
        )]
            ),
                  new Center(child:  new FloatingActionButton(
               elevation: 0.0,
             child: new Icon(Icons.check),
            backgroundColor: new Color(0xFFE57373),
          onPressed: (){}
        )
        )

        ],
      ),
    ),
  ),
);
 }
}

最佳答案

values是所有枚举中唯一的值。
它是所有潜在枚举值的列表。

这意味着CrossAxisAlignment.values不能分配给Column.crossAxisAlignment

相反,当您需要遍历所有可能的类型以执行某种操作时,可以使用它。

关于dart - 如何设置CrossAxisAlignment的值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51040091/

相关文章:

html - <ul> 菜单不会居中

javascript - 在父 DIV 中垂直对齐单个 DIV(img)

firebase - Firestore如何从文档快照流中的快照访问值

dart - 有没有办法检查一个类是否是抽象的?

flutter - 如何在向上滚动时隐藏应用程序栏,但在向下滚动时显示呢?

dart - 如何从 flutter 应用程序中删除 native 启动画面?

android - 来自 adb : Invalid argument(s): The source must not be null Error launching application on device 的 Flutter 意外失败

github - Dart 常量时间字符串比较

html - 在中间的图像上添加文本

dart - 添加和收听流时传递了什么,它是如何使用的?