颤动中的动态操作按钮

时间:2019-07-17 02:50:26

标签: vue.js flutter

如何设计Flutter应用程序,以便每次导航到其他路线时,操作按钮都会更改。例如,在Whatsapp上,当您从“聊天”导航到调用搜索栏时,弹出菜单会更改(已更新)。我们非常感谢您提供任何有关如何使用Flutter实现它的帮助,包括VueJS。 在Web /移动开发方面,这些特殊的东西几乎使我望而却步。 请帮助。

1 个答案:

答案 0 :(得分:0)

您使用什么导航?如果您使用tabViewpageView之类的东西,则可以将state设置为等于页面索引。

从那里您可以执行一些内联​​脚本,例如...

对于2页: 假设int index = 0

index == 0 ? FloatingActionButton(attributes for index 0) : FloatingActionButton(attributes for index 1)

这是简写三元运算符。

要超过2页,难度会变大: 假设int index = 0

  @override
  Widget build(BuildContext context) {
    return _buildFAB(context);
  }

  FloatingActionButton _buildFAB(context) {
    switch(index) {
      case 0: {
        return FloatingActionButton(attributes for index 0);
      }
      break;
      case 1: {
        return FloatingActionButton(attributes for index 1);
      }
      break;
      case 3: {
        return FloatingActionButton(attributes for index 2);
      }
      break;
      //more for each page
    }
  }

可能有数百种方法可以完成,而看不到您的任何代码是我能做的最好的事情。希望这会有所帮助!

相关问题