fromis_9/app/lib/services/download_service.dart
caadiq 5691cb6ce0 Flutter 앱: 앨범 상세 화면, 라이트박스, 다운로드 기능 추가
- 앨범 상세 화면 구현 (히어로, 티저, 수록곡, 컨셉포토 섹션)
- 티저/컨셉포토 라이트박스 (photo_view 핀치줌)
- flutter_downloader로 백그라운드 이미지 다운로드
- modal_bottom_sheet로 앨범 소개 다이얼로그
- 뒤로가기 두 번 눌러 종료 기능
- 앱 아이콘 변경 (fromis_9 로고)
- 모든 아이콘 Lucide Icons로 통일
- 앨범 목록 애니메이션 최적화 (스크롤 시 애니메이션 제거)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 10:42:52 +09:00

54 lines
1.4 KiB
Dart

/// 다운로드 서비스
library;
import 'dart:io';
import 'package:flutter_downloader/flutter_downloader.dart';
import 'package:path_provider/path_provider.dart';
import 'package:permission_handler/permission_handler.dart';
/// 다운로드 서비스 초기화
Future<void> initDownloadService() async {
await FlutterDownloader.initialize(
debug: false,
ignoreSsl: true,
);
}
/// 이미지 다운로드
Future<String?> downloadImage(String url, {String? fileName}) async {
// 권한 요청
if (Platform.isAndroid) {
final status = await Permission.notification.request();
if (status.isDenied) {
// 알림 권한 거부해도 다운로드는 진행
}
}
// 다운로드 경로 설정
Directory? directory;
if (Platform.isAndroid) {
directory = Directory('/storage/emulated/0/Download');
if (!await directory.exists()) {
directory = await getExternalStorageDirectory();
}
} else {
directory = await getApplicationDocumentsDirectory();
}
if (directory == null) return null;
// 파일명 생성
final name = fileName ?? 'fromis9_${DateTime.now().millisecondsSinceEpoch}.jpg';
// 다운로드 시작
final taskId = await FlutterDownloader.enqueue(
url: url,
savedDir: directory.path,
fileName: name,
showNotification: true,
openFileFromNotification: true,
);
return taskId;
}