颤振:堆栈 - 台下 - 文本表单字段 - 焦点问题



我有一个台下小部件列表的堆栈。 这些台下小部件中的每一个都引用一个用于显示表单的 MaterialApp。 这些表单中的每一个都包含多个文本表单域。

我遇到的问题是第一个和第二个台下项 TextFormFields 永远不会得到焦点(当然考虑正确的台下:索引(。

为了使它工作,如果我把第一个台下放在第三个位置(因此在顶部(,一切都很好。

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

有没有办法强制等效于">z索引"? 我也尝试使用IndexedStack,但结果是相同的。

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

非常感谢您的帮助。

这是代码:

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 中描述的问题相同。希望这对将来的某人有所帮助。

最新更新