草庐IT

flutter - Flutter中使用child center的stack child的相对定位

我的布局的一部分显示了一个图像,上面有对象。图像和对象位于Stack中。对于物体位置,我知道物体中心相对于图像的相对坐标。例如(0,0)表示对象中心应位于图像的左上角,(0.23,0.7)表示“中心位于宽度的23%和高度的70%”。我知道对象的大小,但我不知道将分配给图像的先验大小。我尝试为此使用Align但它不使用对象的中心:例如Align与Alignment(1,1)将对象的右下角放在右下角。然后我尝试添加一个变换以将对象的中心转换为(0,0),但这仅适用于右下角,例如,当使用Alignment(0,0)在中心对齐时,位置是错误的)。我想到了使用Positioned小部件,但是我无

flutter - Flutter中使用child center的stack child的相对定位

我的布局的一部分显示了一个图像,上面有对象。图像和对象位于Stack中。对于物体位置,我知道物体中心相对于图像的相对坐标。例如(0,0)表示对象中心应位于图像的左上角,(0.23,0.7)表示“中心位于宽度的23%和高度的70%”。我知道对象的大小,但我不知道将分配给图像的先验大小。我尝试为此使用Align但它不使用对象的中心:例如Align与Alignment(1,1)将对象的右下角放在右下角。然后我尝试添加一个变换以将对象的中心转换为(0,0),但这仅适用于右下角,例如,当使用Alignment(0,0)在中心对齐时,位置是错误的)。我想到了使用Positioned小部件,但是我无

flutter - 错误 : NoSuchMethodError, 在 null 上调用了 getter 'index'

我正在使用AnimatedContainer,以便它的高度可以(通过动画)适应其中存在的选项卡内容。我应该可以使用DefaultTabController.of(context).index访问选项卡的当前索引,并且我正在将此数据传输到一个函数,该函数将根据当前选项卡重建小部件。当我运行代码时,它向我显示错误,但我不明白:这是否意味着DefaultTabController返回null?代码如下:import'package:flutter/material.dart';import'package:travel_agent_app/loginForm.dart';import'pac

flutter - 错误 : NoSuchMethodError, 在 null 上调用了 getter 'index'

我正在使用AnimatedContainer,以便它的高度可以(通过动画)适应其中存在的选项卡内容。我应该可以使用DefaultTabController.of(context).index访问选项卡的当前索引,并且我正在将此数据传输到一个函数,该函数将根据当前选项卡重建小部件。当我运行代码时,它向我显示错误,但我不明白:这是否意味着DefaultTabController返回null?代码如下:import'package:flutter/material.dart';import'package:travel_agent_app/loginForm.dart';import'pac

flutter - 为 Sliver child 设置自定义高度

在下面的代码中我遇到了问题,我正在尝试为Sliverchild的每个child设置自定义高度,我刚刚在Flutter上了解了这个小部件,我想修复它,例如:CustomScrollView(slivers:[SliverFixedExtentList(itemExtent:MediaQuery.of(context).size.height,delegate:SliverChildListDelegate([ConstrainedBox(constraints:BoxConstraints(maxHeight:50.0,minHeight:50.0),child:Text('dddddd

flutter - 为 Sliver child 设置自定义高度

在下面的代码中我遇到了问题,我正在尝试为Sliverchild的每个child设置自定义高度,我刚刚在Flutter上了解了这个小部件,我想修复它,例如:CustomScrollView(slivers:[SliverFixedExtentList(itemExtent:MediaQuery.of(context).size.height,delegate:SliverChildListDelegate([ConstrainedBox(constraints:BoxConstraints(maxHeight:50.0,minHeight:50.0),child:Text('dddddd

flutter - 为 Circle Avatar 小部件 overflow hidden (Flutter)

我需要将图标放入CircleAvatarWidget以允许用户上传他的图像​​。像这样:这是我的代码:child:CircleAvatar(child:Stack(children:[Positioned(bottom:0,right:0,left:0,height:33,child:Container(height:20,width:30,color:Color.fromRGBO(0,0,0,.74),child:Center(child:Icon(Icons.photo_camera,color:Colors.grey),),),)],),radius:68.0,backgroun

flutter - 为 Circle Avatar 小部件 overflow hidden (Flutter)

我需要将图标放入CircleAvatarWidget以允许用户上传他的图像​​。像这样:这是我的代码:child:CircleAvatar(child:Stack(children:[Positioned(bottom:0,right:0,left:0,height:33,child:Container(height:20,width:30,color:Color.fromRGBO(0,0,0,.74),child:Center(child:Icon(Icons.photo_camera,color:Colors.grey),),),)],),radius:68.0,backgroun

flutter - 如何修复隐藏其子项的 Aspectratio 小部件?

我正在尝试将一个materialbutton小部件制作成一个正方形。我想要其中的4个按钮形成它们自己的正方形。像这样:所以我尝试了这个:@overrideWidgetbuild(BuildContextcontext){returnContainer(color:Colors.green,child:Column(mainAxisSize:MainAxisSize.max,children:[Row(mainAxisSize:MainAxisSize.max,children:[AspectRatio(aspectRatio:1,child:MaterialButton(child:I

flutter - 如何修复隐藏其子项的 Aspectratio 小部件?

我正在尝试将一个materialbutton小部件制作成一个正方形。我想要其中的4个按钮形成它们自己的正方形。像这样:所以我尝试了这个:@overrideWidgetbuild(BuildContextcontext){returnContainer(color:Colors.green,child:Column(mainAxisSize:MainAxisSize.max,children:[Row(mainAxisSize:MainAxisSize.max,children:[AspectRatio(aspectRatio:1,child:MaterialButton(child:I