Compare commits

...

24 Commits
dev ... master

Author SHA1 Message Date
Spark 04e09c2507 fix: 修复登录bug, 添加登录/注册页面点击任意非文本框失焦
6 days ago
Spark e908f62d86 fix: 修复评论BUG, 修复TOP50点赞\收藏问题
6 days ago
Spark 38921f848f feat: 调整播放器样式, 启用页面保持, 添加下拉刷新
7 days ago
Spark fc613ee961 fix: 调整播放器样式,修改快速切换 AudioPlayer 无法正确释放的问题
7 days ago
Spark bbf70c81c6 feat: 调整登录页面的一些样式,在注册页面加入验证码发送倒计时
1 week ago
Spark 5ef4804e2f Merge branch 'refs/heads/dev'
1 week ago
Spark cbdad8db5b fix: 修复歌单列表显示问题
1 week ago
Spark c4583e9d82 Merge branch 'refs/heads/dev'
1 week ago
Spark 230fe5511d fix: 修复歌单页面重复显示的问题
1 week ago
Spark 1bab49f997 Merge branch 'refs/heads/dev'
1 week ago
Spark 8e16ac8ad2 feat: 对接获取歌单歌曲接口,对接我的作品数量和我的作品内容接口,删除歌单中我的收藏和本地下载两行
1 week ago
Spark 874c491b0d fix: 修复合并后出现的一些Bug,调整了一些样式
2 weeks ago
Spark 08a374f864 Merge branch 'refs/heads/dev2'
2 weeks ago
Spark db425e3cbe feat: 完成搜索功能
2 weeks ago
Spark 0f0341fc19 fix: 修复合并后出现的一些BUG,修复排行榜更多按钮溢出,移除更多弹出面板中的“查看详细”和“取消”按钮,修复底部菜单栏溢出的问题,
2 weeks ago
Spark b76c58a7fb Merge branch 'refs/heads/dev2'
2 weeks ago
Spark e47f94c932 修复侧边栏PIXELSFLOWED BY 53的问题
2 weeks ago
Plus One 520115c2b0 添加了获取歌单中所有歌曲和获取我的作品接口
2 weeks ago
Spark dc5752b2c6 fix: 修复了父子组件切换数据不一致的问题
2 weeks ago
Spark acb07b7a7b fix: 修复了一些BUG
2 weeks ago
Spark e398fd114b Merge branch 'refs/heads/dev'
2 weeks ago
Spark 8dccdc56c4 发布和音乐界面
2 weeks ago
Spark 91386b243f 完成本地下载页面,修复离开页面下载终止问题
2 weeks ago
Spark 5a0540924d 实现音乐下载功能,替换播放器为流式播放器,修复上\下一曲BUG,修复播放\暂停按钮点击BUG,引入歌曲切换加载提示
2 weeks ago

@ -0,0 +1,2 @@
#Mon Oct 28 21:45:22 CST 2024
java.home=C\:\\Program Files\\Android\\Android Studio\\jbr

@ -0,0 +1,8 @@
## This file must *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.
#
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
#Mon Oct 28 21:45:22 CST 2024
sdk.dir=C\:\\Users\\zxp\\AppData\\Local\\Android\\Sdk

@ -30,4 +30,8 @@
android:name="flutterEmbedding"
android:value="2" />
</application>
<!-- 添加存储权限 -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"/>
</manifest>

