Positioned class

官方文档Positioned class

Positioned class

A widget that controls where a child of a Stack is positioned.

一个用来控制它的子控件在Stack中的放置位置。

A Positioned widget must be a descendant of a Stack, and the path from the Positioned widget to its enclosing Stack must contain only StatelessWidgets or StatefulWidgets (not other kinds of widgets, likeRenderObjectWidgets).

一个Positiond控件必须是Stack的子控件,在Positiond控件与装入它的Stack之间,必须只包含StatelessWidget或者StatefulWidget。(不能是别的类型,比如RenderObjectWidget)。

If a widget is wrapped in a Positioned, then it is a positioned widget in its Stack. If the top property is non-null, the top edge of this child will be positioned top layout units from the top of the stack widget. The right, bottom, and left properties work analogously.

如果一个控件被Positioned包裹,那么它在Stack中就是一个已经定位的控件。如果top属性不为空,则这个widget的顶部将与Stack的顶部间隔与top值相等单位的距离。右侧,底部和左侧属性的工作方式类似。

If both the top and bottom properties are non-null, then the child will be forced to have exactly the height required to satisfy both constraints. Similarly, setting the right and left properties to non-null values will force the child to have a particular width. Alternatively the width and height properties can be used to give the dimensions, with one corresponding position property (e.g. top and height).

如果topbottom属性都不为空,则控件将被赋予满足这两项约束的高度。相同的,设置leftright属性,将为控件赋予满足约束的宽度。或者给出宽度或者高度属性,加上一个相应的位置属性,来声明控件尺寸(比如,topheight)。

If all three values on a particular axis are null, then the Stack.alignment property is used to position the child.

如果三个特定轴上的值都为空,则Stack.alignment属性将用来为子控件排序。

If all six values are null, the child is a non-positioned child. The Stack uses only the non-positioned children to size itself.

如果所有六个值都为空,则子控件是一个未定位的控件。Stack将会让未定位控件适应它的大小。

See also:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
这是我的全部flutter代码,你看下为什么字体没有根据textStyle而改变大小:import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; void main() { runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({super.key}); // This widget is the root of your application. @override Widget build(BuildContext context) { return ScreenUtilInit( designSize: const Size(240, 320), minTextAdapt: true, splitScreenMode: true, builder: (context, child) { return myApp(); }, ); } } class myApp extends StatelessWidget { const myApp({super.key}); @override Widget build(BuildContext context) { return MaterialApp( title: 'ListView widget', theme: ThemeData( textTheme: TextTheme( bodyLarge: TextStyle(fontSize: 50), )), home: Scaffold( body: Container( color: Colors.white, child: SafeArea( child: Column( children: [ Image.asset( 'lib/images/title.png', width: ScreenUtil().setWidth(240), fit: BoxFit.contain, ), Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ Image.asset( 'lib/images/aside.png', width: 30, height: ScreenUtil().setWidth(288), fit: BoxFit.cover, alignment: Alignment.topLeft, ), Expanded(flex: 1, child: middleContainer()), Image.asset( 'lib/images/aside.png', width: 30, height: ScreenUtil().setWidth(288), fit: BoxFit.cover, alignment: Alignment.topRight, ), ], ) ], ), ))), ); } } class middleContainer extends StatelessWidget { const middleContainer({super.key}); @override Widget build(BuildContext context) { return Container( height: ScreenUtil().setWidth(288), color: const Color(0xff010042), child: Column(children: [ Expanded( flex: 274, child: Container( color: Colors.amber, )), Expanded( flex: 45, child: Container( color: Color.fromARGB(255, 209, 188, 123), )), Expanded( flex: 60, child: Container( child: Stack( children: [ Positioned( child: Text( '返回', ), bottom: ScreenUtil().setWidth(5), left: ScreenUtil().setWidth(10), ) ], ), color: Color.fromARGB(255, 85, 105, 104), )), ]), ); } }
最新发布
05-25

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值