Fairly newish to flutter, and I have an app that can succesfully log into Firebase. However now I'm trying to make it so the app skips the registration page if the user is already registered. I started a new template for this post.
I used this post: How to correctly check if a user is logged in for the inspiration, but mine seems to throw an error. I'm using VSCODE if that makes a difference:
import 'package:buildfuture/FirstPage.dart';
import 'package:buildfuture/SecondPage.dart';
import 'package:flutter/material.dart';
import 'package:firebase_auth/firebase_auth.dart';
void main() {
runApp(MyApp());
}
class MyApp implements StatelessWidget {
@override
Widget build() {
return FutureBuilder<FirebaseUser>(
future: FirebaseAuth.instance.currentUser(),
builder: (BuildContext context, AsyncSnapshot<FirebaseUser> snapshot) {
if (snapshot.hasData) {
FirebaseUser user = snapshot.data;
return First();
}
return Second();
}
);
}
}
I don't understand the error:
'Object.toString' ('String Function()') isn't a valid override of 'Diagnosticable.toString' ('String Function({DiagnosticLevel minLevel})').
and
'MyApp.build' ('Widget Function()') isn't a valid override of 'StatelessWidget.build' ('Widget Function(BuildContext)').
Just in case I've also included FirstPage.dart. SecondPage.dart is exactly the same except the class is named Second
import 'package:flutter/material.dart';
class First extends StatelessWidget {
@override
Widget build(BuildContext context){
return new Container(
child: new Center(
child: new Icon(Icons.accessibility_new, size: 150.0, color: Colors.brown)
)
);
}
}