gpt4 book ai didi

Flutter: Stack - Offstage - TextFormField - 焦点问题

转载 作者:IT王子 更新时间:2023-10-29 07:06:48 25 4
gpt4 key购买 nike

我有一堆 Offstage 小部件列表。这些 Offstage 小部件中的每一个都引用一个 MaterialApp 来显示一个表单。这些表单中的每一个都包含多个 TextFormField。

我遇到的问题是第一个和第二个 Offstage 项 TextFormFields 从未获得焦点(当然考虑到正确的 offstage: index)。

为了使其正常工作,如果我将第一个 Offstage 放在第三个位置(因此在顶部),一切正常。

这很可能来自 Stack 或 Offstage 的概念。

有没有办法强制使用“z-index”?我也尝试使用 IndexedStack,但结果是相同的。

我应该使用 Offstage 以外的其他东西吗?

非常感谢您的帮助。

代码如下:

Widget build(BuildContext context) {
return new Scaffold(
backgroundColor: Color(0xF4FFFFFF),
bottomNavigationBar: new Theme(
data: Theme.of(context).copyWith(
canvasColor: Colors.amber[700],
primaryColor: Colors.white,
textTheme: Theme
.of(context)
.textTheme
.copyWith(caption: new TextStyle(color: Colors.grey[800])),
),
child: new BottomNavigationBar(
iconSize: 8.0,
currentIndex: index,
onTap: (int index) {
setState(() {
this.index = index;
});
},
type: BottomNavigationBarType.fixed,
items: <BottomNavigationBarItem>[
new BottomNavigationBarItem(
title: new Text('Sign In',
style: new TextStyle(fontSize: 20.0)),
icon: new Container(height: 8.0),
),
new BottomNavigationBarItem(
title: new Text('Register',
style: new TextStyle(fontSize: 20.0)),
icon: new Text('No account yet',
style: new TextStyle(fontSize: 10.0)),
),
new BottomNavigationBarItem(
title: new Text('lost password',
style: new TextStyle(fontSize: 12.0)),
icon: new Container(height: 8.0),
),
]),
),
body: new SafeArea(
top: false,
bottom: false,
child: new Stack(children: <Widget>[
new Offstage(
offstage: index != 0,
child: new MaterialApp(
home: new LoginForm(),
debugShowCheckedModeBanner: false,
)),
new Offstage(
offstage: index != 1,
child: new MaterialApp(
home: new RegisterForm(),
debugShowCheckedModeBanner: false,
),
),
new Offstage(
offstage: index != 2,
child: new MaterialApp(
home: new LostPasswordForm(),
debugShowCheckedModeBanner: false,
),
),
]),
),
);
}

最佳答案

在尝试找到类似问题的解决方案时偶然发现了这个问题。您可能已经继续前进,但我很确定这与 https://github.com/flutter/flutter/issues/17098 中描述的问题相同.希望这对将来的人有所帮助。

关于Flutter: Stack - Offstage - TextFormField - 焦点问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50179468/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com