简体   繁体   中英

how do I remove fab bottom padding in scaffold

widgets used as fab in a scaffold
seem to have padding by default

see dartpad example

import 'package:flutter/material.dart';

void main() => runApp(
      MaterialApp(
        home: Scaffold(
          floatingActionButtonLocation:
              FloatingActionButtonLocation.centerFloat,
          floatingActionButton: Padding(
            padding: EdgeInsets.zero,
            child: Container(height: 56, color: Colors.red),
          ),
        ),
      ),
    );

how do I remove the padding at the bottom of the red container?

the current (lame) workaround being

import 'package:flutter/material.dart';

void main() => runApp(
      MaterialApp(
        home: Scaffold(
          floatingActionButtonLocation:
              FloatingActionButtonLocation.centerFloat,
+         bottomSheet: Container(height: 16, color: Colors.red),
          floatingActionButton: Padding(
            padding: EdgeInsets.zero,
            child: Container(height: 56, color: Colors.red),
          ),
        ),
      ),
    );

Just change floatingActionButton location:

floatingActionButtonLocation: 
              FloatingActionButtonLocation.centerFloat

to

floatingActionButtonLocation:
              FloatingActionButtonLocation.centerDocked,

result: 在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM