-
-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upgrade flutter to version 3.22 #49
Open
sarahzayat2019
wants to merge
2
commits into
rutvik110:master
Choose a base branch
from
sarahzayat2019:upgrade-flutter-3.22
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"flutter": "3.22.2" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ void main() { | |
} | ||
|
||
class MyApp extends StatelessWidget { | ||
const MyApp({Key? key}) : super(key: key); | ||
const MyApp({super.key}); | ||
|
||
// This widget is the root of your application. | ||
@override | ||
|
@@ -27,7 +27,7 @@ class MyApp extends StatelessWidget { | |
} | ||
|
||
class WaveformsDashboard extends StatefulWidget { | ||
const WaveformsDashboard({Key? key}) : super(key: key); | ||
const WaveformsDashboard({super.key}); | ||
|
||
@override | ||
State<WaveformsDashboard> createState() => _WaveformsDashboardState(); | ||
|
@@ -36,9 +36,10 @@ class WaveformsDashboard extends StatefulWidget { | |
class _WaveformsDashboardState extends State<WaveformsDashboard> { | ||
late Duration maxDuration; | ||
late Duration elapsedDuration; | ||
late AudioCache audioPlayer; | ||
late AudioPlayer audioPlayer; | ||
late List<double> samples; | ||
double sliderValue = 0; | ||
|
||
// Change this value to number of audio samples you want. | ||
// Values between 256 and 1024 are good for showing [RectangleWaveform] and [SquigglyWaveform] | ||
// While the values above them are good for showing [PolygonWaveform] | ||
|
@@ -77,39 +78,36 @@ class _WaveformsDashboardState extends State<WaveformsDashboard> { | |
} | ||
|
||
Future<void> playAudio() async { | ||
await audioPlayer.load(audioData[1]); | ||
await audioPlayer.play(audioData[1]); | ||
await audioPlayer.setSourceAsset(audioData[1]); | ||
await audioPlayer.resume(); | ||
// maxDuration in milliseconds | ||
await Future.delayed(const Duration(milliseconds: 200)); | ||
|
||
int maxDurationInmilliseconds = | ||
await audioPlayer.fixedPlayer!.getDuration(); | ||
await audioPlayer.getDuration() | ||
.then((value) => maxDuration = value!); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not safe to bang! a better approach would be to set a default duration to 0. maxDuration = value ?? Duration.zero There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||
|
||
maxDuration = Duration(milliseconds: maxDurationInmilliseconds); | ||
} | ||
|
||
@override | ||
void initState() { | ||
// TODO: implement initState | ||
super.initState(); | ||
audioData = audioDataList[0]; | ||
audioPlayer = AudioCache( | ||
fixedPlayer: AudioPlayer(), | ||
); | ||
audioPlayer = AudioPlayer(); | ||
|
||
parseData(); | ||
|
||
samples = []; | ||
maxDuration = const Duration(milliseconds: 1000); | ||
elapsedDuration = const Duration(); | ||
|
||
audioPlayer.fixedPlayer!.onPlayerCompletion.listen((_) { | ||
audioPlayer.onPlayerComplete.listen((_) { | ||
setState(() { | ||
elapsedDuration = maxDuration; | ||
sliderValue = 1; | ||
}); | ||
}); | ||
audioPlayer.fixedPlayer!.onAudioPositionChanged.listen((Duration p) { | ||
audioPlayer.onPositionChanged.listen((Duration p) { | ||
setState(() { | ||
elapsedDuration = p; | ||
sliderValue = p.inMilliseconds / maxDuration.inMilliseconds; | ||
|
@@ -273,15 +271,16 @@ class _WaveformsDashboardState extends State<WaveformsDashboard> { | |
// await audioPlayer.fixedPlayer!.resume(); | ||
}, | ||
onChangeStart: (double value) async { | ||
await audioPlayer.fixedPlayer!.pause(); | ||
await audioPlayer.pause(); | ||
}, | ||
onChanged: (val) { | ||
setState(() { | ||
sliderValue = val; | ||
|
||
audioPlayer.fixedPlayer!.seek(Duration( | ||
audioPlayer.seek(Duration( | ||
milliseconds: | ||
(maxDuration.inMilliseconds * val).toInt())); | ||
|
||
}); | ||
}, | ||
), | ||
|
@@ -312,7 +311,7 @@ class _WaveformsDashboardState extends State<WaveformsDashboard> { | |
children: [ | ||
ElevatedButton( | ||
onPressed: () { | ||
audioPlayer.fixedPlayer!.pause(); | ||
audioPlayer.pause(); | ||
}, | ||
child: const Icon( | ||
Icons.pause, | ||
|
@@ -323,8 +322,8 @@ class _WaveformsDashboardState extends State<WaveformsDashboard> { | |
), | ||
ElevatedButton( | ||
onPressed: () async { | ||
if (audioPlayer.fixedPlayer!.state == PlayerState.PAUSED) { | ||
audioPlayer.fixedPlayer!.resume(); | ||
if (audioPlayer.state == PlayerState.paused) { | ||
audioPlayer.resume(); | ||
} else { | ||
await playAudio(); | ||
} | ||
|
@@ -338,7 +337,7 @@ class _WaveformsDashboardState extends State<WaveformsDashboard> { | |
onPressed: () { | ||
setState(() { | ||
sliderValue = 0; | ||
audioPlayer.fixedPlayer! | ||
audioPlayer | ||
.seek(const Duration(milliseconds: 0)); | ||
}); | ||
}, | ||
|
@@ -595,12 +594,12 @@ class _WaveformsDashboardState extends State<WaveformsDashboard> { | |
iconDisabledColor: Colors.white, | ||
items: const [ | ||
DropdownMenuItem( | ||
child: Text("Stroke"), | ||
value: PaintingStyle.stroke, | ||
child: Text("Stroke"), | ||
), | ||
DropdownMenuItem( | ||
child: Text("Fill"), | ||
value: PaintingStyle.fill, | ||
child: Text("Fill"), | ||
), | ||
], | ||
onChanged: (value) { | ||
|
@@ -716,12 +715,12 @@ class _WaveformsDashboardState extends State<WaveformsDashboard> { | |
|
||
class SquigglyWaveformExample extends StatelessWidget { | ||
const SquigglyWaveformExample({ | ||
Key? key, | ||
super.key, | ||
required this.maxDuration, | ||
required this.elapsedDuration, | ||
required this.samples, | ||
required this.waveformCustomizations, | ||
}) : super(key: key); | ||
}); | ||
|
||
final Duration maxDuration; | ||
final Duration elapsedDuration; | ||
|
@@ -748,12 +747,12 @@ class SquigglyWaveformExample extends StatelessWidget { | |
|
||
class CurvedPolgonWaveformExample extends StatelessWidget { | ||
const CurvedPolgonWaveformExample({ | ||
Key? key, | ||
super.key, | ||
required this.maxDuration, | ||
required this.elapsedDuration, | ||
required this.samples, | ||
required this.waveformCustomizations, | ||
}) : super(key: key); | ||
}); | ||
|
||
final Duration maxDuration; | ||
final Duration elapsedDuration; | ||
|
@@ -781,12 +780,12 @@ class CurvedPolgonWaveformExample extends StatelessWidget { | |
|
||
class RectangleWaveformExample extends StatelessWidget { | ||
const RectangleWaveformExample({ | ||
Key? key, | ||
super.key, | ||
required this.maxDuration, | ||
required this.elapsedDuration, | ||
required this.samples, | ||
required this.waveformCustomizations, | ||
}) : super(key: key); | ||
}); | ||
|
||
final Duration maxDuration; | ||
final Duration elapsedDuration; | ||
|
@@ -819,12 +818,12 @@ class RectangleWaveformExample extends StatelessWidget { | |
|
||
class PolygonWaveformExample extends StatelessWidget { | ||
const PolygonWaveformExample({ | ||
Key? key, | ||
super.key, | ||
required this.maxDuration, | ||
required this.elapsedDuration, | ||
required this.samples, | ||
required this.waveformCustomizations, | ||
}) : super(key: key); | ||
}); | ||
|
||
final Duration maxDuration; | ||
final Duration elapsedDuration; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not safe to bang! A better approach would be to set the default value to 0.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed