导入'package:flutter / material.dart';
class MusicApp扩展了StatefulWidget {MusicApp({Key key}):super(key:key);
@@ override _MusicAppState createState()=> _MusicAppState(); }
class _MusicAppState扩展状态{字符串开始;布尔checkStart;地图cycleMap = {1:“ C”,2:“ C#”,3:“ D”,4:“ D#”,5:“ E”,6:“ F”,7:“ F#”,8:“ G”,9:“ G#”,10:“ A”,11:“ A#”,12:“ B”};映射cycleeMap2;
列表周期= [“C”,“C#”,“ D”,“ D#”,“ E”,“F”,“F#”,“G”,“G#”,“一种”,“ A#”];
字符串歌词=“ \ nMalai nasodh kaha dukcha ghau \ n \ nma je chu thikai chu bitholna naaaua”;
弦和=“ F G G#G#B#F D#C A#F”;字符串chutia =“ Chutia”;列出doubleCycle;弦和弦变化; @override void initState(){super.initState();doubleCycle =周期+周期;cycleeMap2 = cycleMap;
chordsChange = "${cycleMap[6]} ${cycleMap[9]} ${cycleMap[10]} ${cycleMap[10]} ${cycleMap[12]} ${cycleMap[6]}\n\n
$ {cycleMap [12]} C A#F“;}
@@ override Widget build(BuildContext context){//以for(var i = 0; i
return ListView( children: <Widget>[ // Stack( // children: <Widget>[Text(chordsChange), Text(lyrics)], // ), FlatButton( child: Text("C"), onPressed: () { setState(() { doEverything(); }); }, ), Text(chordsChange), ], ); }
//对于第一个和弦,以获取数组int中的transposeIndex值transposeValue(String firstChord,String transposeTo){int i = cycle.indexOf(firstChord)+1;
int transposeIndex = 0; String transposeValue; do { transposeValue = doubleCycle[i]; transposeIndex++; if (transposeValue == transposeTo) { break; } i++; } while (i <= doubleCycle.length - 1); return transposeIndex; }
//对于每个和弦,从上方导航到transposeIndex函数String newChord(int transposeIndex,StringcurrentCycleValue){int i,计数器= 0;字符串transposeCycleValue;对于(i = cycle.indexOf(currentCycleValue)+1;i <= doubleCycle.length-1;i ++){计数器+ = 1;if(counter == transposeIndex){transposeCycleValue = doubleCycle [i];
break; } } return transposeCycleValue; }
void doEverything(){int transposeValueIndex = transposeValue(start,“ C#”);cycleeMap2.forEach((i,和弦){字符串newValue = newChord(transposeValueIndex,和弦);cycleMap [i] = newValue;}); }}
不知道您要做什么,但我能发现的第一个错误是
class _MusicAppState extends State
应该是
class _MusicAppState extends State<MusicApp>