当错误消息出现时,它会降低TextFormField. 如果我理解正确,那是因为在指定的高度中考虑了错误消息的高度。
这是之前的屏幕:
之后 :
试图放入conterText: ' 'BoxDecoration (正如我在另一个主题上看到的那样),但没有帮助。
一个主意 ?
编辑: OMG 完全忘了把代码,这里是:
return Form(
key: _formKey,
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Container(
height: 40.0,
child: _createTextFormField(loginEmailController, Icons.alternate_email, "Email Adress", false, TextInputType.emailAddress),
),
Container(
height: 40.0,
child: _createTextFormField(loginPasswordController, Icons.lock, "Password", true, TextInputType.text),
),
SizedBox(
width: double.infinity,
child: loginButton
)
],
),
);
}
Widget _createTextFormField(TextEditingController controller, IconData icon, String hintText, bool obscureText, TextInputType inputType){
return TextFormField(
keyboardType: inputType,
controller: controller,
obscureText: obscureText, …Run Code Online (Sandbox Code Playgroud) 我有一个TripController包含私有字段的类_updatedAccount。我创建了一个吸气剂以便从外部获取。
class TripController {
final String _accountId;
final BuildContext _context;
Account _updatedAccount;
Account updatedAccount() => _updatedAccount;
TripController(this._accountId, this._context);
...
}
Run Code Online (Sandbox Code Playgroud)
在另一个课程中,我完全可以访问该TripController课程,我有代码:
onTap: () {
TripController _tripController =
new TripController(_account.id, context);
_tripController.add(context);
_account.trips = _tripController.updatedAccount.trips;
_account.notifyListeners();
},
Run Code Online (Sandbox Code Playgroud)
在这里,updatedAccount来自_tripController.updatedAccount.trips用红色下划线显示消息:The getter 'updatedAccount' isn't defined for the class 'TripController'
我是否错误地声明了吸气剂?
我试图给我的底部导航栏一些圆角。为此,我必须使其容器的背景透明,但我不知道如何。
这就是我所做的Scaffold:
bottomNavigationBar: ClipRRect(
borderRadius: BorderRadius.only(topLeft: Radius.circular(30.0), topRight: Radius.circular(30.0), ),
child:BottomNavigationBar(
//elevation: 0.0,
type: BottomNavigationBarType.fixed,
backgroundColor: Colors.white10,
Run Code Online (Sandbox Code Playgroud)
结果:
默认情况下仍然是白色背景。我试图将我的包装ClipRRect在一个具有透明背景的容器中,但没有用。
任何的想法 ?
我必须评论/提供我用 flutter 创建的应用程序的文档。
我已经看到DartDoc生成文档。但这仅适用于我的应用程序中的 Dart 代码,这基本上意味着业务逻辑。用户界面怎么样?评论 UI 或将其包含在文档中的最佳方式是什么?
另外,一个有据可查的应用程序是否应该只有“dartdoc 评论” ///?//与 dartcode 注释相比,基本注释的作用是什么?是的,它不会出现在文档中,但我应该如何选择?
我正在使用该Hero组件在两个页面之间创建动画。该Hero组件用于包装一个Image小部件(没问题)和一个Container小部件(有问题)。
抛出以下溢出错误:
??? EXCEPTION CAUGHT BY RENDERING LIBRARY ?????????????????????????????????????????
I/flutter ( 4256): The following message was thrown during layout:
I/flutter ( 4256): A RenderFlex overflowed by 104 pixels on the right.
Run Code Online (Sandbox Code Playgroud)
Positioned(
width: MediaQuery.of(context).size.width * 0.7,
height: MediaQuery.of(context).size.height * 0.45,
top: 160.0,
left: MediaQuery.of(context).size.width * 0.04,
child: Hero(
tag: i.id,
child: Container( ...)
)
)
Run Code Online (Sandbox Code Playgroud)
Hero(
tag: this.i.departure,
child: Container(
margin: EdgeInsets.only(top: MediaQuery.of(context).size.height * 0.25),
height: MediaQuery.of(context).size.height,
decoration: cardDecoration,
), …Run Code Online (Sandbox Code Playgroud) 我在行中显示 SVG 文件形式的图像和文本。
由于某种原因,svg 图像的渲染速度比屏幕的其余部分慢,导致延迟,这不利于用户体验。
这种延迟正常吗?我该怎么做才能使整个屏幕同时渲染?
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
SvgPicture.asset(
'lib/assets/muslim_coloc_logo.svg',
height: 40.0,
width: 40.0,
),
SizedBox(width: 2.0,),
RichText(
text: TextSpan(children: [
TextSpan(
text: 'uslim',
style: MC_titleWhite,
),
TextSpan(
text: 'Coloc',
style: MC_titleWhite50,
),
]),
),
],
),
Run Code Online (Sandbox Code Playgroud)
我_CastError 在这段代码的最后一行遇到错误
BlocBuilder buildUsernameField() {
return BlocBuilder<ProfileBloc, ProfileState>(
buildWhen: (previous, current) => previous != current && current is EditingUserInfo,
builder: (context, state) => TextField(
keyboardType: TextInputType.name,
controller: TextEditingController(
text: (state as EditingUserInfo).username.value),
Run Code Online (Sandbox Code Playgroud)
这么说
I/flutter (26787): The following _CastError was thrown building BlocBuilder<ProfileBloc, ProfileState>(dirty, state:
I/flutter (26787): _BlocBuilderBaseState<ProfileBloc, ProfileState>#25b87):
I/flutter (26787): type 'Success' is not a subtype of type 'EditingUserInfo' in type cast
Run Code Online (Sandbox Code Playgroud)
所以发生的事情是,当我处于另一种状态(成功)时,它会尝试构建该小部件。但在buildWhen参数中,我指定小部件仅应在状态为 时构建EditingUserInfo。
据我了解,这个错误不应该发生。
这是我的ProfileState:
I/flutter (26787): The following _CastError was thrown …Run Code Online (Sandbox Code Playgroud) 在“详细信息”页面中,我希望在最顶部有一个图像占据整个可用宽度。这是我的代码:
@override
Widget build(BuildContext context) {
return Scaffold(
body: Stack(
children: <Widget>[
Container(
child: Column(
children: <Widget>[
Container(
width: double.infinity,
child: Image.asset(
this.imageLink,
),
)
],
),
),
),
);
Run Code Online (Sandbox Code Playgroud)
问题是:使用模拟器,结果正是我想要的:
但是当我在真正的手机(Galaxy S8 Plus)上启动应用程序时,会有一些填充(顶部、左侧和右侧)并且图像不适合屏幕宽度。
这意味着我尝试使用代码的方式有些不正确。
问题出在哪里?
我的底页有问题。
我遇到了这个溢出错误,这很奇怪。我的意思是,它溢出是正常的,这就是小部件的目的:O
https://pub.dev/packages/expandable_bottom_bar
显然,打开底页时不会溢出:
只要我不处于发布模式,我就应该忽略它吗?我尝试修复它但没有找到任何方法:/
编辑:底部工作表放置在堆栈内部的Positioned小部件内:
Positioned(
bottom: 0.0,
left: 0.0,
right: 0.0,
child: BottomExpandableAppBar(
// Provide the bar controller in build method or default controller as ancestor in a tree
controller: controller,
appBarHeight: 00.0,
expandedHeight: controller.dragLength,
horizontalMargin: 0.0,
bottomOffset: 50.0,
//expandedBackColor: Colors.white,
expandedDecoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(20),
topRight: Radius.circular(20),
),
boxShadow: [
BoxShadow(
color: Colors.black12,
offset: Offset(5.0, 5.0),
blurRadius: 15.0,
spreadRadius: 15.0,
),
]
),
// Your bottom sheet code here
expandedBody: new Bookings(controller: …Run Code Online (Sandbox Code Playgroud)