我正在尝试注销用户并切换窗口小部件,但是在调用以下函数后-
void logoutUser() async {
await FirebaseAuth.instance.signOut();
}
如果我检查当前用户,它将返回用户对象,但ID为空-
FirebaseAuth.instance.currentUser()
我尝试在注销后将用户踢出main.dart,以检查用户是否登录并加载正确的小部件。有谁知道为什么currentUser()
在调用signOut()
之后没有返回null?
答案 0 :(得分:0)
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="https://d3js.org/d3.v3.js"></script>
<style>
body{ font-family: 'Hanna' 12px; text-align: center;}
.link {
stroke: #ccc;
}
.node text {
pointer-events: none;
font: sans-serif;
}
</style>
<link rel="stylesheet" type="text/css" href="main.css">
</head>
<body>
<script type="text/javascript">
//Set margins and sizes
var margin = {
top: 20,
bottom: 50,
right: 30,
left: 50
};
var width = 960 - margin.left - margin.right;
var height = 700 - margin.top - margin.bottom;
var zoom = d3.behavior.zoom()
.scaleExtent([0.1, 10])
.on("zoom", zoomed);
//Load Color Scale
var c10 = d3.scale.category10();
//Create an SVG element and append it to the DOM
var svgElement = d3.select("body")
.append("svg")
.attr({"width": width+margin.left+margin.right, "height": height+margin.top+margin.bottom})
.append("g")
.attr("transform","translate("+margin.left+","+margin.top+")")
.call(zoom);
//Load External Data
d3.json("idol_gen1.json", function(dataset){
//Extract data from dataset
var nodes = dataset.nodes,
links = dataset.links;
//Create Force Layout
var force = d3.layout.force()
.size([width, height])
.nodes(nodes)
.links(links)
.gravity(0.05)
.charge(-200)
.linkDistance(200);
//Add links to SVG
var link = svgElement.selectAll(".link")
.data(links)
.enter()
.append("line")
.attr("stroke-width", function(d){ return d.value*0.5; })
.attr("class", "link");
//Add nodes to SVG
var node = svgElement.selectAll(".node")
.data(nodes)
.enter()
.append("g")
.attr("class", "node")
.call(force.drag);
//Add labels to each node
var label = node.append("text")
.attr("dx", 12)
.attr("dy", "0.35em")
.attr("font-size", function(d){ return Math.max(9, d.impor * 1.5); })
.text(function(d){ return d.name; });
//Add circles to each node
var circle = node.append("circle")
.attr("r", function(d){ return Math.max(5, Math.sqrt(d.impor || 0)); })
.attr("fill", function(d){ return c10(d.type); });
//This function will be executed for every tick of force layoutz
force.on("tick", function(){
//Set X and Y of node
node
.attr("cx", function(d){ return d.x; })
.attr("cy", function(d){ return d.y; });
//Set X, Y of link
link.attr("x1", function(d){ return d.source.x; })
link.attr("y1", function(d){ return d.source.y; })
link.attr("x2", function(d){ return d.target.x; })
link.attr("y2", function(d){ return d.target.y; });
//Shift node a little
node.attr("transform", function(d) { return "translate(" + d.x + "," + d.y + ")"; });
});
function zoomed() {
svg.attr("transform", "translate(" + d3.event.translate + ")scale(" + d3.event.scale + ")");
}
force.start();
});
</script>
</body>
</html>
可能是returning an anonymous FirebaseUser object。检查_auth.currentUser()
属性。
示例:
isAnonymous
但是,我强烈建议您使用monitor the onAuthStateChanged stream instead。这样,当用户登录或立即注销时,系统会通知您。
选中this article,它会对其进行深入的显示。