Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to use CopyWith when models are imported with namespace #49

Open
rbresjer opened this issue Apr 21, 2022 · 2 comments
Open

Unable to use CopyWith when models are imported with namespace #49

rbresjer opened this issue Apr 21, 2022 · 2 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@rbresjer
Copy link

Describe the issue

I make use of FlutterFire Firebase Authentication. This package declares a model User which clashes with my own User model. Therefore I import Firebase Authentication namespaced: import 'package:firebase_auth/firebase_auth.dart' as firebase_auth;. I have a model AuthenticationState which looks as follows:

@CopyWith()
class AuthenticationState {
  AuthenticationState({
    required this.user,
    this.firebaseUser,
  });

  final User user;
  final firebase_auth.User? firebaseUser;
}

CopyWith however doesn't take the namespace in account and sees both properties as User. I also tried defining a typedef typedef FirebaseUser = firebase_auth.User; and use that, but CopyWith then still types firebaseUser as User which resolves to my own User model.

Environment details

➜ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.10.5, on macOS 12.3.1 21E258 darwin-x64, locale en-NL)
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 13.3.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2020.3)
[✓] VS Code (version 1.66.2)
[✓] Connected device (2 available)
[✓] HTTP Host Availability

• No issues found!

➜ flutter --version
Flutter 2.10.5 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 5464c5bac7 (3 days ago) • 2022-04-18 09:55:37 -0700
Engine • revision 57d3bac3dd
Tools • Dart 2.16.2 • DevTools 2.9.2

Paste the package version.

dependencies:
  copy_with_extension: ^4.0.0
dev_dependencies:
  copy_with_extension_gen: ^4.0.1

To Reproduce

I think the issue is clear.

Expected behaviour

I think the issue is clear.

Additional context

Let me know what you need :-)

@numen31337 numen31337 added the enhancement New feature or request label May 19, 2022
@numen31337 numen31337 added the help wanted Extra attention is needed label Aug 4, 2022
@zzorba
Copy link

zzorba commented Mar 28, 2023

Seeing a similar thing happen with a field that has been typedefed to another (imported) class. It seems to not use the typedef name, and also doesn't import the underlying source file.

@alexobviously
Copy link

This is also causing problems for me, since I have a class that uses two libraries that have classes with the same name, so obviously i have to import as at least one of them, but since this extension doesn't recognise namespaced imports, it fails.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants