Coder Social home page Coder Social logo

The name 'Key' is defined in the libraries 'package:encrypt/encrypt.dart' and 'package:flutter/src/foundation/key.dart'. about encrypt HOT 12 CLOSED

leocavalcante avatar leocavalcante commented on July 18, 2024
The name 'Key' is defined in the libraries 'package:encrypt/encrypt.dart' and 'package:flutter/src/foundation/key.dart'.

from encrypt.

Comments (12)

leocavalcante avatar leocavalcante commented on July 18, 2024 28

You have a naming conflict, two libraries are exporting a symbol named Key.
You can solve this by adding an alias like:

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

Then using the aliased version for every symbol:

final key = encrypt.Key.fromUtf8()
final iv = encrypt.IV.fromUtf8()
final encrypted = encrypt.Encrypter()

You can also alternatively hide the Key, if it isn't in use, exported by Flutter, like:

import 'package:flutter/material.dart' hide Key;

Duplicated

from encrypt.

allstar456 avatar allstar456 commented on July 18, 2024

thank you!

from encrypt.

blackbeltandre avatar blackbeltandre commented on July 18, 2024

thanks!

from encrypt.

cookie-blood avatar cookie-blood commented on July 18, 2024

Thanks!

from encrypt.

kea137 avatar kea137 commented on July 18, 2024

Thanks

from encrypt.

schhunheng avatar schhunheng commented on July 18, 2024

thank you!

from encrypt.

goc20 avatar goc20 commented on July 18, 2024

can someone solve this issue also:
error: The name 'User' is defined in the libraries 'package:firebase_auth/firebase_auth.dart' and 'package:tunein/models/user.dart'. (ambiguous_import at [tunein] lib/resources/firebase_methods.dart:45)
//this is my firebase_methods .dart
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:google_sign_in/google_sign_in.dart';
import 'package:tunein/models/user.dart';
import 'package:tunein/utils/utilities.dart';
class FirebaseMethods {
final FirebaseAuth _auth = FirebaseAuth.instance;
GoogleSignIn _googleSignIn = GoogleSignIn();
static final Firestore firestore = Firestore.instance;

//user class
User user = User();

Future getCurrentUser() async {
FirebaseUser currentUser;
currentUser = FirebaseAuth.instance.currentUser;
return currentUser;
}

Future signIn() async {
GoogleSignInAccount _signInAccount = await _googleSignIn.signIn();
GoogleSignInAuthentication _signInAuthentication =
await _signInAccount.authentication;

final AuthCredential credential = GoogleAuthProvider.getCredential(
    accessToken: _signInAuthentication.accessToken,
    idToken: _signInAuthentication.idToken);

User user = (await _auth.signInWithCredential(credential)).user;
return user;

}

Future authenticateUser(User user) async {
QuerySnapshot result = await firestore
.collection("users")
.where("email", isEqualTo: user.email)
.getDocuments();

final List<DocumentSnapshot> docs = result.documents;

//if user is registered then length of list > 0 or else less than 0
return docs.length == 0 ? true : false;

}

Future addDataToDb(User currentUser) async {
String username = Utils.getUsername(currentUser.email);

user = User(
    uid: currentUser.uid,
    email: currentUser.email,
    name: currentUser.displayName,
    profilePhoto: currentUser.photoUrl,
    username: username);

firestore
    .collection("users")
    .document(currentUser.uid)
    .setData(user.toMap(user));

}

}

//this is my user.dart file
class User {
String uid;
String name;
String email;
String username;
String status;
int state;
String profilePhoto;

User({
this.uid,
this.name,
this.email,
this.username,
this.status,
this.state,
this.profilePhoto,
});

Map toMap(User user) {
var data = Map<String, dynamic>();
data['uid'] = user.uid;
data['name'] = user.name;
data['email'] = user.email;
data['username'] = user.username;
data["status"] = user.status;
data["state"] = user.state;
data["profile_photo"] = user.profilePhoto;
return data;
}

User.fromMap(Map<String, dynamic> mapData) {
this.uid = mapData['uid'];
this.name = mapData['name'];
this.email = mapData['email'];
this.username = mapData['username'];
this.status = mapData['status'];
this.state = mapData['state'];
this.profilePhoto = mapData['profile_photo'];
}
}

from encrypt.

adityarsingh avatar adityarsingh commented on July 18, 2024

Thank You!

from encrypt.

kuldep-cloud avatar kuldep-cloud commented on July 18, 2024

thankyou

from encrypt.

v1ncere avatar v1ncere commented on July 18, 2024

Thank you!

from encrypt.

lyfer-bob avatar lyfer-bob commented on July 18, 2024

Thank bro

from encrypt.

ged-flod avatar ged-flod commented on July 18, 2024

Thank you !

from encrypt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.