如何在Flutter中使用MenuItem导航到其他页面?

时间:2020-08-31 08:36:54

标签: flutter dart

我是Flutter的新手,我在MenuItems中有一个Drawer的列表,如下所示。

 MenuItem selectedMenuItem;
      List<MenuItem> menuItems = [
        MenuItem(title: 'Contact', items: [
          MenuItem(title: 'Contact Us'),
          MenuItem(title: 'Call center'),
          MenuItem(title: 'WhatsApp'),
        ]),
        MenuItem(title: 'language'),
        MenuItem(title: 'Customer'),
      ];

单击每个项目时,我想打开一个不同的页面。我下一步应该怎么做?有什么想法吗?

subItems(BuildContext context) {
    return selectedMenuItem.items.map(
      (item) => MaterialButton(
        onPressed: () {
          redirectItem(item);
        },
   
        child: Row(
          children: [
            Text(
              item.title,
           
            ),
          ],
        ),
      ),
    );
  }        style: TextStyle(fontSize: 14),
          
        );
      }

1 个答案:

答案 0 :(得分:2)

欢迎来到Flutter社区!我看不到完整的代码,因此我猜您在触发onPressed()时已经可以执行某些操作。
您可以使用以下代码导航到另一个小部件:

    CREATE TRIGGER [active_plan_increase_total]
    ON [dbo].[wallet_plan]
    after UPDATE
    AS
    BEGIN
        SET NOCOUNT ON
        declare @id int, @user_id  int, @inc_id int, @inc_rate float, @status nvarchar(50), @current_balance float
        
        select @user_id = inserted.user_id, @inc_id = inserted.rate_id, @status= inserted.status from inserted      
        
        select @inc_rate = sum( Increase_Rate.inc_rate ), @user_id =wallet_plan.user_id from Increase_Rate join inserted i on  Increase_Rate.Id = i.rate_id inner join wallet_plan on wallet_plan.user_id = i.user_id where wallet_plan.user_id = i.user_id group by wallet_plan.user_id 

        select @current_balance = User_Total.current_btc from User_Total where User_Total.user_id = @user_id    
                
        update User_Total set User_Total.current_btc =( User_Total.current_btc +  @inc_rate)   from  User_Total  join inserted i on User_Total.user_id = i.user_id  
        inner join Increase_Rate on Increase_Rate.Id = i.rate_id where User_Total.user_id = i.user_id

    END