Yahya
Yahya

Reputation: 15

FirebaseUser and User

I have problem in my app that I have to create a Database Class User , But also I have in the new FirebaseAuth there is User now instead of FirebaseUser , How can I separate them functionally ?

Upvotes: 1

Views: 772

Answers (3)

Hossein Yousefi
Hossein Yousefi

Reputation: 994

It's probably better to import firebase_auth package with an as keyword.

 import 'package:firebase_auth/firebase_auth.dart' as firebase_auth;

Now you can use any firebase_auth function or class by prepending firebase_auth. to the name like:

final firebaseUser = firebase_auth.User(...); 
final user = User(...);

I prefer this to the other way around because User class is a part of your code and you usually want to import external code as something.

Upvotes: 0

Luis Utrera
Luis Utrera

Reputation: 1067

Anna's solution should work. But if you're not using FirebaseAuth user in this class, you could just hide the User class from firebase auth like this:

   import 'package:firebase_auth/firebase_auth.dart' hide User;

This will, as its name says, hide the class User so it won't be available in the current file.

Upvotes: 1

Fatima ayaa
Fatima ayaa

Reputation: 650

Import your user model as an alias

import '../../User.dart' as userModel;

use it like

userModel.User user = .........

Upvotes: 2

Related Questions