@ -1,6 +1,13 @@
buildscript {
ext.kotlin_version = '1.7.10'
repositories {
maven { url 'https://maven.aliyun.com/repository/public/' }
maven { url 'https://maven.aliyun.com/repository/spring/'}
maven { url 'https://maven.aliyun.com/repository/google/'}
maven { url 'https://maven.aliyun.com/repository/gradle-plugin/'}
maven { url 'https://maven.aliyun.com/repository/spring-plugin/'}
maven { url 'https://maven.aliyun.com/repository/grails-core/'}
maven { url 'https://maven.aliyun.com/repository/apache-snapshots/'}
google()
mavenCentral()
}
@ -13,8 +20,16 @@ buildscript {
allprojects {
repositories {
maven { url 'https://maven.aliyun.com/repository/public/' }
maven { url 'https://maven.aliyun.com/repository/spring/'}
maven { url 'https://maven.aliyun.com/repository/google/'}
maven { url 'https://maven.aliyun.com/repository/gradle-plugin/'}
maven { url 'https://maven.aliyun.com/repository/spring-plugin/'}
maven { url 'https://maven.aliyun.com/repository/grails-core/'}
maven { url 'https://maven.aliyun.com/repository/apache-snapshots/'}
google()
mavenCentral()
mavenCentral()
}
}

@ -1,3 +1,4 @@
org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
systemProp.org.gradle.wrapper.timeout=300000

@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip
distributionUrl=https\://mirrors.cloud.tencent.com/gradle/gradle-7.5-all.zip

Binary file not shown.

After

Width:  |  Height:  |  Size: 749 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 356 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 299 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 589 B

@ -6,11 +6,11 @@ import 'package:music_player_miao/models/universal_bean.dart';
import '../models/getInfo_bean.dart';
import '../models/login_bean.dart';
const String _LoginURL = 'http://flyingpig.fun:10010/users/login';
const String _LogoutURL = 'http://flyingpig.fun:10010/users/logout';
const String _SetupURL = 'http://flyingpig.fun:10010/email/register';
const String _verificationURL = 'http://flyingpig.fun:10010/email/verificationCode';
const String _GetInfoURL = 'http://flyingpig.fun:10010/users/info';
const String _LoginURL = 'http://8.210.250.29:10010/users/login';
const String _LogoutURL = 'http://8.210.250.29:10010/users/logout';
const String _SetupURL = 'http://8.210.250.29:10010/email/register';
const String _verificationURL = 'http://8.210.250.29:10010/email/verificationCode';
const String _GetInfoURL = 'http://8.210.250.29:10010/users/info';
///
class LoginApiClient {

@ -1,14 +1,14 @@
import 'dart:io';
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import '../models/universal_bean.dart';
const String _changeNameURL = 'http://flyingpig.fun:10010/users/username';
const String _changeHeaderURL = 'http://flyingpig.fun:10010/users/avatar';
const String _changeNameURL = 'http://8.210.250.29:10010/users/username';
const String _changeHeaderURL = 'http://8.210.250.29:10010/users/avatar';
class ChangeApiClient {
final Dio dio = Dio();
final ValueNotifier<String> avatarUrlNotifier = ValueNotifier<String>("");
///
Future<UniversalBean> changeName({
required String Authorization,
@ -16,13 +16,19 @@ class ChangeApiClient {
}) async {
Response response = await dio.put(
_changeNameURL,
data: {
'Authorization': Authorization,
},
// data: {
// 'Authorization': Authorization,
// },
queryParameters: {'userName':userName},
options: Options(headers:{'Authorization':Authorization,'Content-Type':'application/json;charset=UTF-8'})
options: Options(
headers:{
'Authorization':Authorization,
'Content-Type':'application/json;charset=UTF-8'
}
)
);
print(response.data);
return UniversalBean.formMap(response.data);
}
///
@ -32,7 +38,7 @@ class ChangeApiClient {
required File avatar,
}) async {
FormData formData = FormData.fromMap({
'Authorization': Authorization,
// 'Authorization': Authorization,
'avatar': await MultipartFile.fromFile(avatar.path, filename: 'avatar.jpg'),
});
@ -46,8 +52,8 @@ class ChangeApiClient {
},
),
);
print(response.data);
avatarUrlNotifier.value = avatar.path;
return UniversalBean.formMap(response.data);
}

@ -3,7 +3,7 @@
import 'package:dio/dio.dart';
import 'package:music_player_miao/models/universal_bean.dart';
const String _CollectionURL = 'http://flyingpig.fun:10010/collections';
const String _CollectionURL = 'http://8.210.250.29:10010/collections';
class CollectionApiMusic {
final Dio dio = Dio();

@ -0,0 +1,110 @@
import 'dart:io';
import 'package:dio/dio.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:flutter/material.dart';
import 'package:path/path.dart' as path;
class DownloadApi {
final Dio dio = Dio();
//
Future<bool> _requestStoragePermission(BuildContext context) async {
//
PermissionStatus status = await Permission.manageExternalStorage.status;
if (status.isDenied) {
//
// PermissionStatus status1 = await Permission.storage.request();
status = await Permission.manageExternalStorage.request();
print(status);
if (status.isDenied || status.isPermanentlyDenied || status.isRestricted) {
if (context.mounted) {
showDialog(
context: context,
builder: (BuildContext context) => AlertDialog(
title: const Text('需要存储权限'),
content: const Text('下载音乐需要存储权限,请在设置中允许访问存储权限。'),
actions: <Widget>[
TextButton(
child: const Text('取消'),
onPressed: () => Navigator.of(context).pop(),
),
TextButton(
child: const Text('去设置'),
onPressed: () {
Navigator.of(context).pop();
openAppSettings(); //
},
),
],
),
);
}
return false;
}
}
return status.isGranted;
}
String _getFileExtension(String url) {
// Remove query parameters
final urlWithoutQuery = url.split('?').first;
// Get the extension including the dot
final extension = path.extension(urlWithoutQuery);
return extension.isNotEmpty ? extension : '.mp3'; // Default to .mp3 if no extension found
}
Future<String?> downloadMusic({
required String musicUrl,
required String name,
required BuildContext context,
required Function(double) onProgress,
}) async {
try {
String fileExtension = _getFileExtension(musicUrl);
final fileName = '$name$fileExtension';
//
if (!await _requestStoragePermission(context)) {
throw Exception('没有存储权限');
}
//
final downloadDir = Directory('/storage/emulated/0/MTMusic');
if (!await downloadDir.exists()) {
await downloadDir.create(recursive: true);
}
//
final filePath = '${downloadDir.path}/$fileName';
print("Music URL: $musicUrl");
print("Saving as: $filePath");
//
await dio.download(
musicUrl,
filePath,
options: Options(
headers: {
//
},
),
onReceiveProgress: (received, total) {
if (total != -1) {
//
double progress = received / total;
onProgress(progress); //
}
},
);
return filePath;
} catch (e) {
print('Download error: $e');
return null;
}
}
}

@ -4,7 +4,7 @@
import 'package:dio/dio.dart';
import 'package:music_player_miao/models/universal_bean.dart';
const String _LikesURL = 'http://flyingpig.fun:10010/likes';
const String _LikesURL = 'http://8.210.250.29:10010/likes';
class LikesApiMusic {
final Dio dio = Dio();

@ -1,16 +1,34 @@
import 'package:dio/dio.dart';
import '../common_widget/Song_widegt.dart';
import '../models/getMusicList_bean.dart';
import '../models/getRank_bean.dart';
const String _getMusic1 = 'http://flyingpig.fun:10010/musics/1';
const String _getMusic2 = 'http://flyingpig.fun:10010/musics/2';
const String _getMusic3 = 'http://flyingpig.fun:10010/musics/3';
const String _getMusic = 'http://8.210.250.29:10010/musics/';
const String _getMusic1 = 'http://8.210.250.29:10010/musics/1';
const String _getMusic2 = 'http://8.210.250.29:10010/musics/2';
const String _getMusic3 = 'http://8.210.250.29:10010/musics/3';
const String _getSongDetail = 'http://8.210.250.29:10010/musics';
///
///
class GetMusic {
final Dio dio = Dio();
Future<MusicListBean> getMusicById({required int id, required String Authorization}) async {
print(_getMusic + id.toString());
Response response = await dio.get(
_getMusic + id.toString(),
data: {
'Authorization': Authorization,
},
options: Options(headers: {
'Authorization': Authorization,
'Content-Type': 'application/json;charset=UTF-8'
}));
print(response.data);
return MusicListBean.formMap(response.data);
}
Future<MusicListBean> getMusic1({required String Authorization}) async {
Response response = await dio.get(
_getMusic1,
@ -51,3 +69,40 @@ class GetMusic {
return MusicListBean.formMap(response.data);
}
}
//
class GetMusicDetail {
final Dio dio = Dio();
// ID
Future<Song> getMusicDetail({required int songId, required String Authorization}) async {
try {
// songId URL
final String url = 'http://8.210.250.29:10010/musics/$songId'; // API
// GET
Response response = await dio.get(
url,
options: Options(
headers: {
'Authorization': Authorization,
'Content-Type': 'application/json;charset=UTF-8',
},
),
);
print("Song detail response: ${response.data}");
//
if (response.statusCode == 200) {
// Song
return Song.fromMap(response.data['data']);
} else {
throw Exception("Failed to load song details");
}
} catch (e) {
print("Error occurred while fetching song details: $e");
rethrow; //
}
}
}

@ -2,7 +2,7 @@ import 'package:dio/dio.dart';
import '../models/getRank_bean.dart';
const String _getRank = 'http://flyingpig.fun:10010/musics/rank-list';
const String _getRank = 'http://8.210.250.29:10010/musics/rank-list';
///
class GetRank {
final Dio dio = Dio();

@ -6,21 +6,30 @@ import 'package:music_player_miao/models/universal_bean.dart';
import '../models/getComment_bean.dart';
import '../models/search_bean.dart';
const String _SearchURL = 'http://flyingpig.fun:10010/musics/search';
const String _postComment = 'http://flyingpig.fun:10010/comments';
const String _SearchURL = 'http://8.210.250.29:10010/musics/search';
const String _postComment = 'http://8.210.250.29:10010/comments';
///
class SearchMusic {
final Dio dio = Dio();
Future<SearchBean> search({required String keyword,}) async {
Future<SearchBean> search({
required String keyword,
required String Authorization,
}) async {
Response response = await dio.get(
_SearchURL,
queryParameters: {'keyword':keyword}
queryParameters: {'keyword': keyword},
options: Options(headers: {
'Authorization': Authorization,
'Content-Type': 'application/json;charset=UTF-8',
}),
);
print(response.data);
return SearchBean.formMap(response.data);
}
}
///
class commentMusic {
final Dio dio = Dio();
@ -33,7 +42,7 @@ class commentMusic {
_postComment,
data: {
'content': content,
'MusicId': musicId,
'musicId': musicId,
'Authorization':Authorization
},
@ -48,9 +57,9 @@ class commentMusic {
class getCommentApi {
final Dio dio = Dio();
Future<GetCommentBean> getComment({
required String musicId,
required String pageNo,
required String pageSize,
required int musicId,
required int pageNo,
required int pageSize,
required String Authorization,
}) async {
Response response = await dio.get(

@ -7,7 +7,7 @@ import 'dart:io';
import 'package:path/path.dart';
const String _ReleaseURL = 'http://flyingpig.fun:10010/musics';
const String _ReleaseURL = 'http://8.210.250.29:10010/musics';
///
class ReleaseApi {

@ -2,13 +2,41 @@ import 'package:dio/dio.dart';
import 'package:music_player_miao/models/search_bean.dart';
import 'package:music_player_miao/models/songlist_bean.dart';
import '../models/getAllSongs_bean.dart';
import '../models/universal_bean.dart';
import 'package:music_player_miao/models/getMyWorks.dart';
const String _SonglistURL = 'http://8.210.250.29:10010/songlists';
const String _MyWorksURL = 'http://8.210.250.29:10010/musics/upload-music';
const String _SonglistURL = 'http://flyingpig.fun:10010/songlists';
///
class SonglistApi {
final Dio dio = Dio();
///
Future<MyMusicListBean> getAllSongs({required int id, required String Authorization}) async {
String urlWithId = 'http://8.210.250.29:10010/songlist-musics/$id/music-list';
Response response = await dio.get(urlWithId,
options: Options(headers: {
'Authorization': Authorization,
'Content-Type': 'application/json;charset=UTF-8'
}));
print(response.data);
return MyMusicListBean.formMap(response.data);
}
///
Future<MyWorks> getMyworks({required String Authorization}) async {
Response response = await dio.get(_MyWorksURL,
data: {
'Authorization': Authorization,
},
options: Options(headers: {
'Authorization': Authorization,
'Content-Type': 'application/json;charset=UTF-8'
}));
print(response.data);
return MyWorks.formMap(response.data);
}
///
Future<SearchBean> getSonglist({required String Authorization}) async {
Response response = await dio.get(_SonglistURL,
data: {

@ -0,0 +1,201 @@
// audio_player_controller.dart
import 'dart:async';
import 'package:get/get.dart';
import 'package:just_audio/just_audio.dart';
import '../common_widget/Song_widegt.dart';
import '../models/getMusicList_bean.dart';
import '../common/download_manager.dart';
import '../common_widget/app_data.dart';
import '../api/api_music_list.dart';
class AudioPlayerController extends GetxController {
final audioPlayer = AudioPlayer();
final downloadManager = Get.find<DownloadManager>();
final appData = AppData();
// Observable values
final currentSongIndex = 0.obs;
final duration = Duration.zero.obs;
final position = Duration.zero.obs;
final isPlaying = false.obs;
final isLoading = false.obs;
final isRotating = false.obs;
final isDisposed = false.obs;
// Current song info
final artistName = ''.obs;
final musicName = ''.obs;
final likesStatus = false.obs;
final collectionsStatus = false.obs;
// Song lists
final songList = <Song>[].obs;
final ids = <int>[].obs;
final songUrls = <String>[].obs;
final artists = <String>[].obs;
final musicNames = <String>[].obs;
final likes = <bool>[].obs;
final collections = <bool>[].obs;
StreamSubscription? _positionSubscription;
StreamSubscription? _durationSubscription;
StreamSubscription? _playerStateSubscription;
void initWithSongs(List<Song> songs, int initialIndex) {
songList.value = songs;
currentSongIndex.value = initialIndex;
_initializeSongLists();
_initializePlayer();
}
void _initializeSongLists() {
for (int i = 0; i < songList.length; i++) {
ids.add(songList[i].id);
songUrls.add(songList[i].musicurl ?? '');
artists.add(songList[i].artist);
musicNames.add(songList[i].title);
likes.add(songList[i].likes ?? false);
collections.add(songList[i].collection ?? false);
}
_updateCurrentSongInfo();
}
void _initializePlayer() {
// Position updates
_positionSubscription = audioPlayer.positionStream.listen((pos) {
position.value = pos;
});
// Duration updates
_durationSubscription = audioPlayer.durationStream.listen((dur) {
duration.value = dur ?? Duration.zero;
});
// Player state updates
_playerStateSubscription = audioPlayer.playerStateStream.listen((state) {
// isPlaying.value = state.playing;
if (state.processingState == ProcessingState.completed) {
playNext();
}
});
// Initial load
_loadAndPlayCurrentSong();
}
void _updateCurrentSongInfo() {
artistName.value = artists[currentSongIndex.value];
musicName.value = musicNames[currentSongIndex.value];
likesStatus.value = likes[currentSongIndex.value];
collectionsStatus.value = collections[currentSongIndex.value];
}
Future<void> toggleLike() async {
final currentIndex = currentSongIndex.value;
likesStatus.value = !likesStatus.value;
likes[currentIndex] = likesStatus.value;
}
Future<void> toggleCollection() async {
final currentIndex = currentSongIndex.value;
collectionsStatus.value = !collectionsStatus.value;
collections[currentIndex] = collectionsStatus.value;
}
Future<void> _loadAndPlayCurrentSong() async {
isLoading.value = true;
position.value = Duration.zero;
duration.value = Duration.zero;
_updateCurrentSongInfo();
await _checkAndUpdateSongStatus(currentSongIndex.value);
try {
await audioPlayer.stop();
final localSong = downloadManager.getLocalSong(currentSongIndex.value);
final audioSource = localSong != null
? AudioSource.file(localSong.musicurl!)
: AudioSource.uri(Uri.parse(songUrls[currentSongIndex.value]));
await audioPlayer.setAudioSource(audioSource, preload: true);
duration.value = await audioPlayer.duration ?? Duration.zero;
await audioPlayer.play();
} catch (e) {
print('Error loading audio source: $e');
} finally {
isLoading.value = false;
}
}
Future<void> _checkAndUpdateSongStatus(int index) async {
if (songList[index].likes == null || songList[index].collection == null) {
try {
MusicListBean musicListBean = await GetMusic().getMusicById(
id: ids[index],
Authorization: appData.currentToken,
);
if (musicListBean.code == 200) {
likes[index] = musicListBean.likeOrNot!;
collections[index] = musicListBean.collectOrNot!;
if (index == currentSongIndex.value) {
likesStatus.value = musicListBean.likeOrNot!;
collectionsStatus.value = musicListBean.collectOrNot!;
}
}
} catch (e) {
print('Error fetching song status: $e');
}
}
}
void playOrPause() async {
if (audioPlayer.playing) {
isPlaying.value = false;
await audioPlayer.pause();
} else {
await audioPlayer.play();
isPlaying.value = true;
}
}
void playNext() {
if (currentSongIndex.value < songList.length - 1) {
currentSongIndex.value++;
} else {
currentSongIndex.value = 0;
}
_loadAndPlayCurrentSong();
}
void playPrevious() {
if (currentSongIndex.value > 0) {
currentSongIndex.value--;
} else {
currentSongIndex.value = songList.length - 1;
}
_loadAndPlayCurrentSong();
}
void seekTo(Duration position) async {
await audioPlayer.seek(position);
}
void changeSong(int index) {
currentSongIndex.value = index;
_loadAndPlayCurrentSong();
}
@override
void onClose() {
isDisposed.value = true;
_positionSubscription?.cancel();
_durationSubscription?.cancel();
_playerStateSubscription?.cancel();
audioPlayer.dispose();
super.onClose();
}
}

@ -0,0 +1,213 @@
import 'dart:convert';
import 'dart:io';
import 'package:get/get.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../api/api_download.dart';
import '../common_widget/Song_widegt.dart';
import 'package:path/path.dart' as path;
class DownloadItem {
final Song song;
double progress;
bool isCompleted;
bool isDownloading;
DownloadItem({
required this.song,
this.progress = 0.0,
this.isCompleted = false,
this.isDownloading = false,
});
Map<String, dynamic> toJson() {
return {
'song': {
'pic': song.pic,
'artistPic': song.artistPic,
'title': song.title,
'artist': song.artist,
'musicurl': song.musicurl,
'id': song.id,
'likes': song.likes,
'collection': song.collection
},
'progress': progress,
'isCompleted': isCompleted,
'isDownloading': isDownloading,
};
}
// JSONDownloadItem
factory DownloadItem.fromJson(Map<String, dynamic> json) {
return DownloadItem(
song: Song(
pic: json['song']['pic'],
artistPic: json['song']['artistPic'],
title: json['song']['title'],
artist: json['song']['artist'],
musicurl: json['song']['musicurl'],
id: json['song']['id'],
likes: json['song']['likes'],
collection: json['song']['collection'],
),
progress: json['progress'],
isCompleted: json['isCompleted'],
isDownloading: json['isDownloading'],
);
}
}
class DownloadManager extends GetxController {
static const String PREFS_KEY = 'downloads_data';
final _downloads = <String, DownloadItem>{}.obs;
final downloadApi = DownloadApi();
late SharedPreferences _prefs;
@override
void onInit() async {
super.onInit();
await _initPrefs();
}
Future<void> _initPrefs() async {
_prefs = await SharedPreferences.getInstance();
await _loadDownloadsFromPrefs();
}
// SharedPreferences
Future<void> _loadDownloadsFromPrefs() async {
final String? downloadsJson = _prefs.getString(PREFS_KEY);
if (downloadsJson != null) {
final Map<String, dynamic> downloadsMap = json.decode(downloadsJson);
downloadsMap.forEach((key, value) {
_downloads[key] = DownloadItem.fromJson(value);
});
}
}
// SharedPreferences
Future<void> _saveDownloadsToPrefs() async {
final Map<String, dynamic> downloadsMap = {};
_downloads.forEach((key, value) {
downloadsMap[key] = value.toJson();
});
await _prefs.setString(PREFS_KEY, json.encode(downloadsMap));
}
List<Song> getLocalSongs() {
final localSongs = <Song>[];
_downloads.forEach((key, value) {
if (value.isCompleted) {
localSongs.add(value.song);
}
});
return localSongs;
}
Map<String, DownloadItem> get downloads => _downloads;
bool isDownloading(int id) => _downloads[id.toString()]?.isDownloading ?? false;
bool isCompleted(int id) => _downloads[id.toString()]?.isCompleted ?? false;
double getProgress(int id) => _downloads[id.toString()]?.progress ?? 0.0;
Song? getLocalSong(int id) {
final downloadItem = _downloads[id.toString()];
if (downloadItem?.isCompleted ?? false) {
return downloadItem!.song;
}
return null;
}
bool removeSong(int id) {
if (_downloads[id.toString()]?.isCompleted ?? false) {
File file = File.fromUri(Uri.parse(_downloads[id.toString()]!.song.musicurl!));
file.deleteSync();
_downloads.remove(id.toString());
_saveDownloadsToPrefs();
return true;
}
return false;
}
int completedNumber() {
int count = 0;
_downloads.forEach((key, value) {
if (value.isCompleted) {
count++;
}
});
return count;
}
Future<void> startDownload({
required Song song,
required context,
}) async {
if (_downloads[song.id.toString()]?.isDownloading ?? false) return;
final fileName = '${song.id}_${song.title}_${song.artist}';
final downloadItem = DownloadItem(
song: song,
isDownloading: true,
);
_downloads[song.id.toString()] = downloadItem;
try {
final filePath = await downloadApi.downloadMusic(
musicUrl: song.musicurl!,
name: fileName,
context: context,
onProgress: (progress) {
downloadItem.progress = progress;
_downloads[song.id.toString()] = downloadItem;
},
);
if (filePath != null) {
downloadItem.isCompleted = true;
downloadItem.isDownloading = false;
downloadItem.progress = 1.0;
song.musicurl = _getLocalAudioPath(fileName, song.musicurl!);
print(song.musicurl);
} else {
downloadItem.isDownloading = false;
downloadItem.progress = 0.0;
}
} catch (e) {
print('Download error: $e');
downloadItem.isDownloading = false;
downloadItem.progress = 0.0;
}
_downloads[song.id.toString()] = downloadItem;
await _saveDownloadsToPrefs();
}
bool updateSongInfo(int id, bool isCollected, bool isLiked) {
final downloadItem = _downloads[id.toString()];
if (downloadItem != null) {
downloadItem.song.collection = isCollected;
downloadItem.song.likes = isLiked;
_downloads[id.toString()] = downloadItem;
_saveDownloadsToPrefs();
return true;
}
return false;
}
String _getFileExtension(String url) {
// Remove query parameters
final urlWithoutQuery = url.split('?').first;
// Get the extension including the dot
final extension = path.extension(urlWithoutQuery);
return extension.isNotEmpty ? extension : '.mp3'; // Default to .mp3 if no extension found
}
String _getLocalAudioPath(String fileName, String url) {
final extension = _getFileExtension(url);
final fullFileName = '$fileName$extension';
return path.join('/storage/emulated/0/MTMusic', fullFileName);
}
}

@ -1,12 +1,36 @@
class Song {
final String pic;
final String artistPic;
final String title;
final String artist;
final String musicurl;
final int id;
final bool likes;
final bool collection;
String pic;
String artistPic;
String title;
String artist;
String? musicurl;
int id;
bool? likes;
bool? collection;
Song({required this.pic,required this.artistPic,required this.title, required this.artist, required this.musicurl,required this.id,required this.likes,required this.collection});
//
Song({
required this.pic,
required this.artistPic,
required this.title,
required this.artist,
required this.musicurl,
required this.id,
required this.likes,
required this.collection,
});
// 使 Map Song
factory Song.fromMap(Map<String, dynamic> map) {
return Song(
pic: map['coverPath'] ?? '', // coverPath
artistPic: map['coverPath'] ?? '', // artistPic
title: map['name'] ?? '', // name
artist: map['singerName'] ?? '', // singerName
musicurl: map['musicPath'] ?? '', // musicPath
id: map['id'] ?? 0, // ID id
likes: map['likeOrNot'] ?? false, // likeOrNot
collection: map['collectOrNot'] ?? false, // collectOrNot
);
}
}

@ -7,5 +7,7 @@ class AppData extends GetxController{
String get currentToken => box.read('currentToken');
String get currentUsername => box.read('currentUsername') ?? '游客';
String get currentAvatar=> box.read('currentAvatar') ?? 'http://b.hiphotos.baidu.com/image/pic/item/e824b899a9014c08878b2c4c0e7b02087af4f4a3.jpg';
set currentToken(String token) => box.write('currentToken', token);
set currentUsername(String username) => box.write('currentUsername', username);
set currentAvatar(String avatar) => box.write('currentAvatar', avatar);
}

@ -1,7 +1,7 @@
import 'package:flutter/material.dart';
import '../api/api_music_likes.dart'; // API
import '../api/api_collection.dart'; // API
//
import '../view_model/comment_page.dart'; //
class RankSongsRow extends StatelessWidget {
final Map sObj;
@ -174,7 +174,12 @@ class RankSongsRow extends StatelessWidget {
IconButton(
onPressed: () {
//
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const CommentPage(),
),
);
},
icon: Image.asset("assets/img/list_comment.png"),
iconSize: 60,

@ -1,9 +1,13 @@
import 'package:flutter/material.dart';
import 'package:music_player_miao/common_widget/app_data.dart';
import 'package:music_player_miao/view/begin/begin_view.dart';
import 'package:music_player_miao/view/begin/login_v.dart';
import 'package:music_player_miao/view/home_view.dart';
import 'package:music_player_miao/view/splash_view.dart';
import 'package:get/get.dart';
import 'dart:io';
import 'package:flutter/services.dart';
import 'package:music_player_miao/view/user/user_view.dart';
void main(){
WidgetsFlutterBinding.ensureInitialized();
@ -20,9 +24,14 @@ class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return const GetMaterialApp(
debugShowCheckedModeBanner: false,
home: SplashView(),
return GetMaterialApp(
title: 'Flutter Demo',
initialRoute: '/login', //
routes: {
'/': (context) => HomeView(), //
'/user': (context) => UserView(),
'/login' : (context) => BeginView()// UserView
},
);
}
}

@ -0,0 +1,43 @@
class MyMusicListBean {
int? code;
String? msg;
List<DataBean>? data;
MyMusicListBean.formMap(Map map) {
code = map['code'];
msg = map['msg'];
if (map['data'] is! List) return;
data = (map['data'] as List)
.map((item) => DataBean._formMap(item))
.toList();
}
}
class DataBean {
int? songlistId;
SongDetails? musicDetail; // SongDetails
DataBean._formMap(Map map) {
songlistId = map['songlistId'];
musicDetail = SongDetails._formMap(map['musicDetail']); //
}
}
class SongDetails {
int? id;
String? name;
String? coverPath;
String? musicPath;
String? singerName;
String? uploadUserName;
SongDetails._formMap(Map map) {
id = map['id'];
name = map['name'];
coverPath = map['coverPath'];
musicPath = map['musicPath'];
singerName = map['singerName'];
uploadUserName = map['uploadUserName'];
}
}

@ -9,6 +9,8 @@ class MusicListBean {
String? uploadUserName;
bool? likeOrNot;
bool? collectOrNot;
MusicListBean.formMap(Map map){
code = map['code'];
msg= map['msg'];

@ -0,0 +1,34 @@
class MyWorks {
int? code;
String? msg;
List<DataBean>? data;
MyWorks.formMap(Map map) {
code = map['code'];
msg = map['msg'];
if (map['data'] == null) return;
List<dynamic>? dataList = map['data'];
if (dataList == null) return;
data = dataList
.map((item) => DataBean._formMap(item))
.toList();
}
}
class DataBean {
int? id;
String? name;
String? coverPath;
String? musicPath;
String? singerName;
DataBean._formMap(Map map) {
id = map['id'];
name = map['name'];
coverPath = map['coverPath'];
musicPath = map['musicPath'];
singerName = map['singerName'];
}
}

@ -24,8 +24,6 @@ class DataBean {
String? musicPath;
String? name;
DataBean._formMap(Map map) {
id = map['id'];
singerName = map['singerName'];

@ -8,7 +8,12 @@ class UniversalBean {
msg = map['msg'];
if (map['data'] is String) {
data = map['data'];
}}
} else if (map['data'] is bool) {
data = map['data'].toString();
} else {
data = null;
}
}
}

@ -17,19 +17,23 @@ class _BeginViewState extends State<BeginView> with TickerProviderStateMixin {
@override
void initState() {
tabController = TabController(
initialIndex: 0,
length: 2,
vsync: this
);
tabController = TabController(initialIndex: 0, length: 2, vsync: this);
tabController.addListener(() {
if (!tabController.indexIsChanging) {
FocusScope.of(context).unfocus();
}
});
super.initState();
}
@override
Widget build(BuildContext context) {
return Container(
decoration: BoxDecoration(
return GestureDetector(
onTap: () {
FocusScope.of(context).unfocus();
},
child: Container(
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/img/app_bg.png"),
fit: BoxFit.cover,
@ -37,11 +41,17 @@ class _BeginViewState extends State<BeginView> with TickerProviderStateMixin {
),
child: Scaffold(
backgroundColor: Colors.transparent,
body: SingleChildScrollView(
resizeToAvoidBottomInset: false,
body: ScrollConfiguration(
behavior: const ScrollBehavior().copyWith(
physics: const NeverScrollableScrollPhysics(),
),
child: Column(
children: [
//
Padding(
padding: const EdgeInsets.only(top: 110,left: 40,right: 40),
padding:
const EdgeInsets.only(top: 110, left: 40, right: 40),
child: Row(
children: [
const Column(
@ -51,8 +61,7 @@ class _BeginViewState extends State<BeginView> with TickerProviderStateMixin {
style: TextStyle(
color: Colors.black,
fontSize: 20,
fontWeight: FontWeight.w500
),
fontWeight: FontWeight.w500),
),
Row(
children: [
@ -61,35 +70,32 @@ class _BeginViewState extends State<BeginView> with TickerProviderStateMixin {
style: TextStyle(
color: Colors.black,
fontSize: 20,
fontWeight: FontWeight.w500
),
fontWeight: FontWeight.w500),
),
Text(
"喵听",
style: TextStyle(
color: Colors.black,
fontSize: 32,
fontWeight: FontWeight.w800
),
fontWeight: FontWeight.w800),
),
],
),
],
),
const SizedBox(width: 25,),
const SizedBox(width: 25),
Image.asset("assets/img/app_logo.png", width: 80),
],
),
),
SizedBox(
height: MediaQuery.of(context).size.height,
child: Stack(
children: [
Align(
child: SizedBox(
height: MediaQuery.of(context).size.height/1.06,
const SizedBox(height: 20), //
// 使 Expanded
Expanded(
child: Column(
children: [
// TabBar
Padding(
padding: const EdgeInsets.symmetric(horizontal: 30.0),
child: Material(
@ -98,27 +104,28 @@ class _BeginViewState extends State<BeginView> with TickerProviderStateMixin {
borderRadius: BorderRadius.circular(10),
child: TabBar(
controller: tabController,
unselectedLabelColor: Color(0xffCDCDCD),
unselectedLabelColor: const Color(0xffCDCDCD),
// onTap: (_) {
// FocusScope.of(context).unfocus();
// },
labelColor: Colors.black,
indicatorSize: TabBarIndicatorSize.tab,
indicator: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: MColor.LGreen
),
color: MColor.LGreen),
tabs: [
Container(
padding: EdgeInsets.all(8.0),
// color: Colors.pink,
child: Text(
padding: const EdgeInsets.all(8.0),
child: const Text(
'登录',
style: TextStyle(
fontSize: 20,
),
),
),
Container(
padding: EdgeInsets.all(8.0),
child: Text(
padding: const EdgeInsets.all(8.0),
child: const Text(
'注册',
style: TextStyle(
fontSize: 20,
@ -129,17 +136,16 @@ class _BeginViewState extends State<BeginView> with TickerProviderStateMixin {
),
),
),
// TabBarView
Expanded(
child: TabBarView(
controller: tabController,
children: [
physics: const NeverScrollableScrollPhysics(),
children: const [
LoginV(),
SignUpView(),
],
)
)
],
),
),
)
],
@ -149,6 +155,6 @@ class _BeginViewState extends State<BeginView> with TickerProviderStateMixin {
),
),
),
);
));
}
}

@ -4,15 +4,12 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:music_player_miao/common_widget/app_data.dart';
import 'package:music_player_miao/models/search_bean.dart';
import 'package:music_player_miao/view/main_tab_view/main_tab_view.dart';
import '../../api/api_client.dart';
import '../../api/api_songlist.dart';
import '../../common/color_extension.dart';
import '../../models/getInfo_bean.dart';
import '../../models/login_bean.dart';
import '../../models/songlist_bean.dart';
import '../../widget/my_text_field.dart';
class LoginV extends StatefulWidget {
@ -30,6 +27,16 @@ class _LoginVState extends State<LoginV> {
IconData iconPassword = CupertinoIcons.eye_fill;
bool obscurePassword = true;
final _passwordFocusNode = FocusNode();
final _nameFocusNode = FocusNode();
@override
void dispose() {
_passwordFocusNode.dispose();
_nameFocusNode.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Form(
@ -42,6 +49,7 @@ class _LoginVState extends State<LoginV> {
child: MyTextField(
controller: nameController,
hintText: '请输入账号',
focusNode: _nameFocusNode,
obscureText: false,
keyboardType: TextInputType.emailAddress,
prefixIcon: Image.asset("assets/img/login_user.png"))),
@ -52,6 +60,7 @@ class _LoginVState extends State<LoginV> {
child: MyTextField(
controller: passwordController,
hintText: '请输入密码',
focusNode: _passwordFocusNode,
obscureText: obscurePassword,
keyboardType: TextInputType.visiblePassword,
prefixIcon: Image.asset("assets/img/login_lock.png"),
@ -81,24 +90,81 @@ class _LoginVState extends State<LoginV> {
child: TextButton(
onPressed: () async {
try {
_nameFocusNode.unfocus();
_passwordFocusNode.unfocus();
Get.dialog(
Center(
child: CircularProgressIndicator(
color: const Color(0xff429482),
backgroundColor: Colors.grey[200],
),
),
barrierDismissible: false, //
);
LoginBean bean = await LoginApiClient().login(
email: nameController.text,
password: passwordController.text,
);
if (bean.code == 200) {
Get.to(() => const MainTabView());
_showDialog(context,
title: 'assets/img/correct.png',
message: '登录成功!');
Get.back();
Get.off(() => const MainTabView());
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: const Center(
child: Text(
'登录成功',
style: TextStyle(
color: Colors.black,
fontSize: 16.0, //
),
),
),
duration: const Duration(seconds: 3),
behavior: SnackBarBehavior.floating,
backgroundColor: Colors.white,
elevation: 3,
width: 200,
//
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
),
),
);
GetInfoBean bean1 = await GetInfoApiClient()
.getInfo(
Authorization: AppData().currentToken);
} else {
throw Exception("账号或密码错误");
}
} catch (error) {
String errorMessage = error.toString();
_showDialog(context,
title: 'assets/img/warning.png',
message: errorMessage);
Get.back();
print(error.toString());
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Center(
child: Text(
error.toString().replaceAll ('Exception: ', ''),
style: const TextStyle(
color: Colors.black,
fontSize: 16.0, //
),
),
),
duration: const Duration(seconds: 3),
behavior: SnackBarBehavior.floating,
backgroundColor: Colors.white,
elevation: 3,
margin: EdgeInsets.only(
bottom: 50, // 50
right: (MediaQuery.of(context).size.width - 200) / 2, //
left: (MediaQuery.of(context).size.width - 200) / 2,
),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
),
),
);
}
},
style: TextButton.styleFrom(

@ -1,5 +1,7 @@
// ignore_for_file: use_build_context_synchronously
import 'dart:async';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
@ -28,6 +30,44 @@ class _SignUpViewState extends State<SignUpView> {
bool obscurePassword = true;
bool signUpRequired = false;
final _nameFocusNode = FocusNode();
final _passwordFocusNode = FocusNode();
final _emailFocusNode = FocusNode();
final _confirmPSWFocusNode = FocusNode();
final _confirmFocusNode = FocusNode();
//
Timer? _timer;
int _countDown = 60;
bool _canSendCode = true;
@override
void dispose() {
_timer?.cancel(); //
super.dispose();
}
//
void startTimer() {
setState(() {
_canSendCode = false;
_countDown = 60;
});
_timer = Timer.periodic(const Duration(seconds: 1), (timer) {
if (_countDown == 0) {
setState(() {
_canSendCode = true;
timer.cancel();
});
} else {
setState(() {
_countDown--;
});
}
});
}
@override
Widget build(BuildContext context) {
return Form(
@ -41,6 +81,7 @@ class _SignUpViewState extends State<SignUpView> {
child: MyTextField(
controller: nameController,
hintText: '请输入用户名',
focusNode: _nameFocusNode,
obscureText: false,
keyboardType: TextInputType.emailAddress,
prefixIcon: Image.asset("assets/img/login_user.png"),
@ -60,6 +101,7 @@ class _SignUpViewState extends State<SignUpView> {
controller: emailController,
hintText: '请输入邮箱名',
obscureText: false,
focusNode: _emailFocusNode,
keyboardType: TextInputType.name,
prefixIcon: Image.asset("assets/img/setup_email.png"),
validator: (val) {
@ -76,6 +118,7 @@ class _SignUpViewState extends State<SignUpView> {
controller: passwordController,
hintText: '请输入密码',
obscureText: obscurePassword,
focusNode: _passwordFocusNode,
keyboardType: TextInputType.visiblePassword,
prefixIcon: Image.asset("assets/img/login_lock.png"),
suffixIcon: IconButton(
@ -110,6 +153,7 @@ class _SignUpViewState extends State<SignUpView> {
controller: confirmPSWController,
hintText: '请确认密码',
obscureText: obscurePassword,
focusNode: _confirmPSWFocusNode,
keyboardType: TextInputType.visiblePassword,
prefixIcon: Image.asset("assets/img/login_lock.png"),
suffixIcon: IconButton(
@ -150,6 +194,7 @@ class _SignUpViewState extends State<SignUpView> {
controller: confirmController,
hintText: '请输入验证码',
obscureText: false,
focusNode: _confirmFocusNode,
keyboardType: TextInputType.name,
prefixIcon: Image.asset("assets/img/setup_confirm.png"),
validator: (val) {
@ -160,27 +205,88 @@ class _SignUpViewState extends State<SignUpView> {
}),
),
SizedBox(
width: MediaQuery.of(context).size.width * 0.3,
width: MediaQuery.of(context).size.width * 0.313,
height: MediaQuery.of(context).size.width * 0.13,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: MColor.LGreen),
onPressed: () async {
UniversalBean bean =
await SetupApiClient().verification(
backgroundColor: _canSendCode ? MColor.LGreen : Colors.grey[300],
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8.0),
),
),
onPressed: _canSendCode
? () async {
_nameFocusNode.unfocus();
_emailFocusNode.unfocus();
_passwordFocusNode.unfocus();
_confirmPSWFocusNode.unfocus();
_confirmFocusNode.unfocus();
UniversalBean bean = await SetupApiClient().verification(
email: emailController.text,
);
_showSuccessDialog(context,
title: bean.code == 200
? 'assets/img/correct.png'
: 'assets/img/warning.png',
errorMessage:
bean.code == 200 ? '验证码已成功发送!' : '邮箱格式不正确!');
},
child: const Text(
"获取验证码",
style: TextStyle(color: Colors.black45, fontSize: 16),
)),
if (bean.code == 200) {
startTimer(); //
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: const Center(
child: Text(
'验证码发送成功',
style: TextStyle(color: Colors.black),
),
),
duration: const Duration(seconds: 2),
behavior: SnackBarBehavior.floating,
backgroundColor: Colors.white,
elevation: 3,
margin: EdgeInsets.only(
bottom: 50, // 50
right: (MediaQuery.of(context).size.width - 200) / 2, //
left: (MediaQuery.of(context).size.width - 200) / 2,
),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
),
),
);
} else {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: const Center(
child: Text(
'请检查邮箱',
style: TextStyle(
color: Colors.black,
fontSize: 16.0, //
),
),
),
duration: const Duration(seconds: 2),
behavior: SnackBarBehavior.floating,
backgroundColor: Colors.white,
elevation: 3,
// width: 220,
margin: EdgeInsets.only(
bottom: 50, // 50
right: (MediaQuery.of(context).size.width - 200) / 2, //
left: (MediaQuery.of(context).size.width - 200) / 2,
),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
),
),
);
}
}
: null,
child: Text(
_canSendCode ? "获取验证码" : "${_countDown}s后重试",
style: TextStyle(
color: _canSendCode ? Colors.black45 : Colors.grey,
fontSize: 16,
),
),
),
),
],
),
@ -189,6 +295,11 @@ class _SignUpViewState extends State<SignUpView> {
width: MediaQuery.of(context).size.width * 0.85,
child: TextButton(
onPressed: () async {
_nameFocusNode.unfocus();
_emailFocusNode.unfocus();
_passwordFocusNode.unfocus();
_confirmPSWFocusNode.unfocus();
_confirmFocusNode.unfocus();
if (_formKey.currentState?.validate() == false) {
const Text(
'',
@ -198,6 +309,11 @@ class _SignUpViewState extends State<SignUpView> {
),
);
}
if (nameController.text.isNotEmpty &&
emailController.text.isNotEmpty &&
passwordController.text.isNotEmpty &&
confirmPSWController.text.isNotEmpty &&
confirmController.text.isNotEmpty) {
UniversalBean bean = await SetupApiClient().register(
email: emailController.text,
password: passwordController.text,
@ -208,8 +324,11 @@ class _SignUpViewState extends State<SignUpView> {
? 'assets/img/correct.png'
: 'assets/img/warning.png',
errorMessage:
bean.code == 200 ? '注册成功,一键登录' : '登录失败,验证码错误');
bean.code == 200
? '注册成功,一键登录'
: '注册失败,验证码错误');
if (bean.code == 200) Get.to(const MainTabView());
}
},
style: TextButton.styleFrom(
elevation: 3.0,

@ -1,329 +0,0 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:music_player_miao/api/api_music_return.dart';
import 'package:music_player_miao/common_widget/app_data.dart';
import 'package:music_player_miao/models/getComment_bean.dart';
import 'package:music_player_miao/models/universal_bean.dart';
import 'package:music_player_miao/widget/text_field.dart';
class CommentView extends StatefulWidget {
@override
_CommentViewState createState() => _CommentViewState();
CommentView({super.key, required this.initialSongIndex});
late final int initialSongIndex;
}
class _CommentViewState extends State<CommentView> {
List comments = [];
TextEditingController commentController = TextEditingController();
FocusNode commentFocusNode = FocusNode();
List commentTimes = [];
List commentHeader = [];
List commentName = [];
bool ascendingOrder = true;
int playlistCount = 0;
@override
void initState() {
super.initState();
_fetchSonglistData();
}
Future<void> _fetchSonglistData() async {
try {
GetCommentBean bean1 = await getCommentApi().getComment(
musicId: '1',
pageNo: '0',
pageSize: '10',
Authorization: AppData().currentToken,
);
// rows
if (bean1.rows == null) {
print('No comments found');
return;
}
setState(() {
comments = bean1.rows!.map((rows) => rows.content ?? 'No content').toList();
commentTimes = bean1.rows!.map((rows) => rows.time ?? 'Unknown time').toList();
commentHeader = bean1.rows!.map((rows) => rows.avatar ?? 'Default avatar').toList();
commentName = bean1.rows!.map((rows) => rows.username ?? 'Anonymous').toList();
playlistCount = comments.length;
});
} catch (error) {
print('Error fetching songlist data: $error');
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
// backgroundColor: Colors.transparent,
appBar: AppBar(
centerTitle: true,
backgroundColor: const Color(0xffF6FFD1),
title: const Text(
'评论(200)',
style: TextStyle(
color: Colors.black,
fontSize: 22
),
),
elevation: 0,
leading: IconButton(
onPressed: () {
Get.back();
},
icon: Image.asset(
"assets/img/back.png",
width: 25,
height: 25,
fit: BoxFit.contain,
),
),
),
body: Column(
children: [
Container(
height: 80,
padding: const EdgeInsets.only(left: 20, right: 10),
decoration: BoxDecoration(
color: const Color(0xffF9F2AF),
borderRadius: BorderRadius.circular(20)
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
ClipRRect(
borderRadius: BorderRadius.circular(10),
child: Image.asset(
"assets/img/artist_pic.png",
width: 60,
height: 60,
fit: BoxFit.cover,
),
),
const SizedBox(width: 20,),
const Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
"背对背拥抱",
maxLines: 1,
style: TextStyle(
color: Colors.black,
fontSize: 16,
fontWeight: FontWeight.w400),
),
Text(
"林俊杰",
maxLines: 1,
style: TextStyle(color: Colors.black, fontSize: 14),
)
],
),
],
),
IconButton(
onPressed: () {},
icon: Image.asset(
"assets/img/music_pause.png",
width: 25,
height: 25,
fit: BoxFit.contain,
),
),
],
),
),
Padding(
padding: const EdgeInsets.all(10.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Text(
"评论区",
style: TextStyle(
fontSize: 18
),
),
Row(
children: [
const Text(
"时间",
style: TextStyle(
fontSize: 16
),
),
IconButton(
onPressed: () {
setState(() {
ascendingOrder = !ascendingOrder;
// 使
List<int> sortedIndexes = List<int>.generate(comments.length, (i) => i);
sortedIndexes.sort((a, b) {
DateTime timeA = DateTime.parse(commentTimes[a]);
DateTime timeB = DateTime.parse(commentTimes[b]);
return ascendingOrder ? timeA.compareTo(timeB) : timeB.compareTo(timeA);
});
comments = [for (var i in sortedIndexes) comments[i]];
commentTimes = [for (var i in sortedIndexes) commentTimes[i]];
commentHeader = [for (var i in sortedIndexes) commentHeader[i]];
commentName = [for (var i in sortedIndexes) commentName[i]];
});
},
icon: Image.asset(
ascendingOrder
? "assets/img/commend_up.png"
: "assets/img/commend_down.png",
fit: BoxFit.contain,
),
),
],
)
],
),
),
///
Expanded(
child:
ListView.builder(
itemCount: comments.length,
itemBuilder: (context, index) {
return ListTile(
title: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
CircleAvatar(
backgroundImage: NetworkImage(commentHeader[index])
),
const SizedBox(width: 10,),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(commentName[index],
style: const TextStyle(fontSize: 18)),
const SizedBox(width: 8),
// Adjust the spacing between elements
Text(commentTimes[index],
style: const TextStyle(fontSize: 14),),
// Add the timestamp
],
),
],
), // Ad
Padding(
padding: const EdgeInsets.only(
left: 50, top: 10, bottom: 20),
child: Text(
comments[index],
style: const TextStyle(
fontSize: 18), // Customize the font size if needed
),
),
Container(
width: 560,
height: 2,
color: const Color(0xffE3F0ED),
)
],
),
);
},
),
),
///
Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
children: [
Expanded(
child: TextFieldColor(
controller: commentController,
hintText: '来发表你的评论吧!',
)
),
const SizedBox(width: 8.0),
ElevatedButton(
onPressed: () async {
submitComment();
UniversalBean bean = await commentMusic().comment(
musicId: widget.initialSongIndex,
content: commentController.text,
Authorization: AppData().currentToken);
},
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xff429482),
// Change Colors.blue to your desired background color
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(
10), // Adjust the radius as needed
),
minimumSize: const Size(30, 44),
),
child: const Text(
'提交',
style: TextStyle(
fontSize: 16
),
),
),
],
),
),
],
),
);
}
void submitComment() async {
String comment = commentController.text.trim();
if (comment.isEmpty) {
print('Comment cannot be empty');
Get.snackbar('错误', '评论不能为空');
return;
}
print('Submitting comment with content: $comment');
try {
UniversalBean bean = await commentMusic().comment(
musicId: widget.initialSongIndex,
content: comment,
Authorization: AppData().currentToken,
);
//
if (bean.code == 200) {
print('Comment submitted successfully');
commentController.clear();
_fetchSonglistData(); //
} else {
print('Failed to submit comment: ${bean.msg}');
Get.snackbar('错误', bean.msg ?? '评论提交失败');
}
} catch (error) {
print('Error submitting comment: $error');
}
}
}

@ -0,0 +1,436 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:music_player_miao/api/api_music_return.dart';
import 'package:music_player_miao/common_widget/app_data.dart';
import 'package:music_player_miao/models/getComment_bean.dart';
import 'package:music_player_miao/models/universal_bean.dart';
import 'package:music_player_miao/widget/text_field.dart';
class CommentView extends StatefulWidget {
final int id;
final String song;
final String singer;
final String cover;
const CommentView({
super.key,
required this.id,
required this.song,
required this.singer,
required this.cover,
});
@override
_CommentViewState createState() => _CommentViewState();
}
class _CommentViewState extends State<CommentView> {
List comments = [];
ScrollController _scrollController = ScrollController();
TextEditingController commentController = TextEditingController();
FocusNode commentFocusNode = FocusNode();
List commentTimes = [];
List commentHeader = [];
List commentName = [];
bool ascendingOrder = true;
int _page = 1;
int _pageSize = 10;
int _total = 0;
bool _isLoading = false;
bool _hasMoreData = true;
bool _isSendingComment = false;
String avatar = AppData().currentAvatar;
String username = AppData().currentUsername;
bool _isInitialLoading = true;
@override
void initState() {
super.initState();
_scrollController.addListener(_scrollListener);
_fetchCommentData();
commentController.addListener(() {
setState(() {});
});
}
@override
void dispose() {
_scrollController.dispose();
commentController.dispose();
super.dispose();
}
void _scrollListener() {
if (_scrollController.position.pixels ==
_scrollController.position.maxScrollExtent) {
if (!_isLoading && _hasMoreData) {
_loadMoreData();
}
}
}
Future<void> _loadMoreData() async {
if (_isLoading || !_hasMoreData) return;
setState(() {
_isLoading = true;
});
_page++;
await _fetchCommentData();
setState(() {
_isLoading = false;
});
}
String formatDateTime(String dateTimeStr) {
try {
DateTime dateTime = DateTime.parse(dateTimeStr);
//
return "${dateTime.year}-${dateTime.month.toString().padLeft(2, '0')}-${dateTime.day.toString().padLeft(2, '0')} ${dateTime.hour.toString().padLeft(2, '0')}:${dateTime.minute.toString().padLeft(2, '0')}";
} catch (e) {
return dateTimeStr; //
}
}
Future<void> _fetchCommentData() async {
print('Fetching page $_page');
try {
GetCommentBean bean1 = await getCommentApi().getComment(
musicId: widget.id,
pageNo: _page,
pageSize: _pageSize,
Authorization: AppData().currentToken,
);
if (bean1.rows == null || bean1.rows!.isEmpty) {
setState(() {
_hasMoreData = false;
_isInitialLoading = false;
});
return;
}
_total = bean1.total!;
setState(() {
if (_page == 1) {
comments =
bean1.rows!.map((rows) => rows.content ?? 'No content').toList();
commentTimes = bean1.rows!
.map((rows) => formatDateTime(rows.time ?? 'Unknown time'))
.toList();
commentHeader = bean1.rows!
.map((rows) => rows.avatar ?? 'Default avatar')
.toList();
commentName =
bean1.rows!.map((rows) => rows.username ?? 'Anonymous').toList();
} else {
comments.addAll(
bean1.rows!.map((rows) => rows.content ?? 'No content').toList());
commentTimes.addAll(bean1.rows!
.map((rows) => formatDateTime(rows.time ?? 'Unknown time'))
.toList());
commentHeader.addAll(bean1.rows!
.map((rows) => rows.avatar ?? 'Default avatar')
.toList());
commentName.addAll(
bean1.rows!.map((rows) => rows.username ?? 'Anonymous').toList());
}
_hasMoreData = comments.length < _total;
_isInitialLoading = false;
});
} catch (error) {
print('Error fetching comment data: $error');
setState(() {
_isLoading = false;
_isInitialLoading = false;
});
}
}
void _sortComments() {
setState(() {
comments = comments.reversed.toList();
commentTimes = commentTimes.reversed.toList();
commentHeader = commentHeader.reversed.toList();
commentName = commentName.reversed.toList();
});
}
//
bool isCommentValid() {
String comment = commentController.text.trim();
return comment.isNotEmpty;
}
void submitComment() async {
String comment = commentController.text.trim();
if (!isCommentValid()) {
return; //
}
setState(() {
_isSendingComment = true;
});
try {
UniversalBean bean = await commentMusic().comment(
musicId: widget.id,
content: comment,
Authorization: AppData().currentToken,
);
if (bean.code == 200) {
commentController.clear();
setState(() {
comments = [comment, ...comments];
commentTimes = [
formatDateTime(DateTime.now().toString()),
...commentTimes
];
commentHeader = [avatar, ...commentHeader];
commentName = [username, ...commentName];
_total++;
});
}
} catch (error) {
print('Error submitting comment: $error');
} finally {
setState(() {
_isSendingComment = false;
});
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
centerTitle: true,
backgroundColor: const Color(0xffF6FFD1),
title: Text(
'评论($_total)',
style: TextStyle(color: Colors.black, fontSize: 22),
),
elevation: 0,
leading: IconButton(
onPressed: () {
Get.back();
},
icon: Image.asset(
"assets/img/back.png",
width: 25,
height: 25,
fit: BoxFit.contain,
),
),
),
body: Column(
children: [
// ... ...
Container(
height: 80,
padding: const EdgeInsets.only(left: 20, right: 10),
decoration: BoxDecoration(
color: const Color(0xffF9F2AF),
borderRadius: BorderRadius.circular(20)),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
ClipRRect(
borderRadius: BorderRadius.circular(10),
child: Image.network(
widget.cover,
width: 60,
height: 60,
fit: BoxFit.cover,
),
),
const SizedBox(width: 20),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
widget.song,
maxLines: 1,
style: const TextStyle(
color: Colors.black,
fontSize: 16,
fontWeight: FontWeight.w400),
),
Text(
widget.singer,
maxLines: 1,
style: const TextStyle(
color: Colors.black, fontSize: 14),
)
],
),
],
),
],
),
),
//
Padding(
padding: const EdgeInsets.all(10.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Text(
"评论区",
style: TextStyle(fontSize: 18),
),
Row(
children: [
const Text(
"时间",
style: TextStyle(fontSize: 16),
),
IconButton(
onPressed: () {
setState(() {
ascendingOrder = !ascendingOrder;
_sortComments();
});
},
icon: Image.asset(
ascendingOrder
? "assets/img/commend_up.png"
: "assets/img/commend_down.png",
fit: BoxFit.contain,
),
),
],
)
],
),
),
//
Expanded(
child: _isInitialLoading
? const Center(
child: CircularProgressIndicator(
color: Color(0xff429482),
),
)
: ListView.builder(
controller: _scrollController,
itemCount: comments.length + 1, // +1
itemBuilder: (context, index) {
if (index == comments.length) {
// "没有更多数据"
return Container(
padding: const EdgeInsets.all(16.0),
alignment: Alignment.center,
child: _isLoading
? const CircularProgressIndicator(
color: Color(0xff429482),
)
: _hasMoreData
? const Text('上拉加载更多')
: const Text('没有更多评论了'),
);
}
return ListTile(
title: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
CircleAvatar(
backgroundImage:
NetworkImage(commentHeader[index])),
const SizedBox(width: 10),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(commentName[index],
style: const TextStyle(fontSize: 18)),
Text(
commentTimes[index],
style: const TextStyle(fontSize: 14),
),
],
),
],
),
Padding(
padding: const EdgeInsets.only(
left: 50, top: 10, bottom: 20),
child: Text(
comments[index],
style: const TextStyle(fontSize: 18),
),
),
Container(
width: 560,
height: 2,
color: const Color(0xffE3F0ED),
)
],
),
);
},
),
),
//
Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
children: [
Expanded(
child: TextFieldColor(
controller: commentController,
hintText: '来发表你的评论吧!',
enabled: !_isSendingComment,
),
),
const SizedBox(width: 8.0),
ElevatedButton(
onPressed: isCommentValid() && !_isSendingComment
? submitComment
: null,
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xff429482),
foregroundColor: Colors.black45,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
),
minimumSize: const Size(30, 44),
disabledBackgroundColor: Colors.grey,
),
child: _isSendingComment
? const SizedBox(
width: 20,
height: 20,
child: CircularProgressIndicator(
color: Colors.white,
strokeWidth: 2,
),
)
: const Text(
'发送',
style: TextStyle(fontSize: 16),
),
),
],
),
),
],
),
);
}
}

