手势捕获Flutter PopupMenuButton错误异常

时间:2020-07-28 02:54:27

标签: flutter

我不确定这里发生了什么,当我点击PopupMenuButton时,它没有显示并抛出手势捕获的异常。这是我放在支架PopupMenuButton上的actions:小部件

 Widget _popUpMenu() => PopupMenuButton<int>(
            offset: Offset(0, 100),
            onSelected: (value) {
              if (value == 1) {
                FirebaseAuth.instance.signOut();
              }
            },
            child: Selector<UsersProvider, User>(
              selector: (context, provider) => provider.user,
              builder: (context, value, child) {
                return Row(
                  mainAxisAlignment: MainAxisAlignment.spaceAround,
                  crossAxisAlignment: CrossAxisAlignment.center,
                  children: [
                    ClipOval(
                      child: value.photoUrl != null
                          ? Image.network(
                              "url.jpg",
                              fit: BoxFit.cover,
                              width: 32.0,
                              height: 32.0,
                            )
                          : Image.asset(
                              "assets/user.png",
                              fit: BoxFit.cover,
                              width: 32.0,
                              height: 32.0,
                            ),
                    ),
                    Text(value.displayName),
                  ],
                );
              },
            ),
            itemBuilder: (context) => [
              PopupMenuItem<int>(
                value: 1,
                child: Text("Sign Out"),
              ),
            ],
          );

还有我的main.dart:

  Widget build(BuildContext context) {
    return ChangeNotifierProvider(
      create: (context) => UsersProvider(),
      child: MaterialApp(
        title: 'RetGoo Events',
        theme: ThemeData(
          cardTheme: CardTheme(
            elevation: 0,
            shape: RoundedRectangleBorder(
              borderRadius: BorderRadius.circular(8),
              side: BorderSide(color: Colors.grey),
            ),
          ),
          primarySwatch: Colors.blue,
          appBarTheme: AppBarTheme(
              color: Colors.white,
              textTheme: Theme.of(context).textTheme.apply(
                  bodyColor: Colors.blue[900], displayColor: Colors.blue[900])),
          iconTheme: IconThemeData(color: Colors.blue[900]),
          visualDensity: VisualDensity.adaptivePlatformDensity,
          inputDecorationTheme: InputDecorationTheme(
            border: OutlineInputBorder(
              borderRadius: BorderRadius.circular(10),
            ),
          ),
        ),
        routes: {
          "/": (context) => HomePage(),
        },
        debugShowCheckedModeBanner: false,
        builder: (context, child) {
          return Selector<UsersProvider, User>(
            child: child,
            selector: (context, provider) => provider.user,
            builder: (context, value, child) {
              if (value == null) {
                return Navigator(
                  onGenerateRoute: (settings) => MaterialPageRoute(
                      settings: settings, builder: (context) => LoginPage()),
                );
              }

              return MultiProvider(
                providers: [
                  ChangeNotifierProvider(create: (context) => EventsProvider()),
                ],
                child: child,
              );
            },
          );
        },
      ),
    );
  }

错误输出:

enter image description here

不管怎么说,谢谢。

0 个答案:

没有答案