return Scaffold(
appBar: AppBar(
// Here we take the value from the MyHomePage object that was created by
// the App.build method, and use it to set our appbar title.
title: Text(widget.title),
),
body: const Positioned(
left: 100,
height: 50,
child: SizedBox(
width: 100,
height: 100,
child: Text("111"),
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: const Icon(Icons.add),
), // This trailing comma makes auto-formatting nicer for build methods.
);
我在flutter中遇到了一个“Incorrect use of ParentDataWidget.”错误。是什么原因导致了这种错误,如何把握Flutter中布局的基本原理?
Flutter布局是否有任何规则以及如何找到它们?
1条答案
按热度按时间zzlelutf1#
错误消息应该告诉您更多信息并告诉您原因。它应该这样写:
换句话说:
Positioned
只能在Stack
小工具中使用。因此,要修复错误,您可以将其 Package 在Stack
中,例如