@ -4,9 +4,10 @@ import 'package:get/get.dart';
import 'package:music_player_miao/api/api_music_return.dart';
import 'package:music_player_miao/common_widget/app_data.dart';
import 'package:music_player_miao/models/search_bean.dart';
import 'package:music_player_miao/view/commend_view.dart';
import 'package:music_player_miao/view/comment_view.dart';
import '../../view_model/home_view_model.dart';
import '../api/api_music_list.dart';
import '../common/download_manager.dart';
import '../common_widget/Song_widegt.dart';
import '../common_widget/list_cell.dart';
import '../models/getMusicList_bean.dart';
@ -19,18 +20,35 @@ class HomeView extends StatefulWidget {
State<HomeView> createState() => _HomeViewState();
}
class _HomeViewState extends State<HomeView> {
class _HomeViewState extends State<HomeView>
with AutomaticKeepAliveClientMixin {
final homeVM = Get.put(HomeViewModel());
final TextEditingController _controller = TextEditingController();
bool _isSearching = false;
final downloadManager = Get.put(DownloadManager());
List<Song> selectedSongs = [];
@override
bool get wantKeepAlive => true;
@override
void initState() {
super.initState();
_fetchSonglistData();
}
List<Song> songs = [];
Future<void> _onRefresh() async {
try {
//
await _fetchSonglistData();
} catch (e) {
print('Refresh error: $e');
//
}
}
Future<void> _fetchSonglistData() async {
try {
MusicListBean bean1 =
await GetMusic().getMusic1(Authorization: AppData().currentToken);
MusicListBean bean2 =
@ -39,7 +57,7 @@ class _HomeViewState extends State<HomeView> {
await GetMusic().getMusic3(Authorization: AppData().currentToken);
setState(() {
songs = [
selectedSongs = [
Song(
artistPic: bean1.coverPath!,
title: bean1.name!,
@ -69,8 +87,10 @@ class _HomeViewState extends State<HomeView> {
collection: bean3.collectOrNot!),
];
});
} catch (e) {
print('Error occurred while fetching song list: $e');
}
}
///
List<Map> imgList = [
@ -79,23 +99,96 @@ class _HomeViewState extends State<HomeView> {
{"image": "assets/img/banner.png"},
];
List<String> _filteredData = [];
List<Song> _filteredData = [];
Future<void> _filterData(String query) async {
if (query.isNotEmpty) {
SearchBean bean = await SearchMusic().search(keyword: query);
if (bean.code == 200) {
try {
//
SearchBean bean = await SearchMusic().search(
keyword: query,
Authorization: AppData().currentToken,
);
//
if (bean.code == 200 && bean.data != null) {
//
List<Future<Song?>> songDetailsFutures = [];
// id
for (var data in bean.data!) {
if (data.id != null) {
// id null
// 使 id Future
songDetailsFutures.add(GetMusicDetail()
.getMusicDetail(
songId: data.id!,
Authorization: AppData().currentToken,
)
.then((details) {
if (details != null) {
// Song
return Song(
artistPic: details.artistPic ?? '',
//
title: data.name ?? '',
//
artist: details.artist ?? '',
//
musicurl: details.musicurl ?? '',
//
pic: details.pic ?? '',
//
id: details.id,
// ID
likes: details.likes,
//
collection: details.collection, //
);
}
return null; // null
}).catchError((error) {
print("Error occurred while fetching song details: $error");
return null; // null
}));
} else {
print("Song ID is null for song: ${data.name}");
}
}
// 使 Future.wait
List<Song?> songDetailsList = await Future.wait(songDetailsFutures);
// null
List<Song> validSongDetails = songDetailsList
.where((song) => song != null)
.cast<Song>()
.toList();
// UI _filteredData
setState(() {
_filteredData = validSongDetails; //
_isSearching = true; //
});
//
print("Filtered Data: $_filteredData");
} else {
setState(() {
_filteredData = bean.data
?.map((data) =>
"${data.name} ") // Adjust this based on your data structure
.toList() ??
[];
_isSearching = true;
_filteredData = [];
_isSearching = false;
});
}
} catch (error) {
print("Error occurred during search: $error");
setState(() {
_filteredData = [];
_isSearching = false;
});
}
} else {
setState(() {
_filteredData = [];
_isSearching = false;
});
}
@ -103,6 +196,8 @@ class _HomeViewState extends State<HomeView> {
@override
Widget build(BuildContext context) {
super.build(context);
///
var MySwiperWidget = Swiper(
itemBuilder: (BuildContext context, int index) {
@ -133,9 +228,7 @@ class _HomeViewState extends State<HomeView> {
child: Scaffold(
resizeToAvoidBottomInset: false,
backgroundColor: Colors.transparent,
body: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
body: Column(
children: [
///
Container(
@ -145,24 +238,21 @@ class _HomeViewState extends State<HomeView> {
children: [
Text(
'喵听',
style:
TextStyle(fontSize: 35, fontWeight: FontWeight.bold),
),
SizedBox(
width: 10,
style: TextStyle(fontSize: 35, fontWeight: FontWeight.bold),
),
SizedBox(width: 10),
Text(
'你的云端音乐库',
style:
TextStyle(fontSize: 20, fontWeight: FontWeight.w500),
style: TextStyle(fontSize: 20, fontWeight: FontWeight.w500),
),
],
),
),
const SizedBox(height: 10),
///
Container(
padding: const EdgeInsets.only(left: 20, right: 20, top: 10),
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 10),
child: Column(
children: [
Container(
@ -224,7 +314,23 @@ class _HomeViewState extends State<HomeView> {
itemCount: _filteredData.length,
itemBuilder: (context, index) {
return ListTile(
title: Text(_filteredData[index]),
title: Text(_filteredData[index].title),
onTap: () {
//
Navigator.push(
// 使 Navigator
context,
MaterialPageRoute(
// MusicView
builder: (context) => MusicView(
songList: _filteredData,
//
initialSongIndex:
index, //
),
),
);
},
);
},
),
@ -233,45 +339,81 @@ class _HomeViewState extends State<HomeView> {
),
),
const SizedBox(
height: 10,
),
///+
Expanded(
child: RefreshIndicator(
onRefresh: _onRefresh,
color: const Color(0xff429482),
backgroundColor: Colors.white,
child: SingleChildScrollView(
physics: const AlwaysScrollableScrollPhysics(),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
///+
Container(
padding: const EdgeInsets.only(left: 20, right: 20, top: 10),
padding:
const EdgeInsets.only(left: 20, right: 20, top: 10),
child: const Text(
'每日推荐',
style: TextStyle(fontSize: 22, fontWeight: FontWeight.w500),
style: TextStyle(
fontSize: 20, fontWeight: FontWeight.w500),
),
),
const SizedBox(height: 5),
Container(
padding: const EdgeInsets.only(left: 20, right: 20, top: 5),
padding: const EdgeInsets.symmetric(
horizontal: 20, vertical: 5),
height: 186,
width: double.infinity,
child: MySwiperWidget,
),
const SizedBox(height: 10),
///
Container(
alignment: Alignment.topLeft,
padding: const EdgeInsets.only(left: 20, right: 20, top: 5),
padding:
const EdgeInsets.only(left: 20, right: 20, top: 5),
child: const Text(
'精选歌曲',
style: TextStyle(fontSize: 22, fontWeight: FontWeight.w500),
style: TextStyle(
fontSize: 20, fontWeight: FontWeight.w500),
),
),
const SizedBox(
height: 5,
),
ListView.builder(
padding: EdgeInsets.zero,
itemCount: songs.length,
itemCount: selectedSongs.length,
physics: const NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemBuilder: (context, index) {
return ListTile(
leading: Image.network(songs[index].pic),
leading: ClipRRect(
borderRadius: BorderRadius.circular(10),
child: Image.network(
selectedSongs[index].pic,
width: 60,
height: 60,
fit: BoxFit.cover,
),
),
title: Text(
songs[index].title,
style: const TextStyle(fontSize: 18, color: Colors.black),
selectedSongs[index].title,
style: const TextStyle(
fontSize: 18, color: Colors.black),
),
subtitle: Text(
songs[index].artist,
style: const TextStyle(fontSize: 16, color: Colors.black),
selectedSongs[index].artist,
style: const TextStyle(
fontSize: 16, color: Colors.black),
),
trailing: InkWell(
onTap: () {
@ -284,8 +426,20 @@ class _HomeViewState extends State<HomeView> {
context,
MaterialPageRoute(
builder: (context) => MusicView(
song: songs[index],
songList: selectedSongs,
initialSongIndex: index,
onSongStatusChanged:
(index, isCollected, isLiked) {
setState(() {
selectedSongs[index].collection =
isCollected;
selectedSongs[index].likes = isLiked;
downloadManager.updateSongInfo(
selectedSongs[index].id,
isCollected,
isLiked);
});
},
),
),
);
@ -294,13 +448,22 @@ class _HomeViewState extends State<HomeView> {
},
),
const SizedBox(
height: 10,
),
///
Container(
padding: const EdgeInsets.only(left: 20, right: 20, top: 5),
padding:
const EdgeInsets.only(left: 20, right: 20, top: 5),
child: const Text(
'精选歌单',
style: TextStyle(fontSize: 22, fontWeight: FontWeight.w500),
style: TextStyle(
fontSize: 20, fontWeight: FontWeight.w500),
),
),
const SizedBox(
height: 5,
),
SizedBox(
height: 180,
@ -322,6 +485,10 @@ class _HomeViewState extends State<HomeView> {
),
),
),
),
],
),
),
);
}
@ -330,9 +497,15 @@ class _HomeViewState extends State<HomeView> {
context: context,
backgroundColor: Colors.white,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(top: Radius.circular(30))),
builder: (context) => Container(
height: 210,
borderRadius: BorderRadius.vertical(top: Radius.circular(30)),
),
builder: (context) => StatefulBuilder(
// 使StatefulBuilder便
builder: (context, setState) {
bool likesnot = false; //
return Container(
height: 150,
padding: const EdgeInsets.only(top: 20),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
@ -347,7 +520,7 @@ class _HomeViewState extends State<HomeView> {
icon: Image.asset("assets/img/list_add.png"),
iconSize: 60,
),
const Text("加入歌单")
const Text("加入歌单"),
],
),
Column(
@ -357,7 +530,7 @@ class _HomeViewState extends State<HomeView> {
icon: Image.asset("assets/img/list_download.png"),
iconSize: 60,
),
const Text("下载")
const Text("下载"),
],
),
Column(
@ -367,7 +540,7 @@ class _HomeViewState extends State<HomeView> {
icon: Image.asset("assets/img/list_collection.png"),
iconSize: 60,
),
const Text("收藏")
const Text("收藏"),
],
),
Column(
@ -384,53 +557,27 @@ class _HomeViewState extends State<HomeView> {
children: [
IconButton(
onPressed: () {
Get.to(() => CommentView(
initialSongIndex: index,
));
Navigator.pop(context);
// Get.to(() =>
// CommentView(
// id:,
// song:,
// singer:,
// ));
},
icon: Image.asset("assets/img/list_comment.png"),
iconSize: 60,
),
const Text("评论")
const Text("评论"),
],
),
],
),
const SizedBox(
height: 10,
),
ElevatedButton(
onPressed: () {},
child: const Text(
"查看详情页",
style: TextStyle(color: Colors.black, fontSize: 18),
),
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xffE6F4F1),
padding: const EdgeInsets.symmetric(vertical: 8),
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.zero,
),
),
),
ElevatedButton(
onPressed: () => Navigator.pop(context),
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xff429482),
padding: const EdgeInsets.symmetric(vertical: 8),
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.zero,
),
),
child: const Text(
"取消",
style: TextStyle(color: Colors.black, fontSize: 18),
),
),
],
),
));
);
},
),
);
}
}

