Skip to content

Commit c20e41d

Browse files
committed
Add keys
1 parent c04a618 commit c20e41d

File tree

4 files changed

+13
-9
lines changed

4 files changed

+13
-9
lines changed

lib/src/audio_list.dart

+10-1
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,14 @@ class AudioList extends StatefulWidget {
1212
}
1313

1414
class _AudioListState extends State<AudioList> {
15+
List<FileSystemEntity> data = [];
16+
1517
@override
1618
Widget build(BuildContext context) {
1719
return FutureBuilder<List<FileSystemEntity>>(
20+
key: const ValueKey("futureBuilder"),
1821
future: fetchAudioFiles(),
22+
initialData: data,
1923
builder: (context, AsyncSnapshot<List<FileSystemEntity>> snapshot) {
2024
if (snapshot.connectionState == ConnectionState.active ||
2125
snapshot.connectionState == ConnectionState.waiting) {
@@ -24,12 +28,17 @@ class _AudioListState extends State<AudioList> {
2428
);
2529
}
2630
if (snapshot.hasData) {
31+
data = snapshot.data!;
2732
return ListView.builder(
33+
key: const ValueKey("ListBuilder"),
2834
reverse: true,
2935
padding: const EdgeInsets.symmetric(vertical: 15),
3036
itemCount: snapshot.data?.length,
3137
itemBuilder: (BuildContext context, int index) {
32-
return AudioBubble(filepath: snapshot.data![index].path);
38+
return AudioBubble(
39+
filepath: snapshot.data![index].path,
40+
key: ValueKey(snapshot.data![index].path),
41+
);
3342
},
3443
);
3544
} else {

lib/src/home_page.dart

+3
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ class _HomePageState extends State<HomePage>
3535
@override
3636
Widget build(BuildContext context) {
3737
return Scaffold(
38+
appBar: AppBar(
39+
title: const Text("Audio Chat"),
40+
),
3841
body: Padding(
3942
padding: const EdgeInsets.all(Globals.defaultPadding),
4043
child: Column(

pubspec.lock

-7
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,6 @@ packages:
1515
url: "https://pub.dartlang.org"
1616
source: hosted
1717
version: "0.1.6+1"
18-
audio_wave:
19-
dependency: "direct main"
20-
description:
21-
name: audio_wave
22-
url: "https://pub.dartlang.org"
23-
source: hosted
24-
version: "0.1.2"
2518
boolean_selector:
2619
dependency: transitive
2720
description:

pubspec.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ dependencies:
3434
permission_handler: ^8.1.6
3535
path_provider: ^2.0.5
3636
record: ^3.0.0
37-
audio_wave: ^0.1.2
3837

3938
# The following adds the Cupertino Icons font to your application.
4039
# Use with the CupertinoIcons class for iOS style icons.

0 commit comments

Comments
 (0)