Skip to content

Commit ba38a34

Browse files
- fix: replacing useProvider with useStream, avoiding exception "Bad state: Stream has already been listened to." on console.dart
- fix: crash on search bar when there aren't results - cleaned code on version_install_button.dart and app_bottom_bar.dart
1 parent f8a5c63 commit ba38a34

File tree

7 files changed

+23
-24
lines changed

7 files changed

+23
-24
lines changed

lib/src/components/atoms/console.dart

+6-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import 'package:flutter/cupertino.dart';
22
import 'package:flutter/material.dart';
33
import 'package:flutter_hooks/flutter_hooks.dart';
44
import 'package:flutter_spinkit/flutter_spinkit.dart';
5-
import 'package:hooks_riverpod/hooks_riverpod.dart';
65
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
76

87
import '../../modules/fvm/fvm.provider.dart';
@@ -21,11 +20,11 @@ class Console extends HookWidget {
2120

2221
@override
2322
Widget build(BuildContext context) {
24-
final output = useProvider(fvmStdoutProvider);
23+
final output = useStream(fvmStdoutProvider);
2524
final lines = useState<List<String>>(['']);
2625

2726
useValueChanged(output, (_, __) {
28-
lines.value.insert(0, output.data.value);
27+
lines.value.insert(0, output.data);
2928
if (lines.value.length > 100) {
3029
lines.value.removeAt(lines.value.length - 1);
3130
}
@@ -65,7 +64,10 @@ class Console extends HookWidget {
6564
mainAxisAlignment: MainAxisAlignment.start,
6665
crossAxisAlignment: CrossAxisAlignment.center,
6766
children: [
68-
ConsoleText(lines.value.first),
67+
Container(
68+
width: MediaQuery.of(context).size.width - 100,
69+
child: ConsoleText(lines.value.first)
70+
),
6971
],
7072
),
7173
),

lib/src/components/atoms/sliver_header_delegate.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class SliverHeaderDelegate extends SliverPersistentHeaderDelegate {
4141
),
4242
trailing: Text(
4343
I18Next.of(context).t('components:atoms.countFound', variables: {
44-
'count': count.toString(),
44+
'count': count,
4545
}),
4646
),
4747
onTap: onPress,

lib/src/components/molecules/version_install_button.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class VersionInstallButton extends HookWidget {
8989
child: Opacity(
9090
opacity: (version?.isCached ?? false) ? 0.3 : 1,
9191
child: IconButton(
92-
onPressed: (version?.isCached ?? false) ? onInstall : onInstall,
92+
onPressed: onInstall,
9393
splashRadius: 20,
9494
icon: Tooltip(
9595
message:

lib/src/components/organisms/app_bottom_bar.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class AppBottomBar extends HookWidget {
1717
expand.value = !expand.value;
1818
}
1919

20-
if (processing == false) {
20+
if (!processing) {
2121
return Container(height: 0);
2222
}
2323

lib/src/modules/fvm/fvm.provider.dart

+8-11
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,11 @@ class FvmCacheProvider extends StateNotifier<List<CacheVersion>> {
119119
}
120120
}
121121

122-
final fvmStdoutProvider = StreamProvider.autoDispose((ref) {
123-
return StreamGroup.merge([
124-
FVMClient.console.stdout.stream,
125-
FVMClient.console.stderr.stream,
126-
FVMClient.console.warning.stream,
127-
FVMClient.console.info.stream,
128-
FVMClient.console.fine.stream,
129-
FVMClient.console.error.stream,
130-
]).transform(utf8.decoder);
131-
// .transform(const LineSplitter())
132-
});
122+
final fvmStdoutProvider = StreamGroup.mergeBroadcast([
123+
FVMClient.console.stdout.stream,
124+
FVMClient.console.stderr.stream,
125+
FVMClient.console.warning.stream,
126+
FVMClient.console.info.stream,
127+
FVMClient.console.fine.stream,
128+
FVMClient.console.error.stream,
129+
]).transform(utf8.decoder);

macos/Podfile.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,4 @@ SPEC CHECKSUMS:
4343

4444
PODFILE CHECKSUM: 6eac6b3292e5142cfc23bdeb71848a40ec51c14c
4545

46-
COCOAPODS: 1.10.1
46+
COCOAPODS: 1.11.0

pubspec.lock

+5-5
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ packages:
4242
name: async
4343
url: "https://pub.dartlang.org"
4444
source: hosted
45-
version: "2.8.1"
45+
version: "2.8.2"
4646
boolean_selector:
4747
dependency: transitive
4848
description:
@@ -119,7 +119,7 @@ packages:
119119
name: characters
120120
url: "https://pub.dartlang.org"
121121
source: hosted
122-
version: "1.1.0"
122+
version: "1.2.0"
123123
charcode:
124124
dependency: transitive
125125
description:
@@ -491,7 +491,7 @@ packages:
491491
name: matcher
492492
url: "https://pub.dartlang.org"
493493
source: hosted
494-
version: "0.12.10"
494+
version: "0.12.11"
495495
material_design_icons_flutter:
496496
dependency: "direct main"
497497
description:
@@ -825,7 +825,7 @@ packages:
825825
name: test_api
826826
url: "https://pub.dartlang.org"
827827
source: hosted
828-
version: "0.4.2"
828+
version: "0.4.3"
829829
timing:
830830
dependency: transitive
831831
description:
@@ -902,7 +902,7 @@ packages:
902902
name: vector_math
903903
url: "https://pub.dartlang.org"
904904
source: hosted
905-
version: "2.1.0"
905+
version: "2.1.1"
906906
watcher:
907907
dependency: "direct main"
908908
description:

0 commit comments

Comments
 (0)