小编Kol*_*lac的帖子

ElevatedButton 占据全宽

老实说,我对 Flutter 和开发还很陌生。我一直在尝试让每个按钮在点击时改变颜色;它确实有效,但我有一个问题,按钮占据了所有水平空间。我尝试并寻找我能做的方法。有什么办法可以改变宽度吗?

它看起来像这样: https: //ibb.co/rFNfSf4

class Home extends StatefulWidget {
      @override
      State<Home> createState() => _HomeState();
    }
    
    class _HomeState extends State<Home> {
      List<bool> isSelected = [false, false, false, false];
    
      @override
      Widget build(BuildContext context) {
        return MaterialApp(
          debugShowCheckedModeBanner: false,
          home: Scaffold(
            backgroundColor: Colors.grey[850],
            appBar: AppBar(
              title: Text(
                "A Sample Quiz",
                style: TextStyle(
                  letterSpacing: 1.3,
                  fontFamily: "SourceCodePro",
                ),
              ),
              centerTitle: true,
              backgroundColor: Colors.grey[900],
              elevation: 2.0,
            ),
            body: Center(
              child: Column(
                children: <Widget>[
                  SizedBox(
                    height: 20.0,
                  ),
                  Text(
                    "Choose all that apply:",
                    style: …
Run Code Online (Sandbox Code Playgroud)

button flutter flutter-layout

6
推荐指数
1
解决办法
4219
查看次数

标签 统计

button ×1

flutter ×1

flutter-layout ×1