去除Flutter支架中FAB上的底边

pinkon5k  于 2023-02-25  发布在  Flutter
关注(0)|答案(1)|浏览(106)

试图创建一个底部晶圆厂,位于屏幕的最底部。然而,有额外的填充被添加到按钮下方的大型iPhone设备。我如何删除它?

import 'package:flutter/material.dart';

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

xxhby3vn

xxhby3vn1#

可以在main函数中添加此行

SystemChrome.setEnabledSystemUIMode(
      SystemUiMode.manual,
      overlays: [
        SystemUiOverlay.top, // Shows Status bar and hides Navigation bar
      ],
    );

像这样:

import 'package:flutter/material.dart';
    import 'package:flutter/services.dart';

    void main() {
      WidgetsFlutterBinding.ensureInitialized();
      SystemChrome.setEnabledSystemUIMode(
        SystemUiMode.manual,
        overlays: [
          SystemUiOverlay.top, // Shows Status bar and hides Navigation bar
        ],
      );
      runApp(const MyApp());
    }
    
    class MyApp extends StatelessWidget {
      const MyApp({Key? key}) : super(key: key);
    
      @override
      Widget build(BuildContext context) {
        return MaterialApp(
  home: Scaffold(
        bottomNavigationBar: Padding(
          padding: EdgeInsets.zero,
          child: Container(height: 56, color: Colors.red),
        ),
      ),
        );
      }
    }

相关问题