I tried using an answer to the same question but I am not sure what else I have to do in my case
import 'package:auduo/routes/routes.dart';
import 'package:auduo/opening_Screen.dart';
import 'package:firebase_core/firebase_core.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
routes: AppRoutes.define(),
home: OpeningScreen(),
);
}
}
Let me know if you need to see other .dart files
Below is the Requested Code From The Comments
import 'package:flutter/material.dart';
import 'package:auduo/routes/routes.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:firebase_core/firebase_core.dart';
// Bleyl Dev Vid 2 - 7:49
class Register extends StatefulWidget {
@override
_RegisterViewState createState() => _RegisterViewState();
}
class _RegisterViewState extends State<Register> {
final _formKey = GlobalKey<FormState>();
TextEditingController _usernameController = TextEditingController();
TextEditingController _emailController = TextEditingController();
TextEditingController _passwordController = TextEditingController();
TextEditingController _repasswordController = TextEditingController();
@override
Widget build(BuildContext context) {
final mq = MediaQuery.of(context);
final logo = Image.asset(
"assets/Auduo Logo V 1.0.png",
height: mq.size.height / 4,
);
final usernameField = TextFormField(
controller: _usernameController,
style: TextStyle(color: Colors.white),
cursorColor: Colors.white,
decoration: InputDecoration(
focusedBorder: UnderlineInputBorder(
borderSide: BorderSide(color: Colors.yellow),
),
hintText: "NiceSound259",
labelText: "Username",
labelStyle: TextStyle(color: Colors.white),
hintStyle: TextStyle(
color: Colors.white,
),
),
);
final emailField = TextFormField(
controller: _emailController,
keyboardType: TextInputType.emailAddress,
style: TextStyle(color: Colors.white),
cursorColor: Colors.white,
decoration: InputDecoration(
focusedBorder: UnderlineInputBorder(
borderSide: BorderSide(color: Colors.yellow),
),
hintText: "Something@example.com",
labelText: "Email",
labelStyle: TextStyle(color: Colors.white),
hintStyle: TextStyle(
color: Colors.white,
),
),
);
final passwordField = TextFormField(
obscureText: true,
controller: _passwordController,
style: TextStyle(color: Colors.white),
cursorColor: Colors.white,
decoration: InputDecoration(
focusedBorder: UnderlineInputBorder(
borderSide: BorderSide(color: Colors.yellow),
),
hintText: "password",
labelText: "Password",
labelStyle: TextStyle(color: Colors.white),
hintStyle: TextStyle(
color: Colors.white,
),
),
);
final repasswordField = TextFormField(
obscureText: true,
controller: _repasswordController,
style: TextStyle(color: Colors.white),
cursorColor: Colors.white,
decoration: InputDecoration(
focusedBorder: UnderlineInputBorder(
borderSide: BorderSide(color: Colors.yellow),
),
hintText: "re-enter password",
labelText: "Re-Enter Password",
labelStyle: TextStyle(color: Colors.white),
hintStyle: TextStyle(
color: Colors.white,
),
),
);
final fields = Padding(
padding: EdgeInsets.only(top: 10.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
usernameField,
emailField,
passwordField,
repasswordField
],
),
);
final registerButton = Material(
elevation: 5,
borderRadius: BorderRadius.circular(25),
color: Colors.white,
child: MaterialButton(
minWidth: mq.size.width / 1.2,
padding: EdgeInsets.fromLTRB(10, 15, 10, 15),
child: Text(
"Register",
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 20,
color: Colors.black,
fontWeight: FontWeight.bold,
),
),
onPressed: () async {
try {
User user =
(await FirebaseAuth.instance.createUserWithEmailAndPassword(
email: _emailController.text,
password: _passwordController.text,
)) as User;
if (user != null) {
user.updateDisplayName(_usernameController.text);
Navigator.of(context).pushNamed(AppRoutes.home);
}
} catch (e) {
print(e);
_usernameController.text = "";
_passwordController.text = "";
_repasswordController.text = "";
_emailController.text = "";
//TODO alert dialog with error
}
},
),
);
final bottom = Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
//loginButton,
Padding(
padding: EdgeInsets.all(8.0),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text(
"Already have an account?",
style: Theme.of(context).textTheme.subtitle1?.copyWith(
color: Colors.white,
),
),
MaterialButton(
onPressed: () {
Navigator.of(context).pushNamed(AppRoutes.authLogin);
},
child: Text(
"Sign In",
style: Theme.of(context).textTheme.subtitle1?.copyWith(
color: Colors.white,
decoration: TextDecoration.underline,
),
),
),
],
),
],
);
return Scaffold(
backgroundColor: Colors.black,
body: Form(
key: _formKey,
child: SingleChildScrollView(
padding: EdgeInsets.all(36),
child: Container(
height: mq.size.height,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
logo,
fields,
registerButton,
Padding(
padding: EdgeInsets.only(bottom: 150),
child: bottom,
)
],
),
),
),
),
);
}
}
Above is the Requested Code From The Comments, This is the register.dart code the functions are pretty similar to login.dart so hopefully this is enough.