@ -5,6 +5,100 @@ import 'package:music_player_miao/view/user/user_view.dart';
import '../home_view.dart';
import '../release_view.dart';
//
class MiniPlayer extends StatelessWidget {
const MiniPlayer({super.key});
@override
Widget build(BuildContext context) {
return Container(
height: 50, //
decoration: BoxDecoration(
color: Colors.white,
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.1),
blurRadius: 4,
offset: const Offset(0, -1),
),
],
),
child: Row(
children: [
//
Container(
width: 50,
height: 50,
color: Colors.grey[200],
child: Image.asset(
'assets/img/artist_pic.png',
fit: BoxFit.cover,
),
),
//
Expanded(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 12),
child: Row(
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'背对背拥抱',
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w500,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
const SizedBox(height: 2),
Text(
'林俊杰',
style: TextStyle(
fontSize: 12,
color: Colors.grey[600],
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
],
),
),
//
Row(
mainAxisSize: MainAxisSize.min,
children: [
IconButton(
icon: const Icon(Icons.play_arrow),
onPressed: () {},
padding: EdgeInsets.zero,
constraints: const BoxConstraints(),
iconSize: 24,
),
const SizedBox(width: 16),
IconButton(
icon: const Icon(Icons.playlist_play),
onPressed: () {},
padding: EdgeInsets.zero,
constraints: const BoxConstraints(),
iconSize: 24,
),
const SizedBox(width: 8),
],
),
],
),
),
),
],
),
);
}
}
class MainTabView extends StatefulWidget {
const MainTabView({super.key});
@ -19,30 +113,33 @@ class _MainTabViewState extends State<MainTabView> with SingleTickerProviderStat
@override
void initState() {
// TODO: implement initState
super.initState();
controller = TabController(length: 4, vsync: this);
controller?.addListener(() {
selectTab = controller?.index ?? 0;
setState(() {
});
setState(() {});
});
}
@override
void dispose() {
// TODO: implement dispose
super.dispose();
controller?.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
resizeToAvoidBottomInset: false,
key: scaffoldKey,
body: TabBarView(
body: Stack(
children: [
// TabBarView
Column(
children: [
Expanded(
child: TabBarView(
controller: controller,
children: const [
HomeView(),
@ -51,55 +148,72 @@ class _MainTabViewState extends State<MainTabView> with SingleTickerProviderStat
UserView()
],
),
bottomNavigationBar: BottomAppBar(
),
],
),
//
Positioned(
left: 0,
right: 0,
bottom: 0,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
const MiniPlayer(),
Container(
color: Colors.white,
elevation: 0,
child: TabBar(
controller: controller,
indicatorColor: Colors.transparent,
indicatorWeight: 3,
labelColor: Colors.black,
labelStyle: const TextStyle(
fontSize: 12
),
labelStyle: const TextStyle(fontSize: 12),
unselectedLabelColor: const Color(0xffCDCDCD),
unselectedLabelStyle: const TextStyle(
fontSize: 12
),
unselectedLabelStyle: const TextStyle(fontSize: 12),
tabs: [
Tab(
text:
"首页",
height: 60,
icon: Image.asset(
selectTab == 0 ? "assets/img/home_tab.png" : "assets/img/home_tab_un.png",
width: 45,height: 45,),
width: 32,
height: 32,
),
text: "首页",
),
Tab(
text:
"排行榜",
height: 60,
icon: Image.asset(
selectTab == 1 ? "assets/img/list_tab.png" : "assets/img/list_tab_un.png",
width: 45,height: 45,),
width: 32,
height: 32,
),
text: "排行榜",
),
Tab(
text:
"发布",
icon:Image.asset(selectTab == 2?"assets/img/music_tab.png":"assets/img/music_tab_un.png",
width: 45,height: 45,),
height: 60,
icon: Image.asset(
selectTab == 2 ? "assets/img/music_tab.png" : "assets/img/music_tab_un.png",
width: 32,
height: 32,
),
text: "发布",
),
Tab(
text:
"个人",
icon:Image.asset(selectTab == 3?"assets/img/user_tab.png":"assets/img/user_tab_un.png",
width: 45,height: 45,),
height: 60,
icon: Image.asset(
selectTab == 3 ? "assets/img/user_tab.png" : "assets/img/user_tab_un.png",
width: 32,
height: 32,
),
text: "我的",
),
],
),
),
],
),
),
],
),
);
}
}

