Skip to content

Commit f8d1dd8

Browse files
replace MacosSegmentedControl with CupertinoSlidingSegmentedControl in the example project
This was done because macos_ui now depends on macos_window_utils, which caused version resolution to fail.
1 parent 1892d86 commit f8d1dd8

File tree

4 files changed

+26
-31
lines changed

4 files changed

+26
-31
lines changed

example/lib/main_area/main_area.dart

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import 'package:example/main_area/ns_window_delegate_demo/ns_window_delegate_dem
22
import 'package:example/main_area/window_manipulator_demo/window_manipulator_demo.dart';
33
import 'package:flutter/cupertino.dart';
44
import 'package:flutter/material.dart';
5-
import 'package:macos_ui/macos_ui.dart';
65

76
class MainArea extends StatefulWidget {
87
const MainArea({super.key, required this.setState});
@@ -14,26 +13,22 @@ class MainArea extends StatefulWidget {
1413
}
1514

1615
class _MainAreaState extends State<MainArea> {
17-
final _tabController = MacosTabController(length: 2, initialIndex: 0);
18-
19-
@override
20-
void initState() {
21-
_tabController.addListener(() => setState(() {}));
22-
23-
super.initState();
24-
}
16+
int? currentTabIndex = 0;
2517

2618
@override
2719
Widget build(BuildContext context) {
2820
return Column(
2921
children: [
3022
const SizedBox(height: 8.0),
3123
_SegmentedControl(
32-
tabController: _tabController,
24+
currentTabIndex: currentTabIndex,
25+
onTabIndexChanged: (newIndex) => setState(() {
26+
currentTabIndex = newIndex;
27+
}),
3328
),
3429
Expanded(
3530
child: IndexedStack(
36-
index: _tabController.index,
31+
index: currentTabIndex,
3732
children: [
3833
WindowManipulatorDemo(
3934
setState: widget.setState,
@@ -49,23 +44,32 @@ class _MainAreaState extends State<MainArea> {
4944

5045
class _SegmentedControl extends StatelessWidget {
5146
const _SegmentedControl({
52-
required this.tabController,
47+
required this.currentTabIndex,
48+
required this.onTabIndexChanged,
5349
});
5450

55-
final MacosTabController tabController;
51+
final int? currentTabIndex;
52+
final void Function(int?) onTabIndexChanged;
5653

5754
@override
5855
Widget build(BuildContext context) {
59-
return MacosSegmentedControl(
60-
tabs: const [
61-
MacosTab(
62-
label: 'WindowManipulator demo',
56+
return CupertinoSlidingSegmentedControl(
57+
groupValue: currentTabIndex,
58+
onValueChanged: onTabIndexChanged,
59+
children: const {
60+
0: Padding(
61+
padding: EdgeInsets.symmetric(horizontal: 20),
62+
child: Text(
63+
'WindowManipulator demo',
64+
),
6365
),
64-
MacosTab(
65-
label: 'NSWindowDelegate demo',
66+
1: Padding(
67+
padding: EdgeInsets.symmetric(horizontal: 20),
68+
child: Text(
69+
'NSWindowDelegate demo',
70+
),
6671
),
67-
],
68-
controller: tabController,
72+
},
6973
);
7074
}
7175
}

example/macos/Flutter/GeneratedPluginRegistrant.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@
55
import FlutterMacOS
66
import Foundation
77

8-
import macos_ui
98
import macos_window_utils
109

1110
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
12-
MacOSUiPlugin.register(with: registry.registrar(forPlugin: "MacOSUiPlugin"))
1311
MacOSWindowUtilsPlugin.register(with: registry.registrar(forPlugin: "MacOSWindowUtilsPlugin"))
1412
}

example/macos/Podfile.lock

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,22 @@
11
PODS:
22
- FlutterMacOS (1.0.0)
3-
- macos_ui (0.1.0):
4-
- FlutterMacOS
53
- macos_window_utils (1.0.0):
64
- FlutterMacOS
75

86
DEPENDENCIES:
97
- FlutterMacOS (from `Flutter/ephemeral`)
10-
- macos_ui (from `Flutter/ephemeral/.symlinks/plugins/macos_ui/macos`)
118
- macos_window_utils (from `Flutter/ephemeral/.symlinks/plugins/macos_window_utils/macos`)
129

1310
EXTERNAL SOURCES:
1411
FlutterMacOS:
1512
:path: Flutter/ephemeral
16-
macos_ui:
17-
:path: Flutter/ephemeral/.symlinks/plugins/macos_ui/macos
1813
macos_window_utils:
1914
:path: Flutter/ephemeral/.symlinks/plugins/macos_window_utils/macos
2015

2116
SPEC CHECKSUMS:
2217
FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24
23-
macos_ui: 125c911559d646194386d84c017ad6819122e2db
2418
macos_window_utils: 933f91f64805e2eb91a5bd057cf97cd097276663
2519

2620
PODFILE CHECKSUM: 500e4707112a5f11963bc198135953cdebb6d50c
2721

28-
COCOAPODS: 1.11.3
22+
COCOAPODS: 1.12.1

example/pubspec.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ dependencies:
4747
# Use with the CupertinoIcons class for iOS style icons.
4848
cupertino_icons: ^1.0.2
4949
flutter_markdown: ^0.6.13
50-
macos_ui: ^1.11.1
5150

5251
dev_dependencies:
5352
flutter_test:

0 commit comments

Comments
 (0)