lib/pages/user_profile_page/widgets/profile_image_widget:43:51: Error: Too many positional arguments: 0 allowed, but 2 found.
Try removing the extra positional arguments.
final downloadUrl = await uploadProfileImage(widget.userId, imageFile);
uploadProfileImage 함수는 named parameters (이름 있는 인자) 방식을 사용하고 있음:
Future<void> uploadProfileImage({
required String userId,
required File imageFile,
})
그런데 함수 호출 시에는 positional parameters (순서 인자) 방식으로 잘못 호출:
// 잘못된 예
uploadProfileImage(widget.userId, imageFile); // ❌
이 호출 방식은 "순서대로 인자를 전달"하는 방식인데, 이 함수는 이를 허용하지 않음.
// 올바른 방식
await uploadProfileImage(
userId: widget.userId,
imageFile: imageFile,
);
이렇게 작성하면 uploadProfileImage 함수 정의에 맞게 인자를 전달하므로 오류가 해결됨.
users/{userId} 문서의 photoUrl 필드에 저장됨.userProfileProvider는 StreamProvider 기반이기 때문에 Firestore에 변경이 반영되면 자동으로 UI가 최신 상태로 갱신됨.named parameters를 사용하는 함수는 호출 시 반드시 키워드를 사용해야 함.image_picker 오류PlatformException(channel-error, Unable to establish connection on channel: "dev.flutter.pigeon.image_picker_ios.ImagePickerApi.pickImage".)
image_picker 플러그인이 채널 연결에 실패image_picker는 카메라 사용 불가ios/Runner/Info.plist에 아래 추가:
<key>NSPhotoLibraryUsageDescription</key>
<string>프로필 사진을 선택하기 위해 사진 접근이 필요합니다.</string>
<key>NSCameraUsageDescription</key>
<string>프로필 사진을 촬영하기 위해 카메라 접근이 필요합니다.</string>
ImageSource.camera 사용 시 실패합니다ImageSource.gallery로만 테스트하세요flutter pub add image_picker
그리고 반드시 실행:
flutter clean
flutter pub get
1, 2는 잘되어었지만, 3에 해당하는 ios pod 초기화 후 클린빌드를 안했었음.
사용자가 프로필 이미지를 탭함
image_picker로 갤러리에서 이미지 선택
선택된 이미지가 Firebase Storage에 업로드
users/{userId}/profile.jpg업로드 완료 후 다운로드 URL을 가져옴
Firestore의 users/{userId} 문서에 photoUrl 필드를 URL로 갱신
UI는 StreamProvider로 실시간 반영됨
Firebase Storage:
├── users/
│ └── {userId}/
│ └── profile.jpg ← 항상 이 경로 하나만 유지
Firestore:
├── users/
│ └── {userId} → { photoUrl: "https://firebasestorage.googleapis.com/..." }