@ -1,153 +1,405 @@
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:just_audio/just_audio.dart';
import 'package:music_player_miao/common_widget/app_data.dart';
import 'package:music_player_miao/models/universal_bean.dart';
import '../../view_model/home_view_model.dart';
import 'package:audioplayers/audioplayers.dart';
import '../api/api_music_likes.dart';
import '../api/api_music_list.dart';
import '../api/api_collection.dart';
import '../api/api_music_list.dart';
import '../common/download_manager.dart';
import '../common_widget/Song_widegt.dart';
import '../models/getMusicList_bean.dart';
import '../view/commend_view.dart';
import '../view/comment_view.dart';
import '../models/universal_bean.dart';
class MusicView extends StatefulWidget {
final Song song;
final List<Song> songList;
final int initialSongIndex;
const MusicView({super.key, required this.song, required this.initialSongIndex});
final Function(int index, bool isCollected, bool isLiked)? onSongStatusChanged;
const MusicView({
super.key,
required this.songList,
required this.initialSongIndex,
this.onSongStatusChanged,
});
@override
State<MusicView> createState() => _MusicViewState();
}
class _MusicViewState extends State<MusicView> {
class _MusicViewState extends State<MusicView> with SingleTickerProviderStateMixin {
final homeVM = Get.put(HomeViewModel());
bool _isDisposed = false;
AppData appData = AppData();
late int currentSongIndex;
late AudioPlayer _audioPlayer;
StreamSubscription? _playerStateSubscription;
List song2 = [];
List artist = [];
List music = [];
List likes = [];
List collection = [];
final downloadManager = Get.put(DownloadManager());
// Stream values
Duration _duration = Duration.zero;
Duration _position = Duration.zero;
// Current song info
late String artistName;
late String musicName;
late bool likesnot;
late bool collectionsnot;
// Song lists
List<int> id = [];
List<String> song2 = [];
List<String> artist = [];
List<String> music = [];
List<bool> likes = [];
List<bool> collection = [];
late AnimationController _rotationController;
bool _isLoading = false;
@override
void initState() {
super.initState();
currentSongIndex = widget.initialSongIndex;
// _initializeAsync();
_fetchSonglistData();
_updateCurrentSong();
playerInit();
_rotationController = AnimationController(
duration: const Duration(seconds: 20),
vsync: this,
);
_playerStateSubscription = _audioPlayer.playerStateStream.listen((state) {
if (!_isDisposed) {
if (state.playing) {
_rotationController.repeat();
} else {
_rotationController.stop();
}
}
});
}
@override
void dispose() {
_isDisposed = true;
_playerStateSubscription?.cancel();
_rotationController.stop();
_rotationController.dispose();
_audioPlayer.dispose();
super.dispose();
}
Future<void> _fetchSonglistData() async {
MusicListBean bean1 =
await GetMusic().getMusic1(Authorization: AppData().currentToken);
MusicListBean bean2 =
await GetMusic().getMusic2(Authorization: AppData().currentToken);
MusicListBean bean3 =
await GetMusic().getMusic3(Authorization: AppData().currentToken);
setState(() {
for (int i = 0; i < widget.songList.length; i++) {
id.add(widget.songList[i].id);
// TODO musicurl ,
if (widget.songList[i].musicurl == null) {
song2.add("");
} else {
song2.add(widget.songList[i].musicurl!);
}
artist.add(widget.songList[i].artist);
music.add(widget.songList[i].title);
//
likes.add(widget.songList[i].likes ?? false);
collection.add(widget.songList[i].collection ?? false);
}
});
}
//
Future<void> _checkAndUpdateSongStatus(int index) async {
// likescollectionnull
if (widget.songList[index].likes == null || widget.songList[index].collection == null) {
try {
MusicListBean musicListBean = await GetMusic().getMusicById(
id: id[index],
Authorization: AppData().currentToken,
);
if (!_isDisposed && musicListBean.code == 200) {
setState(() {
song2 = [bean1.musicPath,bean2.musicPath,bean3.musicPath];
artist = [bean1.singerName,bean2.singerName,bean3.singerName];
music = [bean1.name,bean2.name,bean3.name];
likes = [bean1.likeOrNot,bean2.likeOrNot,bean3.likeOrNot];
collection = [bean1.collectOrNot,bean2.collectOrNot,bean3.collectOrNot];
likes[index] = musicListBean.likeOrNot!;
collection[index] = musicListBean.collectOrNot!;
//
if (index == currentSongIndex) {
likesnot = musicListBean.likeOrNot!;
collectionsnot = musicListBean.collectOrNot!;
}
widget.onSongStatusChanged?.call(
index,
musicListBean.collectOrNot!,
musicListBean.likeOrNot!,
);
});
}
} catch (e) {
print('Error fetching song status: $e');
}
}
}
late AudioPlayer _audioPlayer;
late Duration _duration;
late Duration _position; late String artistName;
late String musicName;
late bool likesnot;
late bool collectionsnot;
Future<void> _updateCurrentSong() async {
if (_isDisposed) return;
void playerInit() {
_audioPlayer = AudioPlayer()..setSourceUrl('${widget.song.musicurl}');
_duration = const Duration();
_position = const Duration();
artistName = '${widget.song.artist}';
musicName = '${widget.song.title}';
likesnot = widget.song.likes;
collectionsnot = widget.song.collection;
_audioPlayer.onDurationChanged.listen((Duration d) {
_duration = d;
setState(() {});
setState(() {
_isLoading = true;
_position = Duration.zero;
_duration = Duration.zero;
artistName = artist[currentSongIndex];
musicName = music[currentSongIndex];
likesnot = likes[currentSongIndex];
collectionsnot = collection[currentSongIndex];
});
_audioPlayer.onPositionChanged.listen((Duration p) {
_position = p;
setState(() {});
await _checkAndUpdateSongStatus(currentSongIndex);
try {
await _audioPlayer.stop();
_rotationController.reset();
//
final localSong = downloadManager.getLocalSong(currentSongIndex);
final audioSource = localSong != null
? AudioSource.file(localSong.musicurl!)
: AudioSource.uri(Uri.parse(song2[currentSongIndex]));
//
await _audioPlayer.setAudioSource(audioSource, preload: true);
//
final duration = await _audioPlayer.duration;
if (!_isDisposed) {
setState(() {
_duration = duration ?? Duration.zero;
_isLoading = false;
});
}
_audioPlayer.onPlayerComplete.listen((event) {
//
await _audioPlayer.play();
} catch (e) {
print('Error loading audio source: $e');
if (!_isDisposed) {
setState(() {
_position = _duration;
_isLoading = false;
});
}
}
}
void playerInit() async {
_audioPlayer = AudioPlayer();
await _checkAndUpdateSongStatus(widget.initialSongIndex);
//
artistName = widget.songList[widget.initialSongIndex].artist;
musicName = widget.songList[widget.initialSongIndex].title;
likesnot = widget.songList[widget.initialSongIndex].likes!;
collectionsnot = widget.songList[widget.initialSongIndex].collection!;
//
_audioPlayer.positionStream.listen((position) {
if (!_isDisposed) {
setState(() => _position = position);
}
});
//
_audioPlayer.durationStream.listen((duration) {
if (!_isDisposed) {
setState(() => _duration = duration ?? Duration.zero);
}
});
void playOrPause() {
if (_audioPlayer.state == PlayerState.playing) {
_audioPlayer.pause();
} else {
_audioPlayer.resume();
//
_audioPlayer.playerStateStream.listen((state) {
if (_isDisposed) return;
if (state.processingState == ProcessingState.completed) {
// Stream
_handleSongCompletion();
}
});
}
//
void _handleSongCompletion() {
if (_isDisposed) return;
setState(() {
_position = Duration.zero;
_duration = Duration.zero;
});
// 使 Future.microtask
Future.microtask(() {
if (!_isDisposed) {
playNextSong();
}
});
}
// Slider
Widget _buildProgressSlider() {
// 0.1
final max = _duration.inSeconds.toDouble() == 0 ? 0.1 : _duration.inSeconds.toDouble();
//
final current = _position.inSeconds.toDouble().clamp(0, max);
return SliderTheme(
data: const SliderThemeData(
trackHeight: 3.0,
thumbShape: RoundSliderThumbShape(enabledThumbRadius: 7.0),
overlayShape: RoundSliderOverlayShape(overlayRadius: 12.0),
),
child: Slider(
min: 0,
max: max,
value: current.toDouble(),
onChanged: (value) async {
if (!_isDisposed && _duration.inSeconds > 0) {
await _audioPlayer.seek(Duration(seconds: value.toInt()));
setState(() {});
}
},
activeColor: const Color(0xff429482),
inactiveColor: const Color(0xffE3F0ED),
),
);
}
Widget _buildPlayButton() {
return SizedBox(
width: 52,
height: 52,
child: Center(
child: _isLoading
? const CircularProgressIndicator(
valueColor: AlwaysStoppedAnimation<Color>(Color(0xff429482)),
strokeWidth: 3.0,
)
: IconButton(
padding: EdgeInsets.zero, //
constraints: const BoxConstraints(
minWidth: 52,
minHeight: 52,
maxWidth: 52,
maxHeight: 52,
),
onPressed: playOrPause,
icon: _audioPlayer.playing
? Image.asset(
"assets/img/music_play.png",
width: 52,
height: 52,
)
: Image.asset(
"assets/img/music_pause.png",
width: 52,
height: 52,
),
),
),
);
}
void playOrPause() async {
if (_isDisposed) return; //
if (_audioPlayer.playing) {
await _audioPlayer.pause();
if (!_isDisposed) { //
_rotationController.stop();
}
} else {
await _audioPlayer.play();
if (!_isDisposed) { //
_rotationController.repeat();
}
}
if (!_isDisposed) {
setState(() {});
}
}
void playNextSong() {
if (currentSongIndex < 2) {
if (currentSongIndex < widget.songList.length - 1) {
currentSongIndex++;
} else {
currentSongIndex = 0;
}
_audioPlayer.setSourceUrl(song2[currentSongIndex]);
artistName = artist[currentSongIndex];
musicName = music[currentSongIndex];
likesnot = likes[currentSongIndex];
collectionsnot = collection[currentSongIndex];
_audioPlayer.resume();
_updateCurrentSong();
}
void playPreviousSong() {
if (currentSongIndex > 0) {
currentSongIndex--;
} else {
currentSongIndex = 2;
currentSongIndex = widget.songList.length - 1;
}
_audioPlayer.setSourceUrl(song2[currentSongIndex]);
artistName = artist[currentSongIndex];
musicName = music[currentSongIndex];
likesnot = likes[currentSongIndex];
collectionsnot = collection[currentSongIndex];
_audioPlayer.resume();
_updateCurrentSong();
}
String formatDuration(Duration duration) {
String twoDigits(int n) => n.toString().padLeft(2, "0");
String twoDigitMinutes = twoDigits(duration.inMinutes.remainder(60));
String twoDigitSeconds = twoDigits(duration.inSeconds.remainder(60));
return "${twoDigits(duration.inMinutes)}:$twoDigitSeconds";
return "$twoDigitMinutes:$twoDigitSeconds";
}
@override
void initState() {
playerInit();
currentSongIndex = widget.initialSongIndex;
_fetchSonglistData();
super.initState();
Future<void> _initializeAsync() async {
await _fetchSonglistData();
await _updateCurrentSong();
}
@override
void dispose() {
_isDisposed = true;
_audioPlayer.release();
_audioPlayer.dispose();
super.dispose();
void _changeCurrentSong(int index) {
if (!_isDisposed) {
setState(() {
currentSongIndex = index;
_updateCurrentSong();
});
}
}
Widget _buildRotatingAlbumCover() {
return RotationTransition(
turns: _rotationController,
child: Stack(
alignment: Alignment.center,
children: [
Positioned(
child: ClipRRect(
child: Image.network(
widget.songList[currentSongIndex].artistPic,
width: 225,
height: 225,
fit: BoxFit.cover,
),
),
),
ClipRRect(
child: Image.asset(
"assets/img/music_Ellipse.png",
width: 350,
height: 350,
fit: BoxFit.cover,
),
),
],
),
);
}
@override
@ -192,12 +444,45 @@ class _MusicViewState extends State<MusicView> {
),
),
IconButton(
onPressed: () {},
icon: Image.asset(
"assets/img/music_download.png",
onPressed: downloadManager.isDownloading(id[currentSongIndex]) ||
downloadManager.isCompleted(id[currentSongIndex])
? null
: () async {
await downloadManager.startDownload(
song: widget.songList[currentSongIndex],
context: context,
);
},
icon: Obx(() {
if (downloadManager.isDownloading(id[currentSongIndex])) {
return Stack(
alignment: Alignment.center,
children: [
SizedBox(
width: 32,
height: 32,
child: CircularProgressIndicator(
value: downloadManager.getProgress(id[currentSongIndex]),
backgroundColor: Colors.grey[200],
valueColor: const AlwaysStoppedAnimation<Color>(Color(0xff429482)),
strokeWidth: 3.0,
),
),
Text(
'${(downloadManager.getProgress(id[currentSongIndex]) * 100).toInt()}',
style: const TextStyle(fontSize: 12),
),
],
);
}
return Image.asset(
downloadManager.isCompleted(id[currentSongIndex])
? "assets/img/music_download_completed.png"
: "assets/img/music_download.png",
width: 30,
height: 30,
),
);
}),
),
],
)
@ -207,31 +492,7 @@ class _MusicViewState extends State<MusicView> {
height: 80,
),
Center(
child: Stack(
alignment: Alignment.center,
children: [
ClipRRect(
borderRadius: BorderRadius.circular(10),
child: Image.asset(
"assets/img/music_Ellipse.png",
width: 320,
height: 320,
fit: BoxFit.cover,
),
),
Positioned(
child: ClipRRect(
borderRadius: BorderRadius.circular(80),
child: Image.network(
'${widget.song.artistPic}',
width: 230,
height: 230,
fit: BoxFit.cover,
),
),
)
],
),
child: _buildRotatingAlbumCover(),
),
const SizedBox(
height: 60,
@ -258,11 +519,22 @@ class _MusicViewState extends State<MusicView> {
children: [
IconButton(
onPressed: () async{
UniversalBean bean1 =
await LikesApiMusic().likesMusic(musicId: currentSongIndex+1, Authorization: AppData().currentToken);
setState(() {
likesnot = !likesnot;
likes[currentSongIndex] = !likes[currentSongIndex];
});
UniversalBean response = await LikesApiMusic().likesMusic(musicId: id[currentSongIndex], Authorization: AppData().currentToken);
if (response.code != 200) {
likesnot = !likesnot;
likes[currentSongIndex] = !likes[currentSongIndex];
}
widget.onSongStatusChanged?.call(
currentSongIndex,
collection[currentSongIndex], //
likes[currentSongIndex]
);
},
icon: Image.asset(
likesnot
@ -274,11 +546,22 @@ class _MusicViewState extends State<MusicView> {
),
IconButton(
onPressed: () async {
UniversalBean bean1 =
await CollectionApiMusic().addCollection(musicId: currentSongIndex+1, Authorization: AppData().currentToken);
setState(() {
collectionsnot = !collectionsnot;
collection[currentSongIndex] = !collection[currentSongIndex];
});
UniversalBean response = await CollectionApiMusic().addCollection(musicId: id[currentSongIndex], Authorization: AppData().currentToken);
if (response.code != 200) {
collectionsnot = !collectionsnot;
collection[currentSongIndex] = !collection[currentSongIndex];
}
widget.onSongStatusChanged?.call(
currentSongIndex,
collection[currentSongIndex],
likes[currentSongIndex] //
);
},
icon: Image.asset(
collectionsnot
@ -293,7 +576,12 @@ class _MusicViewState extends State<MusicView> {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => CommentView(initialSongIndex: widget.initialSongIndex),
builder: (context) => CommentView(
id: id[currentSongIndex],
song: musicName,
singer: artistName,
cover: widget.songList[currentSongIndex].artistPic,
),
),
);
},
@ -308,45 +596,21 @@ class _MusicViewState extends State<MusicView> {
],
),
const SizedBox(
height: 60,
height: 80,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
"${formatDuration(_position)}",
style: const TextStyle(
color: Colors.black,
),
formatDuration(_position),
style: const TextStyle(color: Colors.black),
),
Expanded(
child: SliderTheme(
data: const SliderThemeData(
trackHeight: 3.0, //
thumbShape: RoundSliderThumbShape(
enabledThumbRadius: 7.0), //
overlayShape:
RoundSliderOverlayShape(overlayRadius: 12.0),
),
child: Slider(
min: 0,
max: _duration.inSeconds.toDouble(),
value: _position.inSeconds.toDouble(),
onChanged: (value) async {
await _audioPlayer
.seek(Duration(seconds: value.toInt()));
setState(() {});
},
activeColor: const Color(0xff429482),
inactiveColor: const Color(0xffE3F0ED),
),
),
child: _buildProgressSlider(),
),
Text(
"${formatDuration(_duration)}",
style: const TextStyle(
color: Colors.black,
),
formatDuration(_duration),
style: const TextStyle(color: Colors.black),
),
],
),
@ -377,15 +641,7 @@ class _MusicViewState extends State<MusicView> {
const SizedBox(
width: 10,
),
IconButton(
onPressed: playOrPause,
icon: _audioPlayer.state == PlayerState.playing
? Image.asset(
"assets/img/music_play.png",
)
: Image.asset(
"assets/img/music_pause.png",
)),
_buildPlayButton(), // 使IconButton
const SizedBox(
width: 10,
),
@ -438,9 +694,12 @@ class _MusicViewState extends State<MusicView> {
),
),
),
const SizedBox(
height: 10,
),
Expanded(
child: ListView.builder(
itemCount: 3,
itemCount: music.length,
itemBuilder: (BuildContext context, int index) {
bool isCurrentlyPlaying = currentSongIndex == index;
return ListTile(
@ -474,40 +733,10 @@ class _MusicViewState extends State<MusicView> {
},
),
),
ElevatedButton(
onPressed: () => Navigator.pop(context),
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xff429482),
padding: const EdgeInsets.symmetric(vertical: 14),
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.zero,
),
),
child: const Text(
"关闭",
style: TextStyle(color: Colors.black, fontSize: 20),
),
),
],
),
);
},
);
}
void _changeCurrentSong(int index) {
if (!_isDisposed) { // Check the flag before using the player
setState(() {
currentSongIndex = index;
_audioPlayer.setSourceUrl(song2[currentSongIndex]);
artistName = artist[currentSongIndex];
musicName = music[currentSongIndex];
likesnot = likes[currentSongIndex];
collectionsnot = collection[currentSongIndex];
_audioPlayer.resume();
});
}
}
}

@ -0,0 +1,507 @@
// music_view_test.dart
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../common/audio_player_controller.dart';
import '../common/download_manager.dart';
import '../common_widget/Song_widegt.dart';
import '../common_widget/app_data.dart';
import 'comment_view.dart';
class MusicView extends StatefulWidget {
final List<Song> songList;
final int initialSongIndex;
final Function(int index, bool isCollected, bool isLiked)?
onSongStatusChanged;
const MusicView({
super.key,
required this.songList,
required this.initialSongIndex,
this.onSongStatusChanged,
});
@override
State<MusicView> createState() => _MusicViewState();
}
class _MusicViewState extends State<MusicView>
with SingleTickerProviderStateMixin {
// late AnimationController _rotationController;
final AudioPlayerController playerController =
Get.put(AudioPlayerController());
final downloadManager = Get.find<DownloadManager>();
final AppData appData = AppData();
@override
void initState() {
super.initState();
playerController.initWithSongs(widget.songList, widget.initialSongIndex);
}
@override
void dispose() {
super.dispose();
}
String formatDuration(Duration duration) {
String twoDigits(int n) => n.toString().padLeft(2, "0");
String twoDigitMinutes = twoDigits(duration.inMinutes.remainder(60));
String twoDigitSeconds = twoDigits(duration.inSeconds.remainder(60));
return "$twoDigitMinutes:$twoDigitSeconds";
}
Widget _buildProgressSlider() {
return Obx(() {
final max = playerController.duration.value.inSeconds.toDouble() == 0
? 0.1
: playerController.duration.value.inSeconds.toDouble();
final current =
playerController.position.value.inSeconds.toDouble().clamp(0, max);
return SliderTheme(
data: const SliderThemeData(
trackHeight: 3.0,
thumbShape: RoundSliderThumbShape(enabledThumbRadius: 7.0),
overlayShape: RoundSliderOverlayShape(overlayRadius: 12.0),
),
child: Slider(
min: 0,
max: max,
value: current.toDouble(),
onChanged: (value) {
playerController.seekTo(Duration(seconds: value.toInt()));
},
activeColor: const Color(0xff429482),
inactiveColor: const Color(0xffE3F0ED),
),
);
});
}
Widget _buildPlayButton() {
return Obx(() {
return SizedBox(
width: 52,
height: 52,
child: Center(
child: playerController.isLoading.value
? const CircularProgressIndicator(
valueColor: AlwaysStoppedAnimation<Color>(Color(0xff429482)),
strokeWidth: 3.0,
)
: IconButton(
padding: EdgeInsets.zero,
constraints: const BoxConstraints(
minWidth: 52,
minHeight: 52,
maxWidth: 52,
maxHeight: 52,
),
onPressed: playerController.playOrPause,
icon: !playerController.isPlaying.value
? Image.asset(
"assets/img/music_play.png",
width: 52,
height: 52,
)
: Image.asset(
"assets/img/music_pause.png",
width: 52,
height: 52,
),
),
),
);
});
}
// Widget _buildRotatingAlbumCover() {
// return Obx(() {
// final currentSong =
// widget.songList[playerController.currentSongIndex.value];
// return RotationTransition(
// turns: _rotationController,
// child: Stack(
// alignment: Alignment.center,
// children: [
// Positioned(
// child: ClipRRect(
// child: Image.network(
// currentSong.artistPic,
// width: 225,
// height: 225,
// fit: BoxFit.cover,
// ),
// ),
// ),
// ClipRRect(
// child: Image.asset(
// "assets/img/music_Ellipse.png",
// width: 350,
// height: 350,
// fit: BoxFit.cover,
// ),
// ),
// ],
// ),
// );
// });
// }
Widget _buildRotatingAlbumCover() {
return Obx(() {
final currentSong =
widget.songList[playerController.currentSongIndex.value];
// RotationTransition
return Stack(
alignment: Alignment.center,
children: [
Positioned(
child: ClipRRect(
child: Image.network(
currentSong.artistPic,
width: 225,
height: 225,
fit: BoxFit.cover,
),
),
),
ClipRRect(
child: Image.asset(
"assets/img/music_Ellipse.png",
width: 350,
height: 350,
fit: BoxFit.cover,
),
),
],
);
});
}
void _showPlaylist() {
showModalBottomSheet(
context: context,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(top: Radius.circular(30)),
),
builder: (BuildContext context) {
return Container(
padding: const EdgeInsets.only(top: 15),
constraints: BoxConstraints(
maxHeight: MediaQuery.of(context).size.height * 0.45,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
const Center(
child: Text(
"播放列表",
style: TextStyle(fontSize: 20),
),
),
const SizedBox(height: 10),
Expanded(
child: Obx(() => ListView.builder(
itemCount: playerController.musicNames.length,
itemBuilder: (BuildContext context, int index) {
final isCurrentlyPlaying =
playerController.currentSongIndex.value == index;
return ListTile(
tileColor: isCurrentlyPlaying
? const Color(0xffE3F0ED)
: null,
title: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Padding(
padding: const EdgeInsets.only(left: 20),
child: Text(
playerController.musicNames[index],
style: const TextStyle(fontSize: 18),
),
),
Padding(
padding: const EdgeInsets.only(right: 20),
child: Image.asset(
"assets/img/songs_run.png",
width: 25,
),
),
],
),
onTap: () {
playerController.changeSong(index);
Navigator.pop(context);
},
);
},
)),
),
],
),
);
},
);
}
@override
Widget build(BuildContext context) {
return Container(
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/img/app_bg.png"),
fit: BoxFit.cover,
),
),
child: Scaffold(
resizeToAvoidBottomInset: false,
backgroundColor: Colors.transparent,
body: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.only(top: 45, left: 10, right: 10),
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
IconButton(
onPressed: () {
Get.back();
},
icon: Image.asset(
"assets/img/back.png",
width: 25,
height: 25,
fit: BoxFit.contain,
),
),
Row(
children: [
IconButton(
onPressed: () {},
icon: Image.asset(
"assets/img/music_add.png",
width: 30,
height: 30,
),
),
Obx(() => IconButton(
onPressed: downloadManager.isDownloading(
playerController.ids[playerController
.currentSongIndex.value]) ||
downloadManager.isCompleted(
playerController.ids[playerController
.currentSongIndex.value])
? null
: () async {
await downloadManager.startDownload(
song: widget.songList[playerController
.currentSongIndex.value],
context: context,
);
},
icon: Obx(() {
if (downloadManager.isDownloading(
playerController.ids[playerController
.currentSongIndex.value])) {
return Stack(
alignment: Alignment.center,
children: [
SizedBox(
width: 32,
height: 32,
child: CircularProgressIndicator(
value: downloadManager.getProgress(
playerController.ids[
playerController
.currentSongIndex.value]),
backgroundColor: Colors.grey[200],
valueColor:
const AlwaysStoppedAnimation<
Color>(Color(0xff429482)),
strokeWidth: 3.0,
),
),
Text(
'${(downloadManager.getProgress(playerController.ids[playerController.currentSongIndex.value]) * 100).toInt()}',
style: const TextStyle(fontSize: 12),
),
],
);
}
return Image.asset(
downloadManager.isCompleted(
playerController.ids[playerController
.currentSongIndex.value])
? "assets/img/music_download_completed.png"
: "assets/img/music_download.png",
width: 30,
height: 30,
);
}),
)),
],
),
],
),
const SizedBox(height: 80),
Center(child: _buildRotatingAlbumCover()),
const SizedBox(height: 60),
Obx(() => Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
playerController.musicName.value,
style: const TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
),
),
Text(
playerController.artistName.value,
style: const TextStyle(fontSize: 20),
),
],
),
Row(
children: [
IconButton(
onPressed: () async {
playerController.toggleLike();
final currentIndex =
playerController.currentSongIndex.value;
widget.onSongStatusChanged?.call(
currentIndex,
playerController.collections[currentIndex],
playerController.likes[currentIndex],
);
},
icon: Image.asset(
playerController.likesStatus.value
? "assets/img/music_good.png"
: "assets/img/music_good_un.png",
width: 29,
height: 29,
),
),
IconButton(
onPressed: () async {
playerController.toggleCollection();
final currentIndex =
playerController.currentSongIndex.value;
widget.onSongStatusChanged?.call(
currentIndex,
playerController.collections[currentIndex],
playerController.likes[currentIndex],
);
},
icon: Image.asset(
playerController.collectionsStatus.value
? "assets/img/music_star.png"
: "assets/img/music_star_un.png",
width: 29,
height: 29,
),
),
IconButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => CommentView(
id: playerController.ids[playerController
.currentSongIndex.value],
song: playerController.musicName.value,
singer: playerController.artistName.value,
cover: widget
.songList[playerController
.currentSongIndex.value]
.artistPic,
),
),
);
},
icon: Image.asset(
"assets/img/music_commend_un.png",
width: 29,
height: 29,
),
),
],
),
],
)),
const SizedBox(height: 80),
Obx(() => Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
formatDuration(playerController.position.value),
style: const TextStyle(color: Colors.black),
),
Expanded(child: _buildProgressSlider()),
Text(
formatDuration(playerController.duration.value),
style: const TextStyle(color: Colors.black),
),
],
)),
const SizedBox(height: 30),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
IconButton(
onPressed: () {},
icon: Image.asset(
"assets/img/music_random.png",
width: 35,
height: 35,
),
),
Row(
children: [
IconButton(
onPressed: playerController.playPrevious,
icon: Image.asset(
"assets/img/music_back.png",
width: 42,
height: 42,
),
),
const SizedBox(width: 10),
_buildPlayButton(),
const SizedBox(width: 10),
IconButton(
onPressed: playerController.playNext,
icon: Image.asset(
"assets/img/music_next.png",
width: 42,
height: 42,
),
),
],
),
IconButton(
onPressed: _showPlaylist,
icon: Image.asset(
"assets/img/music_more.png",
width: 35,
height: 35,
),
),
],
),
],
),
),
),
),
);
}
}

@ -2,9 +2,11 @@ import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:music_player_miao/common_widget/app_data.dart';
import '../api/api_music_rank.dart';
import '../common_widget/rank_song_row.dart';
import '../common/download_manager.dart';
import '../models/getRank_bean.dart';
import '../view_model/rank_view_model.dart';
import 'music_view.dart';
import '../common_widget/Song_widegt.dart';
class RankView extends StatefulWidget {
const RankView({super.key});
@ -13,30 +15,78 @@ class RankView extends StatefulWidget {
State<RankView> createState() => _RankViewState();
}
class _RankViewState extends State<RankView> {
class _RankViewState extends State<RankView> with AutomaticKeepAliveClientMixin {
final rankVM = Get.put(RankViewModel());
List rankNames = [];
List rankSingerName = [];
List rankCoverPath = [];
List rankMusicPath = [];
List<Song> songs = [];
final downloadManager = Get.put(DownloadManager());
@override
bool get wantKeepAlive => true;
@override
void initState() {
super.initState();
_fetchSonglistData();
_fetchTop50Data();
}
Future<void> _onRefresh() async {
await _fetchTop50Data();
}
Future<void> _fetchSonglistData() async {
Future<void> _fetchTop50Data() async {
try {
RankBean bean2 = await GetRank().getRank(Authorization: AppData().currentToken);
if (bean2.code != 200) return;
rankNames.clear();
rankSingerName.clear();
rankCoverPath.clear();
rankMusicPath.clear();
setState(() {
List<int> ids = bean2.data!.map((data) => data.id!).toList();
rankNames = bean2.data!.map((data) => data.name!).toList();
rankSingerName = bean2.data!.map((data) => data.singerName!).toList();
rankCoverPath = bean2.data!.map((data) => data.coverPath!).toList();
rankMusicPath = bean2.data!.map((data) => data.musicPath!).toList();
for (int i = 0; i < ids.length; i++) {
print(ids[i]);
}
songs.clear();
if (rankNames.isNotEmpty &&
rankNames.length == rankSingerName.length &&
rankNames.length == rankCoverPath.length &&
rankNames.length == rankMusicPath.length) {
for (int i = 0; i < rankNames.length; i++) {
songs.add(Song(
artistPic: rankCoverPath[i],
title: rankNames[i],
artist: rankSingerName[i],
musicurl: rankMusicPath[i],
pic: rankCoverPath[i],
id: ids[i],
likes: null,
collection: null,
));
}
}
});
} catch (e) {
//
print('Error fetching data: $e');
}
}
@override
Widget build(BuildContext context) {
super.build(context);
return Container(
decoration: const BoxDecoration(
image: DecorationImage(
@ -50,20 +100,19 @@ class _RankViewState extends State<RankView> {
body: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const SizedBox(
height: 40,
),
const SizedBox(height: 40),
//
const Center(
child: Column(
children: [
SizedBox(
height: 10,
),
Text(
'喵听排行榜',
style: TextStyle(fontSize: 22, fontWeight: FontWeight.w400),
),
SizedBox(
height: 10,
),
SizedBox(height: 10),
Text(
'Top50',
style: TextStyle(
@ -71,19 +120,15 @@ class _RankViewState extends State<RankView> {
fontSize: 40,
fontWeight: FontWeight.w500),
),
SizedBox(
height: 10,
),
Text(
'2023/12/12更新 1期',
style: TextStyle(fontSize: 16, fontWeight: FontWeight.w500),
),
// SizedBox(height: 10),
// Text(
// '2023/12/12更新 1期',
// style: TextStyle(fontSize: 16, fontWeight: FontWeight.w500),
// ),
],
),
),
const SizedBox(
height: 10,
),
const SizedBox(height: 10),
Container(
decoration: const BoxDecoration(
color: Colors.white,
@ -95,7 +140,25 @@ class _RankViewState extends State<RankView> {
child: Row(
children: [
IconButton(
onPressed: () {},
onPressed: () {
//
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => MusicView(
songList: songs,
initialSongIndex: 0,
onSongStatusChanged: (index, isCollected, isLiked) {
setState(() {
songs[index].collection = isCollected;
songs[index].likes = isLiked;
downloadManager.updateSongInfo(songs[index].id, isCollected, isLiked);
});
},
),
),
);
},
icon: Image.asset(
"assets/img/button_play.png",
width: 20,
@ -106,9 +169,7 @@ class _RankViewState extends State<RankView> {
'播放全部',
style: TextStyle(fontSize: 16),
),
const SizedBox(
width: 5,
),
const SizedBox(width: 5),
const Text(
'50',
style: TextStyle(fontSize: 16),
@ -117,8 +178,11 @@ class _RankViewState extends State<RankView> {
),
),
Expanded(
child: RefreshIndicator(
onRefresh: _onRefresh,
color: const Color(0xff429482),
child: SingleChildScrollView(
physics: const BouncingScrollPhysics(),
physics: const AlwaysScrollableScrollPhysics(), //
child: Container(
color: Colors.white,
child: Column(
@ -132,20 +196,37 @@ class _RankViewState extends State<RankView> {
itemBuilder: (context, index) {
int rankNum = index + 1;
return ListTile(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => MusicView(
songList: songs,
initialSongIndex: index,
onSongStatusChanged: (index, isCollected, isLiked) {
setState(() {
songs[index].collection = isCollected;
songs[index].likes = isLiked;
downloadManager.updateSongInfo(songs[index].id, isCollected, isLiked);
});
},
),
),
);
},
title: Column(
children: [
Row(
children: [
Row(
mainAxisAlignment:
MainAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
SizedBox(
width: 25,
child: RichText(
text: TextSpan(
text: rankNum.toString(),
style: TextStyle(
style: const TextStyle(
fontSize: 20,
fontWeight: FontWeight.w700,
color: Color(0xffCE0000),
@ -153,91 +234,88 @@ class _RankViewState extends State<RankView> {
),
),
),
const SizedBox(
width: 10,
),
const SizedBox(width: 10),
ClipRRect(
borderRadius:
BorderRadius.circular(10),
borderRadius: BorderRadius.circular(10),
child: Image.network(
rankCoverPath[index],
width: 60,
height: 60,
fit: BoxFit.cover,
),
),
const SizedBox(
width: 20,
),
const SizedBox(width: 20),
SizedBox(
width: 170,
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
rankNames[index],
maxLines: 1,
style: TextStyle(
style: const TextStyle(
color: Colors.black,
fontSize: 16,
fontWeight:
FontWeight.w400),
fontWeight: FontWeight.w400
),
),
Text(
rankSingerName[index],
maxLines: 1,
style: TextStyle(
style: const TextStyle(
color: Colors.black,
fontSize: 14),
fontSize: 14
),
)
],
),
),
const SizedBox(
width: 20,
),
const SizedBox(width: 18),
],
),
IconButton(
onPressed: () {
_bottomSheet(context);
_bottomSheet(context, index);
},
icon: Image.asset(
"assets/img/More.png",
'assets/img/More.png',
width: 25,
height: 25,
errorBuilder: (context, error, stackTrace) {
print('Error loading image: $error');
return const Icon(Icons.error, size: 25);
},
),
),
const SizedBox(
height: 20,
)
],
),
const SizedBox(
height: 10,
)
const SizedBox(height: 10)
],
));
}),
),
);
},
),
],
),
),
),
),
)
],
),
),
);
}
Future _bottomSheet(BuildContext context){
Future _bottomSheet(BuildContext context, int index) {
return showModalBottomSheet(
context: context,
backgroundColor: Colors.white,
shape: const RoundedRectangleBorder(borderRadius: BorderRadius.vertical(top: Radius.circular(30))),
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(top: Radius.circular(30))
),
builder: (context) => Container(
height: 210,
height: 150,
padding: const EdgeInsets.only(top: 20),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
@ -252,7 +330,7 @@ class _RankViewState extends State<RankView> {
icon: Image.asset("assets/img/list_add.png"),
iconSize: 60,
),
Text("加入歌单")
const Text("加入歌单")
],
),
Column(
@ -262,7 +340,7 @@ class _RankViewState extends State<RankView> {
icon: Image.asset("assets/img/list_download.png"),
iconSize: 60,
),
Text("下载")
const Text("下载")
],
),
Column(
@ -272,7 +350,7 @@ class _RankViewState extends State<RankView> {
icon: Image.asset("assets/img/list_collection.png"),
iconSize: 60,
),
Text("收藏")
const Text("收藏")
],
),
Column(
@ -282,60 +360,26 @@ class _RankViewState extends State<RankView> {
icon: Image.asset("assets/img/list_good.png"),
iconSize: 60,
),
Text("点赞")
const Text("点赞")
],
),
Column(
children: [
IconButton(
onPressed: (){},
onPressed: (){
Navigator.pop(context);
},
icon: Image.asset("assets/img/list_comment.png"),
iconSize: 60,
),
Text("评论")
const Text("评论")
],
),
],
),
const SizedBox(height: 10,),
ElevatedButton(
onPressed: () {
// Get.to(()=>const MainTabView());
},
child: Text(
"查看详情页",
style: const TextStyle(color:Colors.black,fontSize: 18),
),
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xffE6F4F1),
padding: const EdgeInsets.symmetric(vertical: 8),
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.zero,
),
),
),
ElevatedButton(
onPressed: () =>Navigator.pop(context),
child: Text(
"取消",
style: const TextStyle(color:Colors.black,fontSize: 18),
),
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xff429482),
padding: const EdgeInsets.symmetric(vertical: 8),
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.zero,
),
),
),
],
),
)
);
}
}

