Skip to content

Commit 8821665

Browse files
author
Maxeem
committed
fix: upgrade fluent_ui usage to 3.6.0 because on Flutter >= 2.8 old fluent_ui 1.8.1 didn't work anymore
1 parent 1d6a8e5 commit 8821665

File tree

3 files changed

+50
-115
lines changed

3 files changed

+50
-115
lines changed

lib/windows_search_delegate.dart

Lines changed: 22 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -1,121 +1,41 @@
11
import 'package:fluent_ui/fluent_ui.dart' as fluent;
2-
import 'package:fluent_ui/fluent_ui.dart';
32
import 'package:flutter/widgets.dart';
43
import 'package:flutter_search_bar/main.dart';
54
import 'package:flutter_search_bar/platform_search.dart';
65

6+
final _kPlatformNames = [...platforms.map((element) => element.name)]; // map cuz AutoSuggestBox works with Strings
7+
8+
final _autoSuggestBoxKey = GlobalKey(); // use the key to keep the state of the AutoSuggestBox
9+
710
class WindowsSearchDelegate extends AbstractPlatformSearchDelegate {
811
final List<PlatformItem> Function(String text) search;
12+
913
WindowsSearchDelegate(this.search);
1014

11-
Widget buildResults(BuildContext context) {
12-
return ListView.builder(
13-
itemCount: 10,
14-
itemBuilder: (context, index) {
15-
return Row(
16-
children: [
17-
Padding(
18-
padding: const EdgeInsets.all(8.0),
19-
child: Text('Item $index'),
20-
),
21-
],
22-
);
23-
},
24-
);
25-
}
15+
@override
16+
Widget buildResults(BuildContext context) => throw UnimplementedError();
2617

2718
@override
28-
Widget buildSuggestions(BuildContext context) {
29-
return ListView.builder(
30-
itemCount: 10,
31-
itemBuilder: (context, index) {
32-
return Row(
33-
children: [
34-
Padding(
35-
padding: const EdgeInsets.all(8.0),
36-
child: Text('Item $index'),
37-
),
38-
],
39-
);
40-
},
41-
);
42-
}
19+
Widget buildSuggestions(BuildContext context) => throw UnimplementedError();
4320

4421
@override
4522
Widget buildScaffold(Widget? body, BuildContext context) {
46-
const BorderSide _kDefaultRoundedBorderSide = BorderSide(
47-
style: BorderStyle.solid,
48-
width: 0.8,
49-
);
50-
return fluent.Scaffold(
51-
left: NavigationPanel(
52-
currentIndex: 2,
53-
menu: NavigationPanelMenuItem(
54-
icon: IconButton(
55-
icon: fluent.Icon(Icons.menu),
56-
onPressed: () {},
57-
),
58-
),
59-
items: [
60-
NavigationPanelSectionHeader(
61-
header: fluent.AutoSuggestBox<PlatformItem>(
62-
onSelected: (PlatformItem item) => print(item.name),
63-
controller: queryTextController,
64-
sorter: (String text, List items) => search.call(text),
65-
items: platforms,
66-
noResultsFound: (context) => ListTile(
67-
title: DefaultTextStyle(
68-
style: TextStyle(
69-
fontWeight: FontWeight.normal, color: Colors.black),
70-
child: Text('No results found'),
71-
),
72-
),
73-
itemBuilder: (context, item) {
74-
return PlatformItemWidget(
75-
item,
76-
small: true,
77-
);
78-
},
79-
textBoxBuilder: (context, controller, fn, key) => TextBox(
80-
key: key,
81-
controller: controller,
82-
focusNode: fn,
83-
suffixMode: OverlayVisibilityMode.always,
84-
suffix: fluent.Row(
85-
children: [
86-
controller.text.isNotEmpty
87-
? IconButton(
88-
icon: fluent.Icon(Icons.close),
89-
onPressed: () {
90-
controller.clear();
91-
fn.unfocus();
92-
},
93-
)
94-
: fluent.SizedBox.shrink(),
95-
IconButton(
96-
icon: fluent.Icon(Icons.search),
97-
onPressed: () {},
98-
),
99-
],
100-
),
101-
placeholder: searchFieldLabel,
102-
decoration: BoxDecoration(
103-
color: Colors.white,
104-
border: Border(
105-
top: _kDefaultRoundedBorderSide,
106-
bottom: _kDefaultRoundedBorderSide,
107-
left: _kDefaultRoundedBorderSide,
108-
right: _kDefaultRoundedBorderSide,
109-
),
110-
borderRadius: fn.hasFocus
111-
? BorderRadius.vertical(top: Radius.circular(3.0))
112-
: BorderRadius.all(Radius.circular(3.0)),
113-
),
23+
return fluent.ScaffoldPage(
24+
content: Padding(
25+
padding: EdgeInsets.symmetric(horizontal: 16, vertical: 32),
26+
child: Column(
27+
children: [
28+
fluent.AutoSuggestBox<String>(
29+
key: _autoSuggestBoxKey,
30+
placeholder: 'Search',
31+
onSelected: (item) => print(item),
32+
controller: queryTextController,
33+
items: _kPlatformNames,
11434
),
115-
)),
116-
],
35+
Spacer(),
36+
],
37+
),
11738
),
118-
body: Container(),
11939
);
12040
}
12141
}

pubspec.lock

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ packages:
77
name: async
88
url: "https://pub.dartlang.org"
99
source: hosted
10-
version: "2.5.0"
10+
version: "2.8.2"
1111
boolean_selector:
1212
dependency: transitive
1313
description:
@@ -21,14 +21,14 @@ packages:
2121
name: characters
2222
url: "https://pub.dartlang.org"
2323
source: hosted
24-
version: "1.1.0"
24+
version: "1.2.0"
2525
charcode:
2626
dependency: transitive
2727
description:
2828
name: charcode
2929
url: "https://pub.dartlang.org"
3030
source: hosted
31-
version: "1.2.0"
31+
version: "1.3.1"
3232
clock:
3333
dependency: transitive
3434
description:
@@ -63,7 +63,7 @@ packages:
6363
name: fluent_ui
6464
url: "https://pub.dartlang.org"
6565
source: hosted
66-
version: "1.8.1"
66+
version: "3.6.0"
6767
flutter:
6868
dependency: "direct main"
6969
description: flutter
@@ -87,21 +87,35 @@ packages:
8787
name: matcher
8888
url: "https://pub.dartlang.org"
8989
source: hosted
90-
version: "0.12.10"
90+
version: "0.12.11"
9191
meta:
9292
dependency: transitive
9393
description:
9494
name: meta
9595
url: "https://pub.dartlang.org"
9696
source: hosted
97-
version: "1.3.0"
97+
version: "1.7.0"
9898
path:
9999
dependency: transitive
100100
description:
101101
name: path
102102
url: "https://pub.dartlang.org"
103103
source: hosted
104104
version: "1.8.0"
105+
recase:
106+
dependency: transitive
107+
description:
108+
name: recase
109+
url: "https://pub.dartlang.org"
110+
source: hosted
111+
version: "4.0.0"
112+
scroll_pos:
113+
dependency: transitive
114+
description:
115+
name: scroll_pos
116+
url: "https://pub.dartlang.org"
117+
source: hosted
118+
version: "0.3.0"
105119
sky_engine:
106120
dependency: transitive
107121
description: flutter
@@ -113,7 +127,7 @@ packages:
113127
name: source_span
114128
url: "https://pub.dartlang.org"
115129
source: hosted
116-
version: "1.8.0"
130+
version: "1.8.1"
117131
stack_trace:
118132
dependency: transitive
119133
description:
@@ -148,7 +162,7 @@ packages:
148162
name: test_api
149163
url: "https://pub.dartlang.org"
150164
source: hosted
151-
version: "0.2.19"
165+
version: "0.4.3"
152166
typed_data:
153167
dependency: transitive
154168
description:
@@ -162,7 +176,7 @@ packages:
162176
name: vector_math
163177
url: "https://pub.dartlang.org"
164178
source: hosted
165-
version: "2.1.0"
179+
version: "2.1.1"
166180
sdks:
167-
dart: ">=2.12.0 <3.0.0"
168-
flutter: ">=1.17.0"
181+
dart: ">=2.15.0 <3.0.0"
182+
flutter: ">=2.8.0"

pubspec.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,11 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
1818
version: 1.0.0+1
1919

2020
environment:
21-
sdk: ">=2.12.0 <3.0.0"
21+
sdk: ">=2.14.4 <3.0.0"
22+
flutter: ">=2.8.0"
2223

2324
dependencies:
24-
fluent_ui: ^1.8.1
25+
fluent_ui: ^3.6.0
2526
flutter:
2627
sdk: flutter
2728

0 commit comments

Comments
 (0)