Flutter - FloatingActionButton in the center

前端 未结 10 1270
无人及你
无人及你 2020-12-15 18:18

Is it possible to make the FloatingActionButton in the centre instead of the right side?

import \'package:flutter/material.dart\';
import \'numb         


        
10条回答
  •  [愿得一人]
    2020-12-15 19:15

    By changing the logic to use crossAxisAlignment, the mainAxisAlignment and the Flexible the FloatingActionButton were centered at the bottom of the screen

    import 'package:flutter/material.dart';
    import 'number.dart';
    import 'keyboard.dart';
    
    class ContaPage extends StatelessWidget {
      @override
      Widget build(BuildContext context) => new Scaffold(
        body: new Column(
          crossAxisAlignment: CrossAxisAlignment.center,
          mainAxisAlignment: MainAxisAlignment.spaceBetween,       
          children: [
            new Number(),
            new Keyboard(),
            new Flexible(
              child: new Container(
                padding: new EdgeInsets.only(bottom: 16.0),
                child: new FloatingActionButton(
                  elevation: 0.0,
                  child: new Icon(Icons.check),
                  backgroundColor: new Color(0xFFE57373),
                  onPressed: (){}
                )
              )         
            )
          ],
        ), 
      );
    }
    

提交回复
热议问题