@ -23,17 +23,19 @@ class SongInfo {
SongInfo({required this.songName, required this.artistName});
}
class _ReleaseViewState extends State<ReleaseView> {
class _ReleaseViewState extends State<ReleaseView> with AutomaticKeepAliveClientMixin {
List<File> coverImages = [];
List<SongInfo> songInfoList = [];
late File selectedMp3File;
@override
bool get wantKeepAlive => true;
@override
Widget build(BuildContext context) {
super.build(context);
return Scaffold(
resizeToAvoidBottomInset: false,
backgroundColor: Colors.transparent,

@ -0,0 +1,516 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:music_player_miao/common_widget/Song_widegt.dart';
import '../../common/download_manager.dart';
import '../../view_model/home_view_model.dart';
import '../music_view.dart';
class MyDownloadView extends StatefulWidget {
const MyDownloadView({super.key});
@override
State<MyDownloadView> createState() => _MyDownloadViewState();
}
class _MyDownloadViewState extends State<MyDownloadView> {
final listVM = Get.put(HomeViewModel());
bool _isSelectMode = false;
final List<bool> _mySongListSelections = List.generate(2, (index) => false);
List<bool> _selectedItems = [];
List<Song> _songs = [];
final downloadManager = Get.put(DownloadManager());
@override
void initState() {
super.initState();
_getSongs();
}
void _toggleSelectMode() {
setState(() {
_isSelectMode = !_isSelectMode;
if (!_isSelectMode) {
_selectedItems = List.generate(_songs.length, (index) => false);
}
});
}
void _getSongs() async {
setState(() {
_songs = downloadManager.getLocalSongs();
_selectedItems = List.generate(_songs.length, (index) => false);
});
}
void _selectAll() {
setState(() {
_selectedItems = List.generate(_songs.length, (index) => true);
});
}
void _deleteSongs(List<bool> selectedItems) {
// List<Song> songsToDelete = [];
for (int i = 0; i < selectedItems.length; i++) {
if (selectedItems[i]) {
// songsToDelete.add(_songs[i]);
downloadManager.removeSong(_songs[i].id);
}
}
//
_getSongs();
}
void _deleteSong(int index) {
downloadManager.removeSong(_songs[index].id);
_getSongs();
}
void _showSelectionDialog() {
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
),
title: Row(
children: [
const Text(
"添加到",
),
Text(
'(${_selectedItems.where((item) => item).length} 首)',
style: const TextStyle(color: Color(0xff429482), fontSize: 16),
)
],
),
content: SingleChildScrollView(
physics: const BouncingScrollPhysics(),
child: Column(
children: [
for (int i = 0; i < _mySongListSelections.length; i++)
_buildSongListTile(i),
],
),
),
actions: [
TextButton(
onPressed: () {
Navigator.of(context).pop();
},
style: TextButton.styleFrom(
backgroundColor: const Color(0xff429482),
minimumSize: const Size(130, 50),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(5.0),
),
),
child: const Text(
"取消",
style: TextStyle(color: Colors.white),
),
),
TextButton(
onPressed: () {},
style: TextButton.styleFrom(
backgroundColor: const Color(0xff429482),
minimumSize: const Size(130, 50),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(5.0),
),
),
child: const Text(
"保存",
style: TextStyle(color: Colors.white),
),
),
],
);
},
);
}
Widget _buildSongListTile(int index) {
return ListTile(
title: Text("我的歌单 $index"),
trailing: Checkbox(
value: _mySongListSelections[index],
onChanged: (value) {
setState(() {
_mySongListSelections[index] = value ?? false;
});
},
shape: const CircleBorder(),
activeColor: const Color(0xff429482),
),
onTap: () {
setState(() {
_mySongListSelections[index] = !_mySongListSelections[index];
});
},
);
}
@override
Widget build(BuildContext context) {
return Container(
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/img/app_bg.png"),
fit: BoxFit.cover,
),
),
child: Scaffold(
backgroundColor: Colors.transparent,
appBar: AppBar(
backgroundColor: Colors.transparent,
centerTitle: true,
elevation: 0,
leading: !_isSelectMode
? IconButton(
onPressed: () {
Get.back(result: true);
},
icon: Image.asset(
"assets/img/back.png",
width: 25,
height: 25,
fit: BoxFit.contain,
),
)
: TextButton(
onPressed: _selectAll,
style: TextButton.styleFrom(
foregroundColor: Colors.black,
minimumSize: const Size(50, 40), //
padding:
const EdgeInsets.symmetric(horizontal: 8), //
),
child: const Text(
'全选',
style: TextStyle(fontSize: 18),
),
),
title: _isSelectMode
? Text(
'已选中 ${_selectedItems.where((item) => item).length} 首歌曲',
style: const TextStyle(
color: Colors.black,
),
)
: const Text(
'本地下载',
style: TextStyle(color: Colors.black),
),
actions: [
if (_isSelectMode)
TextButton(
onPressed: () {
setState(() {
_isSelectMode = false;
_selectedItems =
List.generate(_songs.length, (index) => false);
});
},
child: const Text(
"完成",
style: TextStyle(color: Colors.black, fontSize: 18),
))
],
),
body: Container(
padding: const EdgeInsets.only(left: 10),
decoration: const BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.vertical(top: Radius.circular(30)),
),
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
IconButton(
onPressed: _songs.isEmpty
? null
: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => MusicView(
songList: _songs,
initialSongIndex: 0,
onSongStatusChanged:
(index, isCollected, isLiked) {
setState(() {
//
_songs[index].collection =
isCollected;
_songs[index].likes = isLiked;
downloadManager.updateSongInfo(
_songs[index].id,
isCollected,
isLiked);
});
},
),
),
);
},
icon: Image.asset(
"assets/img/button_play.png",
width: 20,
height: 20,
),
),
const Text(
'播放全部',
style: TextStyle(fontSize: 16),
),
const SizedBox(
width: 5,
),
Text(
'${_songs.length}',
style: TextStyle(fontSize: 16),
),
],
),
IconButton(
onPressed: _songs.isEmpty ? null : _toggleSelectMode,
icon: Image.asset(
"assets/img/list_op.png",
width: 20,
height: 20,
),
),
],
),
Expanded(
child: ListView.builder(
itemCount: _songs.length,
itemBuilder: (BuildContext context, int index) {
final song = _songs[index];
return Container(
padding: const EdgeInsets.symmetric(vertical: 5.0),
child: ListTile(
leading: _isSelectMode
? Checkbox(
value: _selectedItems[index],
onChanged: (value) {
setState(() {
_selectedItems[index] = value!;
});
},
shape: const CircleBorder(),
activeColor: const Color(0xff429482),
)
: null,
title: Text('${song.title} - ${song.artist}'),
trailing: _isSelectMode
? null
: IconButton(
icon: const Icon(Icons.more_vert),
onPressed: () {
_bottomSheet(context, index);
},
),
//
onTap: _isSelectMode
? () {
//
setState(() {
_selectedItems[index] =
!_selectedItems[index];
});
}
: () {
//
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => MusicView(
songList: _songs,
initialSongIndex: index,
onSongStatusChanged:
(index, isCollected, isLiked) {
setState(() {
//
_songs[index].collection =
isCollected;
_songs[index].likes = isLiked;
});
},
),
),
);
},
),
);
},
),
),
],
),
),
bottomNavigationBar: _isSelectMode
? BottomAppBar(
height: 140, // BottomAppBar
child: SingleChildScrollView(
// 使 SingleChildScrollView
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Padding(
padding: const EdgeInsets.symmetric(vertical: 8),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
// "添加到"
Expanded(
child: InkWell(
onTap: () {
_showSelectionDialog();
},
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
SizedBox(
width: 25,
height: 25,
child: Image.asset("assets/img/add.png"),
),
const SizedBox(width: 4),
const Text("添加到"),
],
),
),
),
// 线
Container(
height: 50,
width: 2,
color: const Color(0xff429482),
),
// "删除"
Expanded(
child: InkWell(
onTap: () {
_deleteSongs(_selectedItems);
},
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
SizedBox(
width: 22,
height: 22,
child:
Image.asset("assets/img/delete.png"),
),
const SizedBox(width: 4),
const Text("删除"),
],
),
),
),
],
),
),
ElevatedButton(
onPressed: () {
setState(() {
_isSelectMode = false;
_selectedItems =
List.generate(_songs.length, (index) => false);
});
},
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xff429482),
padding: const EdgeInsets.symmetric(vertical: 14),
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.zero,
),
),
child: const Text(
'取消',
style: TextStyle(color: Colors.black, fontSize: 16),
),
),
],
),
),
)
: null,
),
);
}
Future _bottomSheet(BuildContext context, int index) {
return showModalBottomSheet(
context: context,
backgroundColor: Colors.white,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(top: Radius.circular(30))),
builder: (context) => Container(
height: 150,
padding: const EdgeInsets.only(top: 20),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Column(
children: [
IconButton(
onPressed: () {
_deleteSong(index);
Navigator.pop(context);
},
icon: Image.asset("assets/img/list_remove.png"),
iconSize: 60,
),
const Text("删除")
],
),
Column(
children: [
IconButton(
onPressed: () {},
icon: Image.asset("assets/img/list_collection.png"),
iconSize: 60,
),
const Text("收藏")
],
),
Column(
children: [
IconButton(
onPressed: () {},
icon: Image.asset("assets/img/list_good.png"),
iconSize: 60,
),
const Text("点赞")
],
),
Column(
children: [
IconButton(
onPressed: () {},
icon: Image.asset("assets/img/list_comment.png"),
iconSize: 60,
),
const Text("评论")
],
),
],
),
],
),
));
}
}

@ -1,22 +1,93 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../../common_widget/app_data.dart';
import '../../models/getAllSongs_bean.dart';
import '../../view_model/home_view_model.dart';
import '../../api/api_songlist.dart';
import '../../api/api_songlist.dart';
List<T> flatten<T>(Iterable<Iterable<T>> iterable) {
return iterable.expand((inner) => inner).toList();
}
class MyMusicView extends StatefulWidget {
const MyMusicView({super.key});
final int? songlistIdd;
const MyMusicView({Key? key, this.songlistIdd}) : super(key: key);
@override
State<MyMusicView> createState() => _MyMusicViewState();
}
class _MyMusicViewState extends State<MyMusicView> {
int songsNum = 0;
List songlistId = [];
List musicDetail = [];
List name = [];
List coverPath = [];
List musicPath = [];
List singerName = [];
List uploadUserName = [];
final listVM = Get.put(HomeViewModel());
bool _isSelectMode = false;
final List<bool> _mySongListSelections = List.generate(2, (index) => false);
List<bool> _selectedItems = List.generate(10, (index) => false);
//
@override
void initState() {
super.initState();
if (widget.songlistIdd != null) {
_fetchMyWorksData();
} else {
// songlistIdd null
print('Songlist ID is null, cannot fetch data.');
}
}
///
Future<void> _fetchMyWorksData() async {
try {
MyMusicListBean bean2 = await SonglistApi().getAllSongs(
id: widget.songlistIdd!,
Authorization: AppData().currentToken,
);
setState(() {
//
name = [];
coverPath = [];
musicPath = [];
singerName = [];
songlistId = [];
// DataBean
bean2.data?.forEach((dataBean) {
// songlistId
songlistId.add(dataBean.songlistId);
// musicDetail
SongDetails songDetails = dataBean.musicDetail!;
//
name.add(songDetails.name);
coverPath.add(songDetails.coverPath);
musicPath.add(songDetails.musicPath);
singerName.add(songDetails.singerName);
});
songsNum = name.length; //
print('赋值开始');
print('赋值结束');
});
} catch (error) {
print('Error fetching myworks data: $error');
}
}
//
void _toggleSelectMode() {
setState(() {
_isSelectMode = !_isSelectMode;
@ -42,13 +113,12 @@ class _MyMusicViewState extends State<MyMusicView> {
),
title: Row(
children: [
const Text("添加到",),
const Text(
"添加到",
),
Text(
'(${_selectedItems.where((item) => item).length} 首)',
style: const TextStyle(
color: Color(0xff429482),
fontSize: 16
),
style: const TextStyle(color: Color(0xff429482), fontSize: 16),
)
],
),
@ -79,8 +149,7 @@ class _MyMusicViewState extends State<MyMusicView> {
),
),
TextButton(
onPressed: () {
},
onPressed: () {},
style: TextButton.styleFrom(
backgroundColor: const Color(0xff429482),
minimumSize: const Size(130, 50),
@ -120,7 +189,6 @@ class _MyMusicViewState extends State<MyMusicView> {
);
}
@override
Widget build(BuildContext context) {
return Container(
@ -139,7 +207,7 @@ class _MyMusicViewState extends State<MyMusicView> {
leading: !_isSelectMode
? IconButton(
onPressed: () {
Get.back();
Get.back(result: true);
},
icon: Image.asset(
"assets/img/back.png",
@ -152,8 +220,14 @@ class _MyMusicViewState extends State<MyMusicView> {
onPressed: _selectAll,
style: TextButton.styleFrom(
foregroundColor: Colors.black,
minimumSize: const Size(50, 40), //
padding:
const EdgeInsets.symmetric(horizontal: 8), //
),
child: const Text(
'全选',
style: TextStyle(fontSize: 18),
),
child: const Text('全选',style: TextStyle(fontSize: 18),),
),
title: _isSelectMode
? Text(
@ -177,12 +251,8 @@ class _MyMusicViewState extends State<MyMusicView> {
},
child: const Text(
"完成",
style: TextStyle(
color: Colors.black,
fontSize: 18
),
)
)
style: TextStyle(color: Colors.black, fontSize: 18),
))
],
),
body: Container(
@ -208,16 +278,14 @@ class _MyMusicViewState extends State<MyMusicView> {
),
const Text(
'播放全部',
style: TextStyle(
fontSize: 16
style: TextStyle(fontSize: 16),
),
const SizedBox(
width: 5,
),
const SizedBox(width: 5,),
const Text(
'50',
style: TextStyle(
fontSize: 16
),
style: TextStyle(fontSize: 16),
),
],
),
@ -232,8 +300,10 @@ class _MyMusicViewState extends State<MyMusicView> {
],
),
Expanded(
child: ListView.builder(
itemCount: 10,
child: songsNum == 0
? Center(child: Text('该歌单为空')) //
: ListView.builder(
itemCount: songsNum,
itemBuilder: (BuildContext context, int index) {
return Container(
padding: const EdgeInsets.symmetric(vertical: 5.0),
@ -249,8 +319,15 @@ class _MyMusicViewState extends State<MyMusicView> {
shape: const CircleBorder(),
activeColor: const Color(0xff429482),
)
: null,
title: Text('歌曲名 $index - 歌手'),
: CircleAvatar(
backgroundImage:
NetworkImage(coverPath[index]),
//
radius: 25,
),
title:
Text('${name[index]} - ${singerName[index]}'),
//
trailing: _isSelectMode
? null
: IconButton(
@ -267,7 +344,6 @@ class _MyMusicViewState extends State<MyMusicView> {
],
),
),
bottomNavigationBar: _isSelectMode
? BottomAppBar(
child: SizedBox(
@ -299,7 +375,8 @@ class _MyMusicViewState extends State<MyMusicView> {
children: [
IconButton(
onPressed: () {},
icon: Image.asset("assets/img/list_download.png"),
icon:
Image.asset("assets/img/list_download.png"),
iconSize: 60,
),
const Text("下载"),
@ -311,7 +388,8 @@ class _MyMusicViewState extends State<MyMusicView> {
onPressed: () {
setState(() {
_isSelectMode = false;
_selectedItems = List.generate(10, (index) => false);
_selectedItems =
List.generate(10, (index) => false);
});
},
style: ElevatedButton.styleFrom(
@ -322,11 +400,10 @@ class _MyMusicViewState extends State<MyMusicView> {
borderRadius: BorderRadius.zero,
),
),
child: const Text('取消',
style: TextStyle(
color: Colors.black,
fontSize: 16
),),
child: const Text(
'取消',
style: TextStyle(color: Colors.black, fontSize: 16),
),
),
],
),
@ -336,11 +413,13 @@ class _MyMusicViewState extends State<MyMusicView> {
),
);
}
Future _bottomSheet(BuildContext context) {
return showModalBottomSheet(
context: context,
backgroundColor: Colors.white,
shape: const RoundedRectangleBorder(borderRadius: BorderRadius.vertical(top: Radius.circular(30))),
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(top: Radius.circular(30))),
builder: (context) => Container(
height: 210,
padding: const EdgeInsets.only(top: 20),
@ -402,7 +481,9 @@ class _MyMusicViewState extends State<MyMusicView> {
),
],
),
const SizedBox(height: 10,),
const SizedBox(
height: 10,
),
ElevatedButton(
onPressed: () {
// Get.to(()=>const MusicView());
@ -419,7 +500,6 @@ class _MyMusicViewState extends State<MyMusicView> {
"查看详情页",
style: TextStyle(color: Colors.black, fontSize: 18),
),
),
ElevatedButton(
onPressed: () => Navigator.pop(context),
@ -435,12 +515,9 @@ class _MyMusicViewState extends State<MyMusicView> {
"取消",
style: TextStyle(color: Colors.black, fontSize: 18),
),
),
],
),
)
);
));
}
}

@ -1,6 +1,9 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:music_player_miao/common_widget/Song_widegt.dart';
import '../../api/api_songlist.dart';
import '../../common_widget/app_data.dart';
import '../../models/getMyWorks.dart';
import '../../view_model/home_view_model.dart';
class MyWorkView extends StatefulWidget {
@ -11,6 +14,12 @@ class MyWorkView extends StatefulWidget {
}
class _MyWorkViewState extends State<MyWorkView> {
int MyWorkCount = 0;
List MyWorkNames = [];
List Songid = [];
List coverPath = [];
List musicPath = [];
List singerName = [];
final listVM = Get.put(HomeViewModel());
bool _isSelectMode = false;
@ -18,6 +27,37 @@ class _MyWorkViewState extends State<MyWorkView> {
List<bool> _mySongListSelections = List.generate(2, (index) => false);
List<bool> _selectedItems = List.generate(10, (index) => false);
//
@override
void initState() {
super.initState();
print('初始化正常');
_fetchMyWorksData();
}
///
Future<void> _fetchMyWorksData() async {
try {
MyWorks bean2 = await SonglistApi().getMyworks(
Authorization: AppData().currentToken,
);
setState(() {
MyWorkNames = bean2.data!.map((data) => data.name!).toList();
Songid = bean2.data!.map((data) => data.id!).toList();
coverPath = bean2.data!.map((data) => data.coverPath!).toList();
musicPath = bean2.data!.map((data) => data.musicPath!).toList();
singerName = bean2.data!.map((data) => data.singerName!).toList();
print('赋值开始');
MyWorkCount = MyWorkNames.length;
print('赋值结束');
});
} catch (error) {
print('Error fetching myworks data: $error');
}
}
//
void _toggleSelectMode() {
setState(() {
_isSelectMode = !_isSelectMode;
@ -248,8 +288,10 @@ class _MyWorkViewState extends State<MyWorkView> {
],
),
Expanded(
child: ListView.builder(
itemCount: 10,
child: MyWorkCount == 0
? Center(child: Text('你还没有作品')) //
: ListView.builder(
itemCount: MyWorkCount,
itemBuilder: (BuildContext context, int index) {
return Container(
padding: const EdgeInsets.symmetric(vertical: 5.0),
@ -265,8 +307,11 @@ class _MyWorkViewState extends State<MyWorkView> {
shape: const CircleBorder(),
activeColor: const Color(0xff429482),
)
: null,
title: Text('歌曲名 $index - 歌手'),
: CircleAvatar(
backgroundImage: NetworkImage(coverPath[index]), //
radius: 25,
),
title: Text('${MyWorkNames[index]} - ${singerName[index]}'), //
trailing: _isSelectMode
? null
: IconButton(

@ -1,17 +1,11 @@
// ignore_for_file: use_build_context_synchronously
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:music_player_miao/widget/text_field.dart';
import 'package:image_picker/image_picker.dart';
import '../../api/api_client.dart';
import '../../api/api_client_info.dart';
import '../../common_widget/app_data.dart';
import '../../models/getInfo_bean.dart';
import '../../models/universal_bean.dart';
import '../../view_model/home_view_model.dart';
import 'package:image_picker/image_picker.dart';
class UserInfo extends StatefulWidget {
const UserInfo({super.key});
@ -23,7 +17,7 @@ class UserInfo extends StatefulWidget {
class _UserInfoState extends State<UserInfo> {
final listVM = Get.put(HomeViewModel());
final TextEditingController _controller = TextEditingController();
late File _selectedImage;
File? _selectedImage;
@override
Widget build(BuildContext context) {
@ -42,7 +36,7 @@ class _UserInfoState extends State<UserInfo> {
elevation: 0,
leading: IconButton(
onPressed: () {
Get.back();
Get.back(result: true);
},
icon: Image.asset(
"assets/img/back.png",
@ -60,7 +54,18 @@ class _UserInfoState extends State<UserInfo> {
body: SingleChildScrollView(
child: Column(
children: [
Container(
_buildAvatarRow(),
_buildNicknameRow(),
],
),
),
),
);
}
//
Widget _buildAvatarRow() {
return Container(
height: 80,
color: Colors.white.withOpacity(0.6),
padding: const EdgeInsets.only(left: 48, right: 25),
@ -77,26 +82,24 @@ class _UserInfoState extends State<UserInfo> {
),
Row(
children: [
Image.network(
AppData().currentAvatar,
width: 64,
height: 64,
),
const SizedBox(
width: 20,
),
_buildAvatarImage(),
const SizedBox(width: 20),
Image.asset(
"assets/img/user_next.png",
width: 25,
height: 25,
)
],
)
),
],
),
],
),
),
Container(
);
}
//
Widget _buildNicknameRow() {
return Container(
height: 80,
color: Colors.white.withOpacity(0.6),
padding: const EdgeInsets.only(left: 48, right: 25),
@ -117,27 +120,38 @@ class _UserInfoState extends State<UserInfo> {
AppData().currentUsername,
style: const TextStyle(fontSize: 20),
),
const SizedBox(
width: 15,
),
const SizedBox(width: 15),
Image.asset(
"assets/img/user_next.png",
width: 25,
height: 25,
)
],
)
],
),
),
)
],
),
],
),
),
);
}
// Widget URL
Widget _buildAvatarImage() {
final avatarPath = AppData().currentAvatar;
if (avatarPath.startsWith('http')) {
return Image.network(
avatarPath,
width: 64,
height: 64,
);
} else {
return Image.file(
File(avatarPath),
width: 64,
height: 64,
);
}
}
Future _bottomSheet(BuildContext context) async {
final picker = ImagePicker();
await showModalBottomSheet(
@ -146,7 +160,7 @@ class _UserInfoState extends State<UserInfo> {
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(top: Radius.circular(30))),
builder: (context) => Container(
height: 132,
height: 80,
padding: const EdgeInsets.only(top: 20),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
@ -157,18 +171,19 @@ class _UserInfoState extends State<UserInfo> {
final pickedFile =
await picker.pickImage(source: ImageSource.gallery);
if (pickedFile != null) {
_selectedImage=File('assets/images/bg.png');
setState(() {
_selectedImage = File(pickedFile.path);
print(_selectedImage);
});
UniversalBean bean = await ChangeApiClient().changeHeader(
setState(() {}); // UI
//
await ChangeApiClient().changeHeader(
Authorization: AppData().currentToken,
avatar: _selectedImage);
GetInfoBean bean1 = await GetInfoApiClient().getInfo(
avatar: _selectedImage!);
//
_updatetouxiang(_selectedImage!.path);
//
await GetInfoApiClient().getInfo(
Authorization: AppData().currentToken);
AppData appData = AppData();
appData.box.write('currentAvatar', AppData().currentAvatar);
}
},
style: ElevatedButton.styleFrom(
@ -182,24 +197,10 @@ class _UserInfoState extends State<UserInfo> {
style: TextStyle(color: Colors.black, fontSize: 18),
),
),
ElevatedButton(
onPressed: () => Navigator.pop(context),
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xff429482),
padding: const EdgeInsets.symmetric(vertical: 18),
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.zero,
),
),
child: const Text(
"取消",
style: TextStyle(color: Colors.black, fontSize: 18),
),
),
],
),
));
),
);
}
void _showNicknameDialog() {
@ -212,46 +213,44 @@ class _UserInfoState extends State<UserInfo> {
"修改昵称",
style: TextStyle(fontSize: 20),
)),
content: TextFieldColor(
content: TextField(
controller: _controller,
hintText: '请输入新昵称',
decoration: const InputDecoration(hintText: '请输入新昵称'),
),
actions: <Widget>[
TextButton(
onPressed: () {
onPressed: () async {
_updateNickname();
await ChangeApiClient().changeName(
Authorization: AppData().currentToken,
userName: AppData().currentUsername);
Navigator.of(context).pop();
},
style: TextButton.styleFrom(
backgroundColor: const Color(0xff429482),
minimumSize: const Size(130, 50),
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(5.0), // Adjust the radius as needed
borderRadius: BorderRadius.circular(5.0),
),
),
child: const Text(
"取消",
"保存",
style: TextStyle(color: Colors.white),
),
),
TextButton(
onPressed: () async {
_updateNickname();
UniversalBean bean = await ChangeApiClient().changeName(
Authorization: AppData().currentToken,
userName: AppData().currentUsername);
onPressed: () {
Navigator.of(context).pop();
},
style: TextButton.styleFrom(
backgroundColor: const Color(0xff429482),
minimumSize: const Size(130, 50),
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(5.0), // Adjust the radius as needed
borderRadius: BorderRadius.circular(5.0),
),
),
child: const Text(
"保存",
"取消",
style: TextStyle(color: Colors.white),
),
),
@ -267,4 +266,14 @@ class _UserInfoState extends State<UserInfo> {
appData.box.write('currentUsername', _controller.text);
});
}
void _updatetouxiang(String path) {
setState(() {
AppData appData = AppData();
appData.box.write('currentAvatar', path); //
});
}
}

