如何在Flutter中删除两个容器之间的空间?

编程入门 行业动态 更新时间:2024-10-28 08:21:14
本文介绍了如何在Flutter中删除两个容器之间的空间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在Column小部件内有两个高度为250的容器.在这两个Container窗口小部件之间没有任何其他窗口小部件,但是我仍然可以看到两个容器之间的空间很小.

I have two Containers of height 250 inside Column widget. There is no any other widget present between this two Container widget but still I can see very little space between two containers.

这是我的代码...

import 'package:flutter/material.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Demo', home: Example(), ); } } class Example extends StatelessWidget { @override Widget build(BuildContext context) { double height = 250; TextStyle containerTextStyle = TextStyle(color: Colors.white, fontSize: 24); return Scaffold( body: Column( children: <Widget>[ Container( height: height, color: Colors.black, child: Center( child: Text('Container 1', style: containerTextStyle), ), ), Container( height: height, color: Colors.black, child: Center( child: Text('Container 2', style: containerTextStyle), ), ), ], ), ); } }

我不知道为什么,但是如果我将此容器的高度设置为100或400,则容器之间不会显示任何空间.并没有尝试使用许多不同的高度值,但是空间对于某些值可见,而对于其他值则不可见.

I don't know why but if I set the height of this containers to 100 or 400 it is not showing any space between container. Did not try with many different values for height but space is visible for some value and not visible for other value.

这是我手机上的屏幕截图...

Here's the screenshot from my phone...

两个容器的高度均等于250

两个容器的高度均等于400

推荐答案

为此替换支架:

return Scaffold( body: Column( children: <Widget>[ Container( height: height, decoration: BoxDecoration( border: Border.all(width: 0, color: Colors.black), color: Colors.black, ), child: Center( child: Text('Container 1', style: containerTextStyle), ), ), Container( height: height, decoration: BoxDecoration( border: Border.all(width: 0, color: Colors.black), color: Colors.black, ), child: Center( child: Text('Container 2', style: containerTextStyle), ), ), ], ), );

更多推荐

如何在Flutter中删除两个容器之间的空间?

本文发布于:2023-10-08 09:54:48,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1472281.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:容器   两个   如何在   空间   Flutter

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!