Back

Conflicting Imports(Flutter)

  • 1
  • Users
  • Flutter
  • Accounts
mmjsmohit
23 May, 2023, 07:04

I was following a tutorial to integrate Authentication in an App I am making. Link: https://devdactic.com/flutter-authentication-appwrite I am getting this error: The name 'Account' is defined in the libraries 'package:appwrite/appwrite.dart' and 'package:appwrite/models.dart'. Try using 'as prefix' for one of the import directives, or hiding the name from all but one of the imports. in the auth_api.dart file. Any idea how this can be fixed?

TL;DR
The user encountered a conflicting import error in Flutter while following a tutorial. They cannot find the User class and have tried adding a prefix everywhere the Account class is imported, but it did not work. The user is on the latest version and suggested updating to resolve the issue. Another solution proposed is to use a prefix in one of the conflicting imports. The user shared their code and asked for assistance. Solution: In the code file `auth_api.dart`, use the import directive with a prefix for one of the conflicting imports. For example, `import 'package:appwrite/appwrite.dart' as appwrite;`
D5
23 May, 2023, 07:07

Could you please share your code?

D5
23 May, 2023, 07:08

Or what's giving you such error?

mmjsmohit
23 May, 2023, 07:08

Here you go.

Maniac_Fighter
23 May, 2023, 07:35

Just use prefix in one of them

Maniac_Fighter
23 May, 2023, 07:36

So it would be import”some-lib” as customName (you can use models )

Maniac_Fighter
23 May, 2023, 07:36

Then you can access the lib code as models.(the properties)

Vedsaga
23 May, 2023, 07:43

or possibly you can update latest version there it won't happen

mmjsmohit
23 May, 2023, 07:45

I am on the latest version

mmjsmohit
23 May, 2023, 07:45

Yeah I tried it doesn't work.

Maniac_Fighter
23 May, 2023, 07:46

It works you just need to add prefix everywhere where the account class from model lib is used

mmjsmohit
23 May, 2023, 07:49

It says it can't find the User class.

Vedsaga
23 May, 2023, 08:00

User is in latest version there shouldn't be any conflict pls can show how and what you imported

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more