@ -1,3 +1,5 @@
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:music_player_miao/api/api_songlist.dart';
@ -5,11 +7,13 @@ import 'package:music_player_miao/common_widget/app_data.dart';
import 'package:music_player_miao/models/songlist_bean.dart';
import 'package:music_player_miao/models/universal_bean.dart';
import 'package:music_player_miao/view/begin/begin_view.dart';
import 'package:music_player_miao/view/user/my_download_view.dart';
import 'package:music_player_miao/view/user/my_music_view.dart';
import 'package:music_player_miao/view/user/user_info.dart';
import 'package:music_player_miao/widget/text_field.dart';
import '../../../view_model/home_view_model.dart';
import '../../api/api_client.dart';
import '../../common/download_manager.dart';
import '../../models/search_bean.dart';
import 'my_work_view.dart';
@ -20,20 +24,28 @@ class UserView extends StatefulWidget {
State<UserView> createState() => _UserViewState();
}
class _UserViewState extends State<UserView> {
class _UserViewState extends State<UserView> with AutomaticKeepAliveClientMixin {
final homeVM = Get.put(HomeViewModel());
final TextEditingController _controller = TextEditingController();
int playlistCount = 2;
int playlistCount = 0;
List playlistNames = [];
List playlistid = [];
List<int> playlistid = [];
int downloadCount = 0;
String avatar = AppData().currentAvatar;
String username = AppData().currentUsername;
final downloadManager = Get.put(DownloadManager());
@override
bool get wantKeepAlive => true;
@override
void initState() {
super.initState();
_fetchSonglistData();
downloadCount = downloadManager.completedNumber();
}
///getSonglist
Future<void> _fetchSonglistData() async {
try {
SearchBean bean2 = await SonglistApi().getSonglist(
@ -42,7 +54,7 @@ class _UserViewState extends State<UserView> {
setState(() {
playlistNames = bean2.data!.map((data) => data.name!).toList();
playlistid = bean2.data!.map((data) => data.id!).toList();
playlistid = bean2.data!.map((data) => data.id!).toList(); // idint
playlistCount = playlistNames.length;
});
} catch (error) {
@ -52,6 +64,7 @@ class _UserViewState extends State<UserView> {
@override
Widget build(BuildContext context) {
super.build(context);
return Container(
decoration: const BoxDecoration(
image: DecorationImage(
@ -77,16 +90,20 @@ class _UserViewState extends State<UserView> {
children: [
Row(
children: [
Image.network(
AppData().currentAvatar,
width: 64,
height: 64,
ClipRRect(
borderRadius: BorderRadius.circular(10),
child: Image.network(
avatar,
width: 60,
height: 60,
fit: BoxFit.cover,
),
),
const SizedBox(
width: 25,
),
Text(
AppData().currentUsername,
username,
style: const TextStyle(fontSize: 20),
)
],
@ -107,12 +124,19 @@ class _UserViewState extends State<UserView> {
Container(
padding: const EdgeInsets.only(
left: 15, right: 15, top: 20, bottom: 20),
//
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
InkWell(
onTap: () {
Get.to(const MyMusicView());
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const MyMusicView(),
),
);
},
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
@ -140,26 +164,41 @@ class _UserViewState extends State<UserView> {
],
),
),
const SizedBox(
height: 10,
),
//
InkWell(
onTap: () {
Get.to(const MyMusicView());
onTap: () async {
final result = await Navigator.push(
context,
MaterialPageRoute(
builder: (context) => MyDownloadView(),
),
);
if (result == true) {
setState(() {
downloadCount = downloadManager.completedNumber();
});
}
},
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Image.asset("assets/img/artist_pic.png"),
const Column(
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
const Text(
"本地下载",
style: TextStyle(fontSize: 20),
),
Text(
"19首",
'${downloadCount}',
style: TextStyle(fontSize: 16),
),
],
@ -175,14 +214,22 @@ class _UserViewState extends State<UserView> {
),
],
)),
///
Container(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
//
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'歌单 $playlistCount',
style: const TextStyle(
fontSize: 20, fontWeight: FontWeight.w500),
fontSize: 20,
fontWeight: FontWeight.w500
),
),
Row(
children: [
@ -194,149 +241,80 @@ class _UserViewState extends State<UserView> {
"assets/img/user_add.png",
width: 31,
color: const Color(0xff404040),
)),
)
),
IconButton(
onPressed: () {},
icon: Image.asset("assets/img/user_export.png",
width: 31))
],
icon: Image.asset(
"assets/img/user_export.png",
width: 31
)
)
],
),
Container(
padding: const EdgeInsets.only(
left: 15, right: 15, top: 10, bottom: 5),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
InkWell(
onTap: () {},
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Image.asset("assets/img/artist_pic.png"),
const Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"我的收藏",
style: TextStyle(fontSize: 20),
),
Text(
"19首",
style: TextStyle(fontSize: 16),
),
],
),
const SizedBox(
width: 80,
),
Image.asset(
"assets/img/user_next.png",
)
],
),
),
const SizedBox(
height: 10,
),
//
Padding(
padding: const EdgeInsets.symmetric(horizontal: 15),
child: Column(
children: List.generate(
playlistNames.length,
(index) => Column(
children: [
InkWell(
onTap: () {},
onTap: () {
print('点击成功');
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => MyMusicView(
songlistIdd: playlistid[index]
),
),
);
},
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Image.asset("assets/img/artist_pic.png"),
const Column(
const SizedBox(width: 25),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"本地下载",
style: TextStyle(fontSize: 20),
playlistNames[index],
style: const TextStyle(fontSize: 20),
),
Text(
"19首",
style: TextStyle(fontSize: 16),
'$playlistCount',
style: const TextStyle(fontSize: 16),
),
],
),
const SizedBox(
width: 80,
),
Image.asset(
"assets/img/user_next.png",
)
Image.asset("assets/img/user_next.png"),
],
),
),
if (index < playlistNames.length - 1)
const SizedBox(height: 10),
],
)),
InkWell(
onTap: () {
Get.to(const MyMusicView());
},
child: Column(
children: List.generate(playlistNames.length, (index) {
return Dismissible(
key: Key(playlistNames[index]),
direction: DismissDirection.endToStart,
background: Container(
color: Colors.red,
alignment: Alignment.centerRight,
padding: const EdgeInsets.only(right: 20.0),
child: const Icon(
Icons.delete,
color: Colors.white,
),
),
confirmDismiss: (direction) async {
return await _showDeleteConfirmationDialog(
context, index);
},
onDismissed: (direction) {
setState(() {
playlistNames.removeAt(index);
playlistid.removeAt(index);
playlistCount--;
});
},
child: ListTile(
title: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
Image.asset("assets/img/artist_pic.png"),
const SizedBox(
width: 30,
),
Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Text(
playlistNames[index],
style: const TextStyle(fontSize: 18),
),
const Text(
'0首',
style: TextStyle(fontSize: 18),
),
],
),
],
),
Image.asset(
"assets/img/user_next.png",
)
],
),
),
);
}),
),
),
const SizedBox(
height: 20,
height: 30,
),
const Text(
@ -351,7 +329,12 @@ class _UserViewState extends State<UserView> {
children: [
InkWell(
onTap: () {
Get.to(const MyWorkView());
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const MyWorkView(),
),
);
},
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
@ -395,11 +378,13 @@ class _UserViewState extends State<UserView> {
context: context,
backgroundColor: Colors.white,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(top: Radius.circular(30))),
builder: (context) => Container(
height: 200,
borderRadius: BorderRadius.vertical(top: Radius.circular(30)),
),
isScrollControlled: true, //
builder: (context) => Padding(
padding: const EdgeInsets.only(top: 20),
child: Column(
mainAxisSize: MainAxisSize.min, // 使Column
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Row(
@ -408,8 +393,20 @@ class _UserViewState extends State<UserView> {
Column(
children: [
IconButton(
onPressed: () {
Get.to(const UserInfo());
onPressed: () async {
Navigator.pop(context);
bool result = await Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const UserInfo(),
),
);
if (result) {
setState(() {
avatar = AppData().currentAvatar;
username = AppData().currentUsername;
});
}
},
icon: Image.asset("assets/img/user_infor.png"),
iconSize: 60,
@ -421,12 +418,14 @@ class _UserViewState extends State<UserView> {
children: [
IconButton(
onPressed: () async {
UniversalBean bean = await LogoutApiClient()
.logout(
Authorization: AppData().currentToken);
if (bean.code == 200) {
Navigator.pop(context);
Get.to(const BeginView());
}
UniversalBean bean = await LogoutApiClient().logout(
Authorization: AppData().currentToken,
);
AppData().currentToken = '';
AppData().currentUsername = '';
AppData().currentAvatar = '';
},
icon: Image.asset("assets/img/user_out.png"),
iconSize: 60,
@ -436,27 +435,11 @@ class _UserViewState extends State<UserView> {
),
],
),
const SizedBox(
height: 30,
),
ElevatedButton(
onPressed: () => Navigator.pop(context),
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xff429482),
padding: const EdgeInsets.symmetric(vertical: 14),
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.zero,
),
),
child: const Text(
"取消",
style: TextStyle(color: Colors.black, fontSize: 18),
),
),
const SizedBox(height: 30),
],
),
));
),
);
}
///--
@ -478,8 +461,19 @@ class _UserViewState extends State<UserView> {
content: TextFieldColor(controller: _controller, hintText: '请输入歌单名称'),
actions: <Widget>[
TextButton(
onPressed: () {
onPressed: () async {
Navigator.of(context).pop();
String enteredSongName = _controller.text;
SonglistBean bean = await SonglistApi().addSonglist(
songlistName: enteredSongName,
Authorization: AppData().currentToken);
if (bean.code == 200) {
print('添加成功');
setState(() {
playlistCount++;
playlistNames.add(enteredSongName);
});
}
},
style: TextButton.styleFrom(
backgroundColor: const Color(0xff429482),
@ -489,22 +483,13 @@ class _UserViewState extends State<UserView> {
),
),
child: const Text(
"取消",
"确认",
style: TextStyle(color: Colors.white),
),
),
TextButton(
onPressed: () async {
onPressed: () {
Navigator.of(context).pop();
String enteredSongName = _controller.text;
playlistCount++;
// Add the new playlist
setState(() {
playlistNames.add(enteredSongName);
});
SonglistBean bean = await SonglistApi().addSonglist(
songlistName: _controller.text,
Authorization: AppData().currentToken);
},
style: TextButton.styleFrom(
backgroundColor: const Color(0xff429482),
@ -514,7 +499,7 @@ class _UserViewState extends State<UserView> {
),
),
child: const Text(
"确认",
"取消",
style: TextStyle(color: Colors.white),
),
),

@ -0,0 +1,76 @@
import 'package:flutter/material.dart';
class CommentPage extends StatefulWidget {
const CommentPage({Key? key}) : super(key: key);
@override
_CommentPageState createState() => _CommentPageState();
}
class _CommentPageState extends State<CommentPage> {
final TextEditingController _controller = TextEditingController();
final List<String> _comments = ["这是第一个评论", "很喜欢这首歌!"]; //
void _addComment() {
if (_controller.text.isNotEmpty) {
setState(() {
_comments.insert(0, _controller.text); //
});
_controller.clear(); //
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('评论'),
),
body: Column(
children: [
//
Expanded(
child: ListView.builder(
reverse: true, //
itemCount: _comments.length,
itemBuilder: (context, index) {
return ListTile(
leading: const CircleAvatar(
child: Icon(Icons.person),
),
title: Text(_comments[index]),
subtitle: Text('${DateTime.now().difference(DateTime.now().subtract(Duration(minutes: index * 5))).inMinutes} 分钟前'),
);
},
),
),
const Divider(),
//
Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
children: [
Expanded(
child: TextField(
controller: _controller,
decoration: InputDecoration(
hintText: '输入你的评论...',
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(10.0),
),
),
onSubmitted: (_) => _addComment(), //
),
),
IconButton(
icon: const Icon(Icons.send, color: Colors.blue),
onPressed: _addComment,
),
],
),
),
],
),
);
}
}

@ -8,6 +8,7 @@ class TextFieldColor extends StatelessWidget {
final String? Function(String?)? validator;
final FocusNode? focusNode;
final String? Function(String?)? onChanged;
final bool enabled; // enabled
const TextFieldColor({
super.key,
@ -18,11 +19,13 @@ class TextFieldColor extends StatelessWidget {
this.validator,
this.focusNode,
this.onChanged,
this.enabled = true, //
});
@override
Widget build(BuildContext context) {
return TextFormField(
enabled: enabled,
validator: validator,
controller: controller,
focusNode: focusNode,
@ -35,22 +38,25 @@ class TextFieldColor extends StatelessWidget {
contentPadding: EdgeInsets.symmetric(vertical: 10.0, horizontal: 16.0),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
borderSide: BorderSide.none
borderSide: BorderSide.none,
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
borderSide: BorderSide.none,
),
fillColor: Color(0xffE3F0ED),
disabledBorder: OutlineInputBorder( //
borderRadius: BorderRadius.circular(10),
borderSide: BorderSide.none,
),
fillColor: enabled ? const Color(0xffE3F0ED) : const Color(0xffE3F0ED).withOpacity(0.7), //
filled: true,
hintText: hintText,
alignLabelWithHint: true,
hintStyle: TextStyle(
color: Color(0xff6E6E6E),
fontSize: 16
color: enabled ? const Color(0xff6E6E6E) : const Color(0xff6E6E6E).withOpacity(0.5),
fontSize: 16,
),
),
);
}
}

@ -5,12 +5,18 @@
import FlutterMacOS
import Foundation
import audio_session
import audioplayers_darwin
import file_selector_macos
import just_audio
import path_provider_foundation
import shared_preferences_foundation
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
AudioSessionPlugin.register(with: registry.registrar(forPlugin: "AudioSessionPlugin"))
AudioplayersDarwinPlugin.register(with: registry.registrar(forPlugin: "AudioplayersDarwinPlugin"))
FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin"))
JustAudioPlugin.register(with: registry.registrar(forPlugin: "JustAudioPlugin"))
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
}

