小编UVi*_*Vic的帖子

如何使用 firebase auth 限制对 next.js 中页面的访问?

我正在开发一个使用 firebase 的 next.js 应用程序。我需要使用 firebase auth 包来限制对页面的访问。with-firebase-authentication 示例不显示多个页面的身份验证。

import React from 'react';
import Router from 'next/router';

import { firebase } from '../../firebase';
import * as routes from '../../constants/routes';

const withAuthorization = (needsAuthorization) => (Component) => {
  class WithAuthorization extends React.Component {
    componentDidMount() {
      firebase.auth.onAuthStateChanged(authUser => {
        if (!authUser && needsAuthorization) {
          Router.push(routes.SIGN_IN)
        }
      });
    }

    render() {
      return (
        <Component { ...this.props } />
      );
    }
  }

  return WithAuthorization;
}

export default withAuthorization;
Run Code Online (Sandbox Code Playgroud)

firebase firebase-authentication next.js

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

GraphQL 中具有一对多关系的多态性

我的架构中有以下实体。

  • 用户
  • 链接帖子
  • 普通邮政

我如何建模UserPost类型之间的一对多关系,其中Post可以是两种类型LinkPostNormalPost.

graphql

5
推荐指数
2
解决办法
1873
查看次数

如何在颤动中为自定义绘制的圆圈提供阴影

我试图让一个圆圈看起来更物质。所以我想给它一个阴影,我如何在颤振中使用 Paint 类来做到这一点

thumbPaint = Paint()
..color = Colors.white,
..style = PaintingStyle.fill;
Run Code Online (Sandbox Code Playgroud)

paint dart flutter

5
推荐指数
3
解决办法
3344
查看次数

包导入和flutter中的常规导入之间有什么区别?

通过一些混乱的源代码,发现了两种不同类型的导入。

两者之间有什么区别,哪个更好?


#1
import 'folder/filename.dart';

#2
import 'package:projectname/folder1/folder2/folder/filename.dart';

Run Code Online (Sandbox Code Playgroud)

dart flutter

5
推荐指数
1
解决办法
162
查看次数

如何在颤动的文本小部件中显示图标?

我想在文本小部件中显示一个图标。我该怎么做呢 ?

以下代码仅显示 IconData

Text("Click ${Icons.add} to add");
Run Code Online (Sandbox Code Playgroud)

flutter

5
推荐指数
6
解决办法
996
查看次数

从 firestore 查询的文档中获取用户信息?

我正在从 firestore 查询一些文档。如何从快照对象获取用户信息。

用户 ID 和用户名等信息。

假设用户使用社交 OAuth 提供商登录。如果这很重要的话。

firebase.firestore().collection('sample').get()
        .then(function(snapshot) {
            console.log('SNAPSHOT', snapshot);
            snapshot.forEach(function(doc) {
                console.log(doc.exists);
                console.log(doc);
                console.log(doc.id);
                console.log(doc.metadata);
                console.log(doc.ref);
                console.log(doc.data());
                console.log(doc.ref.path);
                console.log(doc);
            })
        }).catch(console.log);
Run Code Online (Sandbox Code Playgroud)

javascript firebase google-cloud-firestore

2
推荐指数
1
解决办法
1万
查看次数

如何在 ChangeNotifier 中使用 Futures?

我有一个sqlite从中读取数据的数据库。我也有一个很长的小部件树。所以经过一番研究,我找到了providerFlutter 包。但是我不知道如何在扩展类中使用 FuturesChangeNotifier或如何在我的小部件树中的任何地方使用它?

class MyProvider with ChangeNotifier {
  dynamic _myValue;

  dynamic get myValue => _myValue;

  set myValue(dynamic newValue) {
    _myValue = newValue;
    notifyListeners();
  }

  MyProvider(){
    loadValue();
  }

  Future<void> loadValue async {
    myValue = await db.instance().getValue();
  }

  Future<void> refetch async {
    myValue = await db.instance().newValue();
    notifyListeners();
  }
}
Run Code Online (Sandbox Code Playgroud)

sqlite dart flutter flutter-provider

2
推荐指数
1
解决办法
2909
查看次数

我应该为颤动表单中的每个输入字段创建一个单独的控制器吗?

我正在创建一个可能有两个或更多输入字段的基本表单。我应该为每个输入创建一个控制器,还是有办法为所有输入文本字段使用单个控制器。

dart flutter

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