Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flutter 如何在颤振中添加条件_Flutter_User Interface_If Statement_Swipe - Fatal编程技术网

Flutter 如何在颤振中添加条件

Flutter 如何在颤振中添加条件,flutter,user-interface,if-statement,swipe,Flutter,User Interface,If Statement,Swipe,我想添加一个条件,例如,如果有人单击Circle Avatar()图像,则它将导航到其他页面(假设其他页面在我的情况下为USERPROFILE()页面),其他人向左或向右滑动,则它也将导航到user profile()页面 以下是ontap的代码-> actions: <Widget>[ Padding( padding: const EdgeInsets.only(right: 20), child: Gestur

我想添加一个条件,例如,如果有人单击Circle Avatar()图像,则它将导航到其他页面(假设其他页面在我的情况下为USERPROFILE()页面),其他人向左或向右滑动,则它也将导航到user profile()页面 以下是ontap的代码->

actions: <Widget>[
          Padding(
            padding: const EdgeInsets.only(right: 20),
            child: GestureDetector(

              onTap: () {Navigator.push(context,MaterialPageRoute(builder: (context) => UserProfile()));},

              child: CircleAvatar(),
            ),
          ),
        ],

您是否使用命名路由?@classicdude7 noso什么是UserProfile()?@classicdude7这是一个在Center中打印简单hello的页面。您使用的
setState()
错误。从左侧将其拆下以开始
onSwipeLeft: () {
                setState(() {
                  Navigator.push(
                    context,
                    PageTransition(
                        type: PageTransitionType.rightToLeft,
                        child: UserProfile(),
                        inheritTheme: true,
                        ctx: context),
                  );
                });
              },