小编Mat*_*ier的帖子

Flutter AnimatedSwitcher 在孩子之间跳转

我正在尝试在扩展面板列表中实现一些自定义设计。因此,我想创建某种动画,可以从一个视图(例如标题)平滑地动画到具有其他尺寸的另一个视图(例如图块的完整信息)(显然,完整信息将高于标题)。使用 AnimatedContainer 可以很容易地实现这一点。但是,我需要标题小部件和完整信息小部件的高度,以便在这两个高度之间进行动画处理。由于这些值在图块之间有所不同(其他信息 -> 可能是其他高度),并且通过全局键跟踪高度不是我的首选解决方案,因此我决定使用更简单的 AnimatedSwitcher 来代替。然而,我的 AnimatedSwitcher 的行为很奇怪。首先,ListView 中的其他图块(在我的示例中为按钮)立即向下移动,随后图块展开。有谁知道我如何实现一些代码,以实现与我从 AnimatedContainer 获得的相同动画(按钮/其他图块随着图块展开同时向下移动)?预先感谢您的任何建议。这是我的代码:

class MyPage extends State {
List _items;
int pos;

@override
void initState() {
pos = 0;
_items = [
  Container(
    color: Colors.white,
    width: 30,
    key: UniqueKey(),
    child: Column(
      children: <Widget>[Text('1'), Text('2')], //example that should visualise different heights
    ),
  ),
  Container(
    width: 30,
    color: Colors.white,
    key: UniqueKey(),
    child: Column(
      children: <Widget>[Text('1'), Text('2'), Text('44534'), Text('534534')],
    ),
  )
];
super.initState();
}

@override
Widget build(BuildContext context) {

return Scaffold(
  body: ListView(
    padding: …
Run Code Online (Sandbox Code Playgroud)

dart flutter flutter-animation

6
推荐指数
1
解决办法
4171
查看次数

在 TextFormField 中禁用单词下划线

我目前正在 Flutter 中进行应用程序设计,并正在努力解决这个看似简单的问题。创建下面的 TextFormField 时,输入文本始终带有下划线,无论我尝试过什么。我唯一想要的是没有这种难看的下划线的文本。

出现此问题的原因可能是 Android(我正在使用 Android 模拟器)会自动在像这样的输入表单中为文本添加下划线,但这只是我想到的一个想法,我不确定这是否是真正的原因我与 TextFormField 的斗争背后。不管怎样,这是我的代码和我得到的。

这是我的 TextFormField 目前的样子

Container(
              margin: EdgeInsets.only(top: 10, left: 20, right: 30),
              child: Card(
                  elevation: 5.0,
                  child: Container(
                    child: TextFormField(
                      style: TextStyle(
                          fontSize: 18.0,
                          color: const Color(0xFF757575),
                          decoration: TextDecoration.none,
                          fontWeight: FontWeight.w500,
                          fontFamily: 'Montserrat'),
                      key: formKey,
                      onSaved: (text) => _input = text,
                      decoration: InputDecoration(
                        focusedBorder: InputBorder.none,
                        enabledBorder: InputBorder.none,
                        border: InputBorder.none,
                        prefixIcon: Icon(
                          Feather.getIconData("search"),
                          color: Colors.orange,
                        ),
                      ),
                    ),
                  ))),
Run Code Online (Sandbox Code Playgroud)

dart flutter

4
推荐指数
1
解决办法
3071
查看次数

标签 统计

dart ×2

flutter ×2

flutter-animation ×1