@ -6,15 +6,23 @@ packages:
description:
name: async
sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c"
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "2.11.0"
audio_session:
dependency: transitive
description:
name: audio_session
sha256: "343e83bc7809fbda2591a49e525d6b63213ade10c76f15813be9aed6657b3261"
url: "https://pub.dev"
source: hosted
version: "0.1.21"
audioplayers:
dependency: "direct main"
description:
name: audioplayers
sha256: c05c6147124cd63e725e861335a8b4d57300b80e6e92cea7c145c739223bbaef
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "5.2.1"
audioplayers_android:
@ -22,7 +30,7 @@ packages:
description:
name: audioplayers_android
sha256: b00e1a0e11365d88576320ec2d8c192bc21f1afb6c0e5995d1c57ae63156acb5
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "4.0.3"
audioplayers_darwin:
@ -30,7 +38,7 @@ packages:
description:
name: audioplayers_darwin
sha256: "3034e99a6df8d101da0f5082dcca0a2a99db62ab1d4ddb3277bed3f6f81afe08"
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "5.0.2"
audioplayers_linux:
@ -38,7 +46,7 @@ packages:
description:
name: audioplayers_linux
sha256: "60787e73fefc4d2e0b9c02c69885402177e818e4e27ef087074cf27c02246c9e"
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "3.1.0"
audioplayers_platform_interface:
@ -46,7 +54,7 @@ packages:
description:
name: audioplayers_platform_interface
sha256: "365c547f1bb9e77d94dd1687903a668d8f7ac3409e48e6e6a3668a1ac2982adb"
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "6.1.0"
audioplayers_web:
@ -54,7 +62,7 @@ packages:
description:
name: audioplayers_web
sha256: "22cd0173e54d92bd9b2c80b1204eb1eb159ece87475ab58c9788a70ec43c2a62"
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "4.1.0"
audioplayers_windows:
@ -62,7 +70,7 @@ packages:
description:
name: audioplayers_windows
sha256: "9536812c9103563644ada2ef45ae523806b0745f7a78e89d1b5fb1951de90e1a"
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "3.1.0"
boolean_selector:
@ -70,7 +78,7 @@ packages:
description:
name: boolean_selector
sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66"
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "2.1.1"
characters:
@ -78,7 +86,7 @@ packages:
description:
name: characters
sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605"
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "1.3.0"
clock:
@ -86,7 +94,7 @@ packages:
description:
name: clock
sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "1.1.1"
collection:
@ -94,7 +102,7 @@ packages:
description:
name: collection
sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "1.18.0"
cross_file:
@ -102,7 +110,7 @@ packages:
description:
name: cross_file
sha256: "7caf6a750a0c04effbb52a676dce9a4a592e10ad35c34d6d2d0e4811160d5670"
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "0.3.4+2"
crypto:
@ -110,7 +118,7 @@ packages:
description:
name: crypto
sha256: "1e445881f28f22d6140f181e07737b22f1e099a5e1ff94b0af2f9e4a463f4855"
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "3.0.6"
cupertino_icons:
@ -118,7 +126,7 @@ packages:
description:
name: cupertino_icons
sha256: ba631d1c7f7bef6b729a622b7b752645a2d076dba9976925b8f25725a30e1ee6
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "1.0.8"
dio:
@ -126,7 +134,7 @@ packages:
description:
name: dio
sha256: "5598aa796bbf4699afd5c67c0f5f6e2ed542afc956884b9cd58c306966efc260"
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "5.7.0"
dio_web_adapter:
@ -134,7 +142,7 @@ packages:
description:
name: dio_web_adapter
sha256: "33259a9276d6cea88774a0000cfae0d861003497755969c92faa223108620dc8"
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "2.0.0"
fake_async:
@ -142,7 +150,7 @@ packages:
description:
name: fake_async
sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78"
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "1.3.1"
ffi:
@ -150,7 +158,7 @@ packages:
description:
name: ffi
sha256: "16ed7b077ef01ad6170a3d0c57caa4a112a38d7a2ed5602e0aca9ca6f3d98da6"
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "2.1.3"
file:
@ -158,7 +166,7 @@ packages:
description:
name: file
sha256: a3b4f84adafef897088c160faf7dfffb7696046cb13ae90b508c2cbc95d3b8d4
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "7.0.1"
file_picker:
@ -166,23 +174,23 @@ packages:
description:
name: file_picker
sha256: "1bbf65dd997458a08b531042ec3794112a6c39c07c37ff22113d2e7e4f81d4e4"
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "6.2.1"
file_selector_linux:
dependency: transitive
description:
name: file_selector_linux
sha256: "712ce7fab537ba532c8febdb1a8f167b32441e74acd68c3ccb2e36dcb52c4ab2"
url: "https://pub.flutter-io.cn"
sha256: b2b91daf8a68ecfa4a01b778a6f52edef9b14ecd506e771488ea0f2e0784198b
url: "https://pub.dev"
source: hosted
version: "0.9.3"
version: "0.9.3+1"
file_selector_macos:
dependency: transitive
description:
name: file_selector_macos
sha256: "271ab9986df0c135d45c3cdb6bd0faa5db6f4976d3e4b437cf7d0f258d941bfc"
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "0.9.4+2"
file_selector_platform_interface:
@ -190,7 +198,7 @@ packages:
description:
name: file_selector_platform_interface
sha256: a3994c26f10378a039faa11de174d7b78eb8f79e4dd0af2a451410c1a5c3f66b
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "2.6.2"
file_selector_windows:
@ -198,7 +206,7 @@ packages:
description:
name: file_selector_windows
sha256: "8f5d2f6590d51ecd9179ba39c64f722edc15226cc93dcc8698466ad36a4a85a4"
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "0.9.3+3"
fixnum:
@ -206,7 +214,7 @@ packages:
description:
name: fixnum
sha256: b6dc7065e46c974bc7c5f143080a6764ec7a4be6da1285ececdc37be96de53be
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "1.1.1"
flutter:
@ -219,7 +227,7 @@ packages:
description:
name: flutter_lints
sha256: a25a15ebbdfc33ab1cd26c63a6ee519df92338a9c10f122adda92938253bef04
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "2.0.3"
flutter_plugin_android_lifecycle:
@ -227,7 +235,7 @@ packages:
description:
name: flutter_plugin_android_lifecycle
sha256: "9b78450b89f059e96c9ebb355fa6b3df1d6b330436e0b885fb49594c41721398"
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "2.0.23"
flutter_swiper_view:
@ -235,7 +243,7 @@ packages:
description:
name: flutter_swiper_view
sha256: "2a165b259e8a4c49d4da5626b967ed42a73dac2d075bd9e266ad8d23b9f01879"
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "1.1.8"
flutter_test:
@ -253,7 +261,7 @@ packages:
description:
name: get
sha256: e4e7335ede17452b391ed3b2ede016545706c01a02292a6c97619705e7d2a85e
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "4.6.6"
get_storage:
@ -261,7 +269,7 @@ packages:
description:
name: get_storage
sha256: "39db1fffe779d0c22b3a744376e86febe4ade43bf65e06eab5af707dc84185a2"
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "2.1.1"
http:
@ -269,7 +277,7 @@ packages:
description:
name: http
sha256: b9c29a161230ee03d3ccf545097fccd9b87a5264228c5d348202e0f0c28f9010
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "1.2.2"
http_parser:
@ -277,7 +285,7 @@ packages:
description:
name: http_parser
sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b"
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "4.0.2"
image_picker:
@ -285,7 +293,7 @@ packages:
description:
name: image_picker
sha256: "021834d9c0c3de46bf0fe40341fa07168407f694d9b2bb18d532dc1261867f7a"
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "1.1.2"
image_picker_android:
@ -293,7 +301,7 @@ packages:
description:
name: image_picker_android
sha256: "8faba09ba361d4b246dc0a17cb4289b3324c2b9f6db7b3d457ee69106a86bd32"
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "0.8.12+17"
image_picker_for_web:
@ -301,7 +309,7 @@ packages:
description:
name: image_picker_for_web
sha256: "717eb042ab08c40767684327be06a5d8dbb341fe791d514e4b92c7bbe1b7bb83"
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "3.0.6"
image_picker_ios:
@ -309,7 +317,7 @@ packages:
description:
name: image_picker_ios
sha256: "4f0568120c6fcc0aaa04511cb9f9f4d29fc3d0139884b1d06be88dcec7641d6b"
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "0.8.12+1"
image_picker_linux:
@ -317,7 +325,7 @@ packages:
description:
name: image_picker_linux
sha256: "4ed1d9bb36f7cd60aa6e6cd479779cc56a4cb4e4de8f49d487b1aaad831300fa"
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "0.2.1+1"
image_picker_macos:
@ -325,7 +333,7 @@ packages:
description:
name: image_picker_macos
sha256: "3f5ad1e8112a9a6111c46d0b57a7be2286a9a07fc6e1976fdf5be2bd31d4ff62"
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "0.2.1+1"
image_picker_platform_interface:
@ -333,7 +341,7 @@ packages:
description:
name: image_picker_platform_interface
sha256: "9ec26d410ff46f483c5519c29c02ef0e02e13a543f882b152d4bfd2f06802f80"
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "2.10.0"
image_picker_windows:
@ -341,7 +349,7 @@ packages:
description:
name: image_picker_windows
sha256: "6ad07afc4eb1bc25f3a01084d28520496c4a3bb0cb13685435838167c9dcedeb"
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "0.2.1+1"
js:
@ -349,15 +357,39 @@ packages:
description:
name: js
sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "0.6.7"
just_audio:
dependency: "direct main"
description:
name: just_audio
sha256: a49e7120b95600bd357f37a2bb04cd1e88252f7cdea8f3368803779b925b1049
url: "https://pub.dev"
source: hosted
version: "0.9.42"
just_audio_platform_interface:
dependency: transitive
description:
name: just_audio_platform_interface
sha256: "0243828cce503c8366cc2090cefb2b3c871aa8ed2f520670d76fd47aa1ab2790"
url: "https://pub.dev"
source: hosted
version: "4.3.0"
just_audio_web:
dependency: transitive
description:
name: just_audio_web
sha256: "9a98035b8b24b40749507687520ec5ab404e291d2b0937823ff45d92cb18d448"
url: "https://pub.dev"
source: hosted
version: "0.4.13"
leak_tracker:
dependency: transitive
description:
name: leak_tracker
sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05"
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "10.0.5"
leak_tracker_flutter_testing:
@ -365,7 +397,7 @@ packages:
description:
name: leak_tracker_flutter_testing
sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806"
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "3.0.5"
leak_tracker_testing:
@ -373,7 +405,7 @@ packages:
description:
name: leak_tracker_testing
sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3"
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "3.0.1"
lints:
@ -381,7 +413,7 @@ packages:
description:
name: lints
sha256: "0a217c6c989d21039f1498c3ed9f3ed71b354e69873f13a8dfc3c9fe76f1b452"
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "2.1.1"
matcher:
@ -389,7 +421,7 @@ packages:
description:
name: matcher
sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "0.12.16+1"
material_color_utilities:
@ -397,7 +429,7 @@ packages:
description:
name: material_color_utilities
sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "0.11.1"
meta:
@ -405,7 +437,7 @@ packages:
description:
name: meta
sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "1.15.0"
mime:
@ -413,7 +445,7 @@ packages:
description:
name: mime
sha256: "41a20518f0cb1256669420fdba0cd90d21561e560ac240f26ef8322e45bb7ed6"
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "2.0.0"
nested:
@ -421,7 +453,7 @@ packages:
description:
name: nested
sha256: "03bac4c528c64c95c722ec99280375a6f2fc708eec17c7b3f07253b626cd2a20"
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "1.0.0"
path:
@ -429,23 +461,23 @@ packages:
description:
name: path
sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af"
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "1.9.0"
path_provider:
dependency: transitive
description:
name: path_provider
sha256: fec0d61223fba3154d87759e3cc27fe2c8dc498f6386c6d6fc80d1afdd1bf378
url: "https://pub.flutter-io.cn"
sha256: "50c5dd5b6e1aaf6fb3a78b33f6aa3afca52bf903a8a5298f53101fdaee55bbcd"
url: "https://pub.dev"
source: hosted
version: "2.1.4"
version: "2.1.5"
path_provider_android:
dependency: transitive
description:
name: path_provider_android
sha256: c464428172cb986b758c6d1724c603097febb8fb855aa265aeecc9280c294d4a
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "2.2.12"
path_provider_foundation:
@ -453,7 +485,7 @@ packages:
description:
name: path_provider_foundation
sha256: f234384a3fdd67f989b4d54a5d73ca2a6c422fa55ae694381ae0f4375cd1ea16
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "2.4.0"
path_provider_linux:
@ -461,7 +493,7 @@ packages:
description:
name: path_provider_linux
sha256: f7a1fe3a634fe7734c8d3f2766ad746ae2a2884abe22e241a8b301bf5cac3279
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "2.2.1"
path_provider_platform_interface:
@ -469,7 +501,7 @@ packages:
description:
name: path_provider_platform_interface
sha256: "88f5779f72ba699763fa3a3b06aa4bf6de76c8e5de842cf6f29e2e06476c2334"
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "2.1.2"
path_provider_windows:
@ -477,15 +509,63 @@ packages:
description:
name: path_provider_windows
sha256: bd6f00dbd873bfb70d0761682da2b3a2c2fccc2b9e84c495821639601d81afe7
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "2.3.0"
permission_handler:
dependency: "direct main"
description:
name: permission_handler
sha256: "18bf33f7fefbd812f37e72091a15575e72d5318854877e0e4035a24ac1113ecb"
url: "https://pub.dev"
source: hosted
version: "11.3.1"
permission_handler_android:
dependency: transitive
description:
name: permission_handler_android
sha256: "71bbecfee799e65aff7c744761a57e817e73b738fedf62ab7afd5593da21f9f1"
url: "https://pub.dev"
source: hosted
version: "12.0.13"
permission_handler_apple:
dependency: transitive
description:
name: permission_handler_apple
sha256: e6f6d73b12438ef13e648c4ae56bd106ec60d17e90a59c4545db6781229082a0
url: "https://pub.dev"
source: hosted
version: "9.4.5"
permission_handler_html:
dependency: transitive
description:
name: permission_handler_html
sha256: af26edbbb1f2674af65a8f4b56e1a6f526156bc273d0e65dd8075fab51c78851
url: "https://pub.dev"
source: hosted
version: "0.1.3+2"
permission_handler_platform_interface:
dependency: transitive
description:
name: permission_handler_platform_interface
sha256: e9c8eadee926c4532d0305dff94b85bf961f16759c3af791486613152af4b4f9
url: "https://pub.dev"
source: hosted
version: "4.2.3"
permission_handler_windows:
dependency: transitive
description:
name: permission_handler_windows
sha256: "1a790728016f79a41216d88672dbc5df30e686e811ad4e698bfc51f76ad91f1e"
url: "https://pub.dev"
source: hosted
version: "0.2.1"
platform:
dependency: transitive
description:
name: platform
sha256: "5d6b1b0036a5f331ebc77c850ebc8506cbc1e9416c27e59b439f917a902a4984"
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "3.1.6"
plugin_platform_interface:
@ -493,7 +573,7 @@ packages:
description:
name: plugin_platform_interface
sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02"
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "2.1.8"
provider:
@ -501,9 +581,73 @@ packages:
description:
name: provider
sha256: c8a055ee5ce3fd98d6fc872478b03823ffdb448699c6ebdbbc71d59b596fd48c
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "6.1.2"
rxdart:
dependency: transitive
description:
name: rxdart
sha256: "5c3004a4a8dbb94bd4bf5412a4def4acdaa12e12f269737a5751369e12d1a962"
url: "https://pub.dev"
source: hosted
version: "0.28.0"
shared_preferences:
dependency: "direct main"
description:
name: shared_preferences
sha256: "95f9997ca1fb9799d494d0cb2a780fd7be075818d59f00c43832ed112b158a82"
url: "https://pub.dev"
source: hosted
version: "2.3.3"
shared_preferences_android:
dependency: transitive
description:
name: shared_preferences_android
sha256: "3b9febd815c9ca29c9e3520d50ec32f49157711e143b7a4ca039eb87e8ade5ab"
url: "https://pub.dev"
source: hosted
version: "2.3.3"
shared_preferences_foundation:
dependency: transitive
description:
name: shared_preferences_foundation
sha256: "07e050c7cd39bad516f8d64c455f04508d09df104be326d8c02551590a0d513d"
url: "https://pub.dev"
source: hosted
version: "2.5.3"
shared_preferences_linux:
dependency: transitive
description:
name: shared_preferences_linux
sha256: "580abfd40f415611503cae30adf626e6656dfb2f0cee8f465ece7b6defb40f2f"
url: "https://pub.dev"
source: hosted
version: "2.4.1"
shared_preferences_platform_interface:
dependency: transitive
description:
name: shared_preferences_platform_interface
sha256: "57cbf196c486bc2cf1f02b85784932c6094376284b3ad5779d1b1c6c6a816b80"
url: "https://pub.dev"
source: hosted
version: "2.4.1"
shared_preferences_web:
dependency: transitive
description:
name: shared_preferences_web
sha256: d2ca4132d3946fec2184261726b355836a82c33d7d5b67af32692aff18a4684e
url: "https://pub.dev"
source: hosted
version: "2.4.2"
shared_preferences_windows:
dependency: transitive
description:
name: shared_preferences_windows
sha256: "94ef0f72b2d71bc3e700e025db3710911bd51a71cefb65cc609dd0d9a982e3c1"
url: "https://pub.dev"
source: hosted
version: "2.4.1"
sky_engine:
dependency: transitive
description: flutter
@ -514,7 +658,7 @@ packages:
description:
name: source_span
sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c"
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "1.10.0"
sprintf:
@ -522,7 +666,7 @@ packages:
description:
name: sprintf
sha256: "1fc9ffe69d4df602376b52949af107d8f5703b77cda567c4d7d86a0693120f23"
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "7.0.0"
stack_trace:
@ -530,7 +674,7 @@ packages:
description:
name: stack_trace
sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b"
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "1.11.1"
stream_channel:
@ -538,7 +682,7 @@ packages:
description:
name: stream_channel
sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "2.1.2"
string_scanner:
@ -546,7 +690,7 @@ packages:
description:
name: string_scanner
sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde"
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "1.2.0"
synchronized:
@ -554,7 +698,7 @@ packages:
description:
name: synchronized
sha256: "69fe30f3a8b04a0be0c15ae6490fc859a78ef4c43ae2dd5e8a623d45bfcf9225"
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "3.3.0+3"
term_glyph:
@ -562,7 +706,7 @@ packages:
description:
name: term_glyph
sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "1.2.1"
test_api:
@ -570,7 +714,7 @@ packages:
description:
name: test_api
sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb"
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "0.7.2"
typed_data:
@ -578,7 +722,7 @@ packages:
description:
name: typed_data
sha256: f9049c039ebfeb4cf7a7104a675823cd72dba8297f264b6637062516699fa006
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "1.4.0"
uuid:
@ -586,7 +730,7 @@ packages:
description:
name: uuid
sha256: a5be9ef6618a7ac1e964353ef476418026db906c4facdedaa299b7a2e71690ff
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "4.5.1"
vector_math:
@ -594,7 +738,7 @@ packages:
description:
name: vector_math
sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803"
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "2.1.4"
vm_service:
@ -602,7 +746,7 @@ packages:
description:
name: vm_service
sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d"
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "14.2.5"
web:
@ -610,23 +754,23 @@ packages:
description:
name: web
sha256: cd3543bd5798f6ad290ea73d210f423502e71900302dde696f8bff84bf89a1cb
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "1.1.0"
win32:
dependency: "direct main"
description:
name: win32
sha256: e1d0cc62e65dc2561f5071fcbccecf58ff20c344f8f3dc7d4922df372a11df1f
url: "https://pub.flutter-io.cn"
sha256: "84ba388638ed7a8cb3445a320c8273136ab2631cd5f2c57888335504ddab1bc2"
url: "https://pub.dev"
source: hosted
version: "5.7.1"
version: "5.8.0"
xdg_directories:
dependency: transitive
description:
name: xdg_directories
sha256: "7a3f37b05d989967cdddcbb571f1ea834867ae2faa29725fd085180e0883aa15"
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "1.1.0"
sdks:

@ -30,10 +30,12 @@ environment:
dependencies:
flutter:
sdk: flutter
win32: ^5.1.0
win32: ^5.7.1
flutter_swiper_view: 1.1.8
audioplayers: ^5.2.1
permission_handler: ^11.0.1
just_audio: ^0.9.34
shared_preferences: ^2.2.0
# The following adds the Cupertino Icons font to your application.

@ -10,6 +10,11 @@ include(${EPHEMERAL_DIR}/generated_config.cmake)
# https://github.com/flutter/flutter/issues/57146.
set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper")
# Set fallback configurations for older versions of the flutter tool.
if (NOT DEFINED FLUTTER_TARGET_PLATFORM)
set(FLUTTER_TARGET_PLATFORM "windows-x64")
endif()
# === Flutter Library ===
set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll")
@ -92,7 +97,7 @@ add_custom_command(
COMMAND ${CMAKE_COMMAND} -E env
${FLUTTER_TOOL_ENVIRONMENT}
"${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat"
windows-x64 $<CONFIG>
${FLUTTER_TARGET_PLATFORM} $<CONFIG>
VERBATIM
)
add_custom_target(flutter_assemble DEPENDS

@ -8,10 +8,13 @@
#include <audioplayers_windows/audioplayers_windows_plugin.h>
#include <file_selector_windows/file_selector_windows.h>
#include <permission_handler_windows/permission_handler_windows_plugin.h>
void RegisterPlugins(flutter::PluginRegistry* registry) {
AudioplayersWindowsPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("AudioplayersWindowsPlugin"));
FileSelectorWindowsRegisterWithRegistrar(
registry->GetRegistrarForPlugin("FileSelectorWindows"));
PermissionHandlerWindowsPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("PermissionHandlerWindowsPlugin"));
}

@ -5,6 +5,7 @@
list(APPEND FLUTTER_PLUGIN_LIST
audioplayers_windows
file_selector_windows
permission_handler_windows
)
list(APPEND FLUTTER_FFI_PLUGIN_LIST

Loading…
Cancel
Save