what im trying to do is to setup a role based authorization (reqular users and subscribed users) and based on roles users gets redirected to different screens. i am STUCK. ive tried different solutions and seen every tutorial there is out there about the concept. i understand how the concept works but having a realy hard time setting it up in my code. im not sure where to declare the subscribed users and how create the function and how to Navigate them! greatful for any help! this is how my code looks!
//this is my auth services
static void signUpUser(
BuildContext context, String name, String email, String password) async {
try {
AuthResult authResult = await _auth.createUserWithEmailAndPassword(
email: email,
password: password
);
FirebaseUser signedInUser = authResult.user;
if (signedInUser != null) {
_firestore.collection('/users').document(signedInUser.uid).setData({
'name': name,
'email': email,
'profileImageUrl': '',
});
//sign up page
final _formKey = GlobalKey<FormState>();
String _name, _email, _password;
_submit() {
if(_formKey.currentState.validate()){
_formKey.currentState.save();
AuthService.signUpUser(context, _name, _email, _password);
}
}
//my main.dart
Widget _getScreenId() {
return StreamBuilder<FirebaseUser>(
stream: FirebaseAuth.instance.onAuthStateChanged,
builder: (BuildContext context, snapshot) {
if (!snapshot.hasData) {
Provider.of<UserData>(context).currentUserId = snapshot.data.uid;
return LoginScreen();
} else {
return HomeScreen();
}
},
);
}
//user models import 'package:cloud_firestore/cloud_firestore.dart';
class User {
final String id;
final String name;
final String profileImageUrl;
final String email;
final String bio;
User({
this.id,
this.name,
this.profileImageUrl,
this.email,
this.bio
});