【Flutter】別ファイルの変数を参照して画面を更新したい。

dart

1import 'package:flutter/material.dart';2import 'package:nmusic_new/addmusic.dart';3import 'colors.dart';4 5class AllTracks extends StatefulWidget {6 const AllTracks({super.key});7 8 9 // ignore: library_private_types_in_public_api10 AllTracksState createState() => AllTracksState();11}12 13class AllTracksState extends State<AllTracks> {14 List<ListTile> listTiles = [];15 16 17 Widget build(BuildContext context) {18 return Scaffold(19 backgroundColor: NMusicColors.bg,20 appBar: AppBar(21 backgroundColor: NMusicColors.bg,22 title: const Text(23 "All Tracks",24 style: TextStyle(color: NMusicColors.text),25 ),26 ),27 body: Column(28 children: [29 Row(30 children: [31 Padding(32 padding: const EdgeInsets.fromLTRB(4, 4, 4, 4),33 child: ElevatedButton(34 style: ElevatedButton.styleFrom(35 shape: RoundedRectangleBorder(36 borderRadius: BorderRadius.circular(25)),37 backgroundColor: NMusicColors.buttonbg),38 onPressed: () {},39 child: const Row(40 children: [41 Icon(42 Icons.play_arrow_rounded,43 color: NMusicColors.buttontext,44 ),45 Text(46 "Play all",47 style: TextStyle(color: NMusicColors.buttontext),48 )49 ],50 )),51 ),52 ElevatedButton(53 style: ElevatedButton.styleFrom(54 shape: RoundedRectangleBorder(55 borderRadius: BorderRadius.circular(25)),56 backgroundColor: NMusicColors.buttonbg),57 onPressed: () {},58 child: const Row(59 children: [60 Icon(61 Icons.shuffle,62 color: NMusicColors.buttontext,63 ),64 Text(65 "Shuffle",66 style: TextStyle(color: NMusicColors.buttontext),67 )68 ],69 )),70 ],71 ),72 ],73 ),74 );75 }76 77 void AddListTile(musicName) {78 listTiles.add(79 ListTile(80 tileColor: NMusicColors.tilebutton,81 leading: const Column(82 mainAxisAlignment: MainAxisAlignment.center,83 children: [84 Icon(85 Icons.music_note,86 color: NMusicColors.text,87 size: 35,88 ),89 ],90 ),91 title: Text(92 musicName.toString(),93 style: const TextStyle(color: NMusicColors.text),94 ),95 onTap: () {},96 ),97 );98 99 setState(() {});100 }101}

コメントを投稿

0 コメント