diff --git a/.github/workflows/dart_code_metrics.yaml b/.github/workflows/dart_code_metrics.yaml
deleted file mode 100644
index 03336a6a..00000000
--- a/.github/workflows/dart_code_metrics.yaml
+++ /dev/null
@@ -1,22 +0,0 @@
-name: Dart Code Metrics
-on: [pull_request, workflow_dispatch]
-
-jobs:
- dart-code-metrics:
- runs-on: ubuntu-latest
-
- steps:
- - uses: actions/checkout@v3
-
- - name: Install Flutter
- uses: subosito/flutter-action@v2
- with:
- channel: stable
-
- - name: Set Up DCM
- run: flutter pub get
- - uses: CQLabs/setup-dcm@v1.0.0
- with:
- github_token: ${{ secrets.GITHUB_TOKEN }}
-
- - run: dcm analyze --ci-key="${{ secrets.DCM_CI_KEY }}" --email="${{ secrets.DCM_EMAIL }}" lib
diff --git a/.github/workflows/flutter_analysis.yml b/.github/workflows/flutter_analysis.yml
index fba04aa4..5612680f 100644
--- a/.github/workflows/flutter_analysis.yml
+++ b/.github/workflows/flutter_analysis.yml
@@ -34,3 +34,11 @@ jobs:
- name: Analyze code
run: flutter analyze --fatal-infos .
+
+ - name: Install DCM
+ uses: CQLabs/setup-dcm@v2
+ with:
+ github-token: ${{ secrets.GITHUB_TOKEN }}
+
+ - name: Run DCM
+ run: dcm analyze .
diff --git a/.gitignore b/.gitignore
index 144640c7..ae5694f1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -82,3 +82,7 @@ coverage_report
coverage
example/macos/Flutter/GeneratedPluginRegistrant.swift
example/devtools_options.yaml
+
+# Swift package manager
+.build/
+.swiftpm/
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8d87d8aa..10816f76 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,75 @@
+## [2.2.2]
+### ๐ Fixed ๐
+- Fixed setState called after dispose issue in MacosPulldownButton.
+
+## [2.2.1]
+### ๐ Updated ๐
+* Wrap toolbar items with `MacosToolbarPassthrough` to prevent window move or resize when interacting with toolbar items.
+
+## [2.2.0+3]
+* Address DCM lints:
+ * Prefer `const BorderRadius.all`
+ * Sort private members
+
+## [2.2.0+2]
+* Formatter updates
+
+## [2.2.0+1]
+* Support Dart 3.9.2
+* Update dependencies
+* Address lints
+
+## [2.2.0]
+### โจ New โจ
+* Add support for Swift package manager.
+
+## [2.1.10]
+### ๐ Updated ๐
+* Make text field cursor color follow the userโs accent color if not explicitly set (thanks, [@driftwoodstudio](https://github.com/driftwoodstudio)).
+* Expose the `AccentColorListener` class to macos_ui users.
+
+## [2.1.9]
+### ๐ ๏ธ Fixed ๐ ๏ธ
+* Fix incorrect highlighting and focusing behavior of `_MacosPopupMenuItemButton`.
+* Remove scrolling animation from dropdown menus when manipulating the focus with the keyboard to mimic native macOS behavior.
+
+## [2.1.8]
+### ๐ ๏ธ Fixed ๐ ๏ธ
+* Fixed `shownByDefault` not being respected for the left sidebar of the `MacosWindow` (thanks, [@ShayperCool](https://github.com/ShayperCool)).
+
+## [2.1.7]
+### ๐ Updated ๐
+* Expose `WindowMainStateListener` and implement `overrideIsMainWindow` method to allow for the windowโs main state to be overridden.
+
+## [2.1.6]
+### ๐ Updated ๐
+* add `section` parameter to `SidebarItem` to display an unclickable widget in the sidebar as a section header (thanks, [@whirlun](https://github.com/whirlun)).
+* Fix incorrect barrier color when calling `showMacosSheet` when dark mode is enabled.
+
+## [2.1.5]
+### ๐ป Migrated ๐ป
+* Migrate to Flutterโs new Color API.
+
+## [2.1.4]
+### ๐ ๏ธ Fixed ๐ ๏ธ
+* Fix incorrect barrier color when calling `showMacosAlertDialog` when dark mode is enabled.
+
+## [2.1.3]
+### ๐ ๏ธ Fixed ๐ ๏ธ
+* Fix `ToolbarOverflowButton` only reacting to every second click.
+
+## [2.1.2]
+### ๐ ๏ธ Updated ๐ ๏ธ
+* Add โOlder macOS versionsโ section to README
+* Add Flutter version constraints to prevent the following error:
+ ```
+ Package validation found the following error:
+ * pubspec.yaml allows Flutter SDK version 1.9.x, which does not support the flutter.plugin.platforms key.
+ Please consider increasing the Flutter SDK requirement to ^1.10.0 (environment.sdk.flutter)
+ ```
+## [2.1.1]
+* Fixed a bug where `MacosPulldownMenuItem` would not show an alert dialog when tapped.
+
## [2.1.0]
* Updated dependencies
* Support macOS 15
diff --git a/README.md b/README.md
index 23a54c9a..5e8271f6 100644
--- a/README.md
+++ b/README.md
@@ -20,7 +20,7 @@ Guides, codelabs, and other documentation can be found at https://macosui.dev
###
Flutter channel
`macos_ui` is developed against Flutter's `stable` channel. To ensure a smooth development experience with `macos_ui`, you should build your application on Flutter's `stable` channel.
-###
Platform Compatibility
+### ๐ฅ๏ธ Platform Compatibility
pub.dev shows that `macos_ui` only supports macOS. This is because `macos_ui` calls some native code, and therefore
specifies macOS as a plugin platform in the `pubspec.yaml` file.
@@ -33,6 +33,12 @@ The features of `macos_ui` that will _not_ work on platforms other than macOS du
* The `MacosColors.controlAccentColor()` function
* The `MacosColorWell` widget
+###
Flutter Compatibility
+
+Starting with version `2.2.0+1`, `macos_ui` requires Flutter `3.35.0` or higher due to a depredation in Flutter 3.35.0. If you use an older Flutter version along with `macos_ui` version `2.2.0+1`, only version `2.2.0` will be available to you when you run `flutter pub get`.
+
+**We therefore strongly recommend that you use Flutter `3.35.0` or higher if developing with `macos_ui` so that you gain access to the latest features and fixes.**
+
###
Popups & window resizing
Since at this time Flutter does not allow UI elements to overflow the bounds of the window, popups are constrained to
@@ -124,6 +130,12 @@ should avoid allowing your application window to be resized below the height of
- [MacosColorWell](#macoscolorwell)
+
+Older macOS versions
+
+- [Older macOS versions](#older-macos-versions)
+
+
---
## Contributing
@@ -224,7 +236,9 @@ See the documentation for customizations and `ToolBar` examples.
## Modern window look
-A new look for macOS apps was introduced in Big Sur (macOS 11). To match that look in your Flutter app, macos_ui relies on [macos_window_utils](https://pub.dev/packages/macos_window_utils), which requires a minimum macOS deployment target of 10.14.6. Therefore, make sure to open the `macos/Runner.xcworkspace` folder of your project using Xcode and search for `Runner.xcodeproj`. Go to `Info` > `Deployment Target` and set the `macOS Deployment Target` to `10.14.6` or above. Then, open your project's `Podfile` (if it doesn't show up in Xcode, you can find it in your project's `macos` directory via VS Code) and set the minimum deployment version in the first line to `10.14.6` or above:
+A new look for macOS apps was introduced in Big Sur (macOS 11). To match that look in your Flutter app, macos_ui relies on [macos_window_utils](https://pub.dev/packages/macos_window_utils), which requires a minimum macOS deployment target of 10.14.6. Therefore, make sure to open the `macos/Runner.xcworkspace` folder of your project using Xcode and search for `Runner.xcodeproj`. Go to `Info` > `Deployment Target` and set the `macOS Deployment Target` to `10.14.6` or above.
+
+It is recommended to enable the Swift Package Manager when using macos_ui. Instructions on how to do that can be found [here](https://docs.flutter.dev/packages-and-plugins/swift-package-manager/for-app-developers#how-to-turn-on-swift-package-manager). Alternatively, macos_ui can also be used with CocoaPods. To do so, it is necessary to open your project's `Podfile` (if it doesn't show up in Xcode, you can find it in your project's `macos` directory via VS Code) and set the minimum deployment version in the first line to `10.14.6` or above:
```podspec
platform :osx, '10.14.6'
@@ -472,8 +486,8 @@ A checkbox is a type of button that lets the user choose between two opposite st
checkbox is considered on when it contains a checkmark and off when it's empty. A checkbox is almost always followed
by a title unless it appears in a checklist. [Learn more](https://developer.apple.com/design/human-interface-guidelines/macos/buttons/checkboxes/)
-| Unchecked | Checked | Mixed |
-| --------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------ |
+| Unchecked | Checked | Mixed |
+| ---------------------------------------------------- | -------------------------------------------------- | ------------------------------------------------ |
|  |  |  |
Here's an example of how to create a basic checkbox:
@@ -1012,3 +1026,55 @@ MacosColorWell(
onColorSelected: (color) => debugPrint('$color'),
),
```
+
+## Older macOS versions
+
+If youโre targeting older macOS versions (Monterey and earlier), it is necessary to perform the following steps to make the [macos_window_utils](https://pub.dev/packages/macos_window_utils) plugin, which macos_ui depends on, work correctly:
+
+Open the `macos/Runner.xcworkspace` folder of your project using Xcode, press โง + โ + O and search for `MainFlutterWindow.swift`.
+
+Insert `import macos_window_utils` at the top of the file.
+Then, replace the code above the `super.awakeFromNib()`-line with the following code:
+
+```swift
+let windowFrame = self.frame
+let macOSWindowUtilsViewController = MacOSWindowUtilsViewController()
+self.contentViewController = macOSWindowUtilsViewController
+self.setFrame(windowFrame, display: true)
+
+/* Initialize the macos_window_utils plugin */
+MainFlutterWindowManipulator.start(mainFlutterWindow: self)
+
+RegisterGeneratedPlugins(registry: macOSWindowUtilsViewController.flutterViewController)
+```
+
+Assuming you're starting with the default configuration, the finished code should look something like this:
+
+```diff
+import Cocoa
+import FlutterMacOS
++import macos_window_utils
+
+class MainFlutterWindow: NSWindow {
+ override func awakeFromNib() {
+- let flutterViewController = FlutterViewController.init()
+- let windowFrame = self.frame
+- self.contentViewController = flutterViewController
+- self.setFrame(windowFrame, display: true)
+
+- RegisterGeneratedPlugins(registry: flutterViewController)
+
++ let windowFrame = self.frame
++ let macOSWindowUtilsViewController = MacOSWindowUtilsViewController()
++ self.contentViewController = macOSWindowUtilsViewController
++ self.setFrame(windowFrame, display: true)
+
++ /* Initialize the macos_window_utils plugin */
++ MainFlutterWindowManipulator.start(mainFlutterWindow: self)
+
++ RegisterGeneratedPlugins(registry: macOSWindowUtilsViewController.flutterViewController)
+
+ super.awakeFromNib()
+ }
+}
+```
\ No newline at end of file
diff --git a/example/ios/.gitignore b/example/ios/.gitignore
index e96ef602..cd653048 100644
--- a/example/ios/.gitignore
+++ b/example/ios/.gitignore
@@ -30,3 +30,6 @@ Runner/GeneratedPluginRegistrant.*
!default.mode2v3
!default.pbxuser
!default.perspectivev3
+
+# Flutter related
+**/Flutter/ephemeral/
\ No newline at end of file
diff --git a/example/lib/main.dart b/example/lib/main.dart
index cbe02dbc..8c59a524 100644
--- a/example/lib/main.dart
+++ b/example/lib/main.dart
@@ -161,36 +161,47 @@ class _WidgetGalleryState extends State {
itemSize: SidebarItemSize.large,
items: const [
SidebarItem(
- leading: MacosImageIcon(
- AssetImage('assets/sf_symbols/button_programmable_2x.png'),
- ),
- label: Text('Buttons'),
- ),
- SidebarItem(
- leading: MacosImageIcon(
- AssetImage(
- 'assets/sf_symbols/lines_measurement_horizontal_2x.png',
+ label: Text('Basic UI Elements'),
+ section: true,
+ expandDisclosureItems: true,
+ disclosureItems: [
+ SidebarItem(
+ leading: MacosImageIcon(
+ AssetImage(
+ 'assets/sf_symbols/button_programmable_2x.png',
+ ),
+ ),
+ label: Text('Buttons'),
),
- ),
- label: Text('Indicators'),
- ),
- SidebarItem(
- leading: MacosImageIcon(
- AssetImage(
- 'assets/sf_symbols/character_cursor_ibeam_2x.png',
+ SidebarItem(
+ leading: MacosImageIcon(
+ AssetImage(
+ 'assets/sf_symbols/lines_measurement_horizontal_2x.png',
+ ),
+ ),
+ label: Text('Indicators'),
),
- ),
- label: Text('Fields'),
- ),
- SidebarItem(
- leading: MacosImageIcon(
- AssetImage('assets/sf_symbols/rectangle_3_group_2x.png'),
- ),
- label: Text('Colors'),
- ),
- SidebarItem(
- leading: MacosIcon(CupertinoIcons.square_on_square),
- label: Text('Dialogs & Sheets'),
+ SidebarItem(
+ leading: MacosImageIcon(
+ AssetImage(
+ 'assets/sf_symbols/character_cursor_ibeam_2x.png',
+ ),
+ ),
+ label: Text('Fields'),
+ ),
+ SidebarItem(
+ leading: MacosImageIcon(
+ AssetImage(
+ 'assets/sf_symbols/rectangle_3_group_2x.png',
+ ),
+ ),
+ label: Text('Colors'),
+ ),
+ SidebarItem(
+ leading: MacosIcon(CupertinoIcons.square_on_square),
+ label: Text('Dialogs & Sheets'),
+ ),
+ ],
),
SidebarItem(
leading: MacosImageIcon(
@@ -199,6 +210,7 @@ class _WidgetGalleryState extends State {
),
),
label: Text('Layout'),
+ section: true,
disclosureItems: [
SidebarItem(
leading: MacosIcon(CupertinoIcons.macwindow),
@@ -224,15 +236,23 @@ class _WidgetGalleryState extends State {
expandDisclosureItems: true,
),
SidebarItem(
- leading: MacosImageIcon(
- AssetImage(
- 'assets/sf_symbols/filemenu_and_selection_2x.png'),
- ),
- label: Text('Selectors'),
- ),
- SidebarItem(
- leading: MacosIcon(CupertinoIcons.textformat_size),
- label: Text('Typography'),
+ label: Text('Additional UI Elements'),
+ section: true,
+ expandDisclosureItems: true,
+ disclosureItems: [
+ SidebarItem(
+ leading: MacosImageIcon(
+ AssetImage(
+ 'assets/sf_symbols/filemenu_and_selection_2x.png',
+ ),
+ ),
+ label: Text('Selectors'),
+ ),
+ SidebarItem(
+ leading: MacosIcon(CupertinoIcons.textformat_size),
+ label: Text('Typography'),
+ ),
+ ],
),
],
);
@@ -249,9 +269,7 @@ class _WidgetGalleryState extends State {
maxWidth: 300,
shownByDefault: false,
builder: (context, _) {
- return const Center(
- child: Text('End Sidebar'),
- );
+ return const Center(child: Text('End Sidebar'));
},
),
child: [
diff --git a/example/lib/pages/buttons_page.dart b/example/lib/pages/buttons_page.dart
index 26952d90..72d74a20 100644
--- a/example/lib/pages/buttons_page.dart
+++ b/example/lib/pages/buttons_page.dart
@@ -52,9 +52,7 @@ class _ButtonsPageState extends State {
ToolBarIconButton(
label: 'Toggle End Sidebar',
tooltipMessage: 'Toggle End Sidebar',
- icon: const MacosIcon(
- CupertinoIcons.sidebar_right,
- ),
+ icon: const MacosIcon(CupertinoIcons.sidebar_right),
onPressed: () => MacosWindowScope.of(context).toggleEndSidebar(),
showLabel: false,
),
@@ -71,10 +69,7 @@ class _ButtonsPageState extends State {
children: [
const WidgetTextTitle1(widgetName: 'PushButton'),
Divider(color: MacosTheme.of(context).dividerColor),
- Text(
- 'Primary',
- style: MacosTypography.of(context).title2,
- ),
+ Text('Primary', style: MacosTypography.of(context).title2),
Row(
children: [
PushButton(
@@ -115,7 +110,7 @@ class _ButtonsPageState extends State {
startSize: 200,
windowBreakpoint: 700,
resizableSide: ResizableSide.left,
- builder: (_, __) {
+ builder: (_, _) {
return const Center(
child: Text('Resizable Pane'),
);
@@ -159,7 +154,7 @@ class _ButtonsPageState extends State {
startSize: 200,
windowBreakpoint: 700,
resizableSide: ResizableSide.left,
- builder: (_, __) {
+ builder: (_, _) {
return const Center(
child: Text('Resizable Pane'),
);
@@ -203,7 +198,7 @@ class _ButtonsPageState extends State {
startSize: 200,
windowBreakpoint: 700,
resizableSide: ResizableSide.left,
- builder: (_, __) {
+ builder: (_, _) {
return const Center(
child: Text('Resizable Pane'),
);
@@ -247,10 +242,7 @@ class _ButtonsPageState extends State {
],
),
const SizedBox(height: 16),
- Text(
- 'Secondary',
- style: MacosTypography.of(context).title2,
- ),
+ Text('Secondary', style: MacosTypography.of(context).title2),
Row(
children: [
PushButton(
@@ -293,7 +285,7 @@ class _ButtonsPageState extends State {
startSize: 200,
windowBreakpoint: 700,
resizableSide: ResizableSide.left,
- builder: (_, __) {
+ builder: (_, _) {
return const Center(
child: Text('Resizable Pane'),
);
@@ -338,7 +330,7 @@ class _ButtonsPageState extends State {
startSize: 200,
windowBreakpoint: 700,
resizableSide: ResizableSide.left,
- builder: (_, __) {
+ builder: (_, _) {
return const Center(
child: Text('Resizable Pane'),
);
@@ -383,7 +375,7 @@ class _ButtonsPageState extends State {
startSize: 200,
windowBreakpoint: 700,
resizableSide: ResizableSide.left,
- builder: (_, __) {
+ builder: (_, _) {
return const Center(
child: Text('Resizable Pane'),
);
@@ -449,9 +441,7 @@ class _ButtonsPageState extends State {
fillColor: Colors.transparent,
),
const SizedBox(width: 16.0),
- MacosBackButton(
- onPressed: () => debugPrint('click'),
- ),
+ MacosBackButton(onPressed: () => debugPrint('click')),
],
),
const SizedBox(height: 20),
@@ -477,26 +467,20 @@ class _ButtonsPageState extends State {
Row(
children: [
MacosIconButton(
- icon: const MacosIcon(
- CupertinoIcons.star_fill,
- ),
+ icon: const MacosIcon(CupertinoIcons.star_fill),
shape: BoxShape.rectangle,
borderRadius: BorderRadius.circular(7),
onPressed: () {},
),
const SizedBox(width: 8),
const MacosIconButton(
- icon: MacosIcon(
- CupertinoIcons.plus_app,
- ),
+ icon: MacosIcon(CupertinoIcons.plus_app),
shape: BoxShape.circle,
//onPressed: () {},
),
const SizedBox(width: 8),
MacosIconButton(
- icon: const MacosIcon(
- CupertinoIcons.minus_square,
- ),
+ icon: const MacosIcon(CupertinoIcons.minus_square),
backgroundColor: Colors.transparent,
onPressed: () {},
),
@@ -567,10 +551,7 @@ class _ButtonsPageState extends State {
},
),
const SizedBox(width: 8),
- MacosCheckbox(
- value: switchValue,
- onChanged: null,
- ),
+ MacosCheckbox(value: switchValue, onChanged: null),
],
),
const SizedBox(height: 16),
@@ -732,11 +713,12 @@ class _ButtonsPageState extends State {
},
items: ['One', 'Two', 'Three', 'Four']
.map>((String value) {
- return MacosPopupMenuItem(
- value: value,
- child: Text(value),
- );
- }).toList(),
+ return MacosPopupMenuItem(
+ value: value,
+ child: Text(value),
+ );
+ })
+ .toList(),
),
const SizedBox(width: 20),
MacosPopupButton(
@@ -752,8 +734,9 @@ class _ButtonsPageState extends State {
onChanged: (String? newValue) {
setState(() => languagePopupValue = newValue!);
},
- items: languages
- .map>((String value) {
+ items: languages.map>((
+ String value,
+ ) {
return MacosPopupMenuItem(
value: value,
child: Text(value),
@@ -825,5 +808,5 @@ const languages = [
'Polish',
'Ukrainian',
'Romanian',
- 'Dutch'
+ 'Dutch',
];
diff --git a/example/lib/pages/colors_page.dart b/example/lib/pages/colors_page.dart
index 6eb3eac8..5af39b82 100644
--- a/example/lib/pages/colors_page.dart
+++ b/example/lib/pages/colors_page.dart
@@ -50,9 +50,7 @@ class _ColorsPageState extends State {
children: [
const MacosTooltip(
message: 'System Red',
- child: ColorBox(
- color: MacosColors.systemRedColor,
- ),
+ child: ColorBox(color: MacosColors.systemRedColor),
),
MacosTooltip(
message: 'System Red Dark',
@@ -62,9 +60,7 @@ class _ColorsPageState extends State {
),
const MacosTooltip(
message: 'System Green',
- child: ColorBox(
- color: MacosColors.systemGreenColor,
- ),
+ child: ColorBox(color: MacosColors.systemGreenColor),
),
MacosTooltip(
message: 'System Green Dark',
@@ -74,9 +70,7 @@ class _ColorsPageState extends State {
),
const MacosTooltip(
message: 'System Blue',
- child: ColorBox(
- color: MacosColors.systemBlueColor,
- ),
+ child: ColorBox(color: MacosColors.systemBlueColor),
),
MacosTooltip(
message: 'System Blue Dark',
@@ -86,9 +80,7 @@ class _ColorsPageState extends State {
),
const MacosTooltip(
message: 'System Orange',
- child: ColorBox(
- color: MacosColors.systemOrangeColor,
- ),
+ child: ColorBox(color: MacosColors.systemOrangeColor),
),
MacosTooltip(
message: 'System Orange Dark',
@@ -98,9 +90,7 @@ class _ColorsPageState extends State {
),
const MacosTooltip(
message: 'System Yellow',
- child: ColorBox(
- color: MacosColors.systemYellowColor,
- ),
+ child: ColorBox(color: MacosColors.systemYellowColor),
),
MacosTooltip(
message: 'System Yellow Dark',
@@ -110,9 +100,7 @@ class _ColorsPageState extends State {
),
const MacosTooltip(
message: 'System Brown',
- child: ColorBox(
- color: MacosColors.systemBrownColor,
- ),
+ child: ColorBox(color: MacosColors.systemBrownColor),
),
MacosTooltip(
message: 'System Brown Dark',
@@ -122,9 +110,7 @@ class _ColorsPageState extends State {
),
const MacosTooltip(
message: 'System Pink',
- child: ColorBox(
- color: MacosColors.systemPinkColor,
- ),
+ child: ColorBox(color: MacosColors.systemPinkColor),
),
MacosTooltip(
message: 'System Pink Dark',
@@ -134,9 +120,7 @@ class _ColorsPageState extends State {
),
const MacosTooltip(
message: 'System Purple',
- child: ColorBox(
- color: MacosColors.systemPurpleColor,
- ),
+ child: ColorBox(color: MacosColors.systemPurpleColor),
),
MacosTooltip(
message: 'System Purple Dark',
@@ -146,9 +130,7 @@ class _ColorsPageState extends State {
),
const MacosTooltip(
message: 'System Teal',
- child: ColorBox(
- color: MacosColors.systemTealColor,
- ),
+ child: ColorBox(color: MacosColors.systemTealColor),
),
MacosTooltip(
message: 'System Teal Dark',
@@ -158,9 +140,7 @@ class _ColorsPageState extends State {
),
const MacosTooltip(
message: 'System Indigo',
- child: ColorBox(
- color: MacosColors.systemIndigoColor,
- ),
+ child: ColorBox(color: MacosColors.systemIndigoColor),
),
MacosTooltip(
message: 'System Indigo Dark',
@@ -170,9 +150,7 @@ class _ColorsPageState extends State {
),
const MacosTooltip(
message: 'System Gray',
- child: ColorBox(
- color: MacosColors.systemGrayColor,
- ),
+ child: ColorBox(color: MacosColors.systemGrayColor),
),
MacosTooltip(
message: 'System Gray Dark',
@@ -182,15 +160,11 @@ class _ColorsPageState extends State {
),
const MacosTooltip(
message: 'Link',
- child: ColorBox(
- color: MacosColors.linkColor,
- ),
+ child: ColorBox(color: MacosColors.linkColor),
),
MacosTooltip(
message: 'Link Dark',
- child: ColorBox(
- color: MacosColors.linkColor.darkColor,
- ),
+ child: ColorBox(color: MacosColors.linkColor.darkColor),
),
const MacosTooltip(
message: 'Unemphasized Background',
@@ -221,9 +195,7 @@ class _ColorsPageState extends State {
),
const MacosTooltip(
message: 'Control',
- child: ColorBox(
- color: MacosColors.controlColor,
- ),
+ child: ColorBox(color: MacosColors.controlColor),
),
MacosTooltip(
message: 'Control Dark',
@@ -233,9 +205,7 @@ class _ColorsPageState extends State {
),
const MacosTooltip(
message: 'Control Text',
- child: ColorBox(
- color: MacosColors.controlTextColor,
- ),
+ child: ColorBox(color: MacosColors.controlTextColor),
),
MacosTooltip(
message: 'Control Text Dark',
@@ -294,9 +264,7 @@ class _ColorsPageState extends State {
),
const MacosTooltip(
message: 'Label',
- child: ColorBox(
- color: MacosColors.labelColor,
- ),
+ child: ColorBox(color: MacosColors.labelColor),
),
MacosTooltip(
message: 'Label Dark',
@@ -306,9 +274,7 @@ class _ColorsPageState extends State {
),
const MacosTooltip(
message: 'Secondary Label',
- child: ColorBox(
- color: MacosColors.secondaryLabelColor,
- ),
+ child: ColorBox(color: MacosColors.secondaryLabelColor),
),
MacosTooltip(
message: 'Secondary Label Dark',
@@ -318,9 +284,7 @@ class _ColorsPageState extends State {
),
const MacosTooltip(
message: 'Tertiary Label',
- child: ColorBox(
- color: MacosColors.tertiaryLabelColor,
- ),
+ child: ColorBox(color: MacosColors.tertiaryLabelColor),
),
MacosTooltip(
message: 'Tertiary Label Dark',
@@ -353,10 +317,7 @@ class _ColorsPageState extends State {
}
class ColorBox extends StatelessWidget {
- const ColorBox({
- super.key,
- required this.color,
- });
+ const ColorBox({super.key, required this.color});
final Color color;
@@ -364,10 +325,7 @@ class ColorBox extends StatelessWidget {
Widget build(BuildContext context) {
return ColoredBox(
color: color,
- child: const SizedBox(
- height: 50,
- width: 50,
- ),
+ child: const SizedBox(height: 50, width: 50),
);
}
}
diff --git a/example/lib/pages/dialogs_page.dart b/example/lib/pages/dialogs_page.dart
index 33764bda..c5d2eae3 100644
--- a/example/lib/pages/dialogs_page.dart
+++ b/example/lib/pages/dialogs_page.dart
@@ -215,15 +215,13 @@ class DemoSheet extends StatelessWidget {
child: Column(
children: [
const SizedBox(height: 50),
- const FlutterLogo(
- size: 56,
- ),
+ const FlutterLogo(size: 56),
const SizedBox(height: 24),
Text(
'Welcome to macos_ui',
- style: MacosTheme.of(context).typography.largeTitle.copyWith(
- fontWeight: FontWeight.bold,
- ),
+ style: MacosTheme.of(
+ context,
+ ).typography.largeTitle.copyWith(fontWeight: FontWeight.bold),
),
const SizedBox(height: 24),
const MacosListTile(
diff --git a/example/lib/pages/fields_page.dart b/example/lib/pages/fields_page.dart
index fd9183bb..7af455e8 100644
--- a/example/lib/pages/fields_page.dart
+++ b/example/lib/pages/fields_page.dart
@@ -105,8 +105,9 @@ class _FieldsPageState extends State {
SizedBox(
width: 300.0,
child: MacosSearchField(
- results:
- countries.map((e) => SearchResultItem(e)).toList(),
+ results: countries
+ .map((e) => SearchResultItem(e))
+ .toList(),
placeholder: 'Search for a country...',
onResultSelected: (resultItem) {
// Retrieve the user-selected search suggestion via its
@@ -125,10 +126,11 @@ class _FieldsPageState extends State {
results: actionResults,
resultHeight: 40.0,
emptyWidget: const Center(
- child: Padding(
- padding: EdgeInsets.all(8.0),
- child: Text('No action found!'),
- )),
+ child: Padding(
+ padding: EdgeInsets.all(8.0),
+ child: Text('No action found!'),
+ ),
+ ),
placeholder: 'Search for an action...',
onResultSelected: (resultItem) {
// Retrieve the user-selected search suggestion via its
@@ -353,7 +355,7 @@ const countries = [
'Virgin Islands (US)',
'Yemen',
'Zambia',
- 'Zimbabwe'
+ 'Zimbabwe',
];
var actionResults = [
diff --git a/example/lib/pages/resizable_pane_page.dart b/example/lib/pages/resizable_pane_page.dart
index 78ed3320..312fc68b 100644
--- a/example/lib/pages/resizable_pane_page.dart
+++ b/example/lib/pages/resizable_pane_page.dart
@@ -42,30 +42,24 @@ class _ResizablePanePageState extends State {
startSize: 200,
windowBreakpoint: 700,
resizableSide: ResizableSide.right,
- builder: (_, __) {
- return const Center(
- child: Text('Left Resizable Pane'),
- );
+ builder: (_, _) {
+ return const Center(child: Text('Left Resizable Pane'));
},
),
ContentArea(
- builder: (_, __) {
+ builder: (_, _) {
return Column(
children: [
const Flexible(
fit: FlexFit.loose,
- child: Center(
- child: Text('Content Area'),
- ),
+ child: Center(child: Text('Content Area')),
),
ResizablePane(
minSize: 50,
startSize: 200,
//windowBreakpoint: 600,
- builder: (_, __) {
- return const Center(
- child: Text('Bottom Resizable Pane'),
- );
+ builder: (_, _) {
+ return const Center(child: Text('Bottom Resizable Pane'));
},
resizableSide: ResizableSide.top,
),
diff --git a/example/lib/pages/sliver_toolbar_page.dart b/example/lib/pages/sliver_toolbar_page.dart
index be2e680c..583ef5b3 100644
--- a/example/lib/pages/sliver_toolbar_page.dart
+++ b/example/lib/pages/sliver_toolbar_page.dart
@@ -1,5 +1,4 @@
import 'package:flutter/cupertino.dart';
-import 'package:flutter/material.dart';
import 'package:macos_ui/macos_ui.dart';
class SliverToolbarPage extends StatefulWidget {
@@ -128,25 +127,23 @@ class _SliverToolbarPageState extends State {
),
),
SliverList(
- delegate: SliverChildListDelegate(
- [
- Row(
- children: [
- ...List.generate(
- 3,
- (index) => const FlutterLogo(size: 150),
- )
- ],
- ),
- ...List.generate(
- 100,
- (index) => Padding(
- padding: const EdgeInsets.symmetric(horizontal: 16.0),
- child: Text('Item ${index + 1}'),
+ delegate: SliverChildListDelegate([
+ Row(
+ children: [
+ ...List.generate(
+ 3,
+ (index) => const FlutterLogo(size: 150),
),
+ ],
+ ),
+ ...List.generate(
+ 100,
+ (index) => Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 16.0),
+ child: Text('Item ${index + 1}'),
),
- ],
- ),
+ ),
+ ]),
),
],
);
diff --git a/example/lib/pages/tabview_page.dart b/example/lib/pages/tabview_page.dart
index 5e224429..03c20fb6 100644
--- a/example/lib/pages/tabview_page.dart
+++ b/example/lib/pages/tabview_page.dart
@@ -9,10 +9,7 @@ class TabViewPage extends StatefulWidget {
}
class _TabViewPageState extends State {
- final _controller = MacosTabController(
- initialIndex: 0,
- length: 3,
- );
+ final _controller = MacosTabController(initialIndex: 0, length: 3);
@override
Widget build(BuildContext context) {
@@ -49,26 +46,14 @@ class _TabViewPageState extends State {
child: MacosTabView(
controller: _controller,
tabs: const [
- MacosTab(
- label: 'Tab 1',
- ),
- MacosTab(
- label: 'Tab 2',
- ),
- MacosTab(
- label: 'Tab 3',
- ),
+ MacosTab(label: 'Tab 1'),
+ MacosTab(label: 'Tab 2'),
+ MacosTab(label: 'Tab 3'),
],
children: const [
- Center(
- child: Text('Tab 1'),
- ),
- Center(
- child: Text('Tab 2'),
- ),
- Center(
- child: Text('Tab 3'),
- ),
+ Center(child: Text('Tab 1')),
+ Center(child: Text('Tab 2')),
+ Center(child: Text('Tab 3')),
],
),
);
diff --git a/example/lib/pages/toolbar_page.dart b/example/lib/pages/toolbar_page.dart
index 104bd7c1..659bc873 100644
--- a/example/lib/pages/toolbar_page.dart
+++ b/example/lib/pages/toolbar_page.dart
@@ -17,18 +17,14 @@ class _ToolbarPageState extends State {
titleWidth: 100.0,
actions: [
ToolBarIconButton(
- icon: const MacosIcon(
- CupertinoIcons.folder_badge_plus,
- ),
+ icon: const MacosIcon(CupertinoIcons.folder_badge_plus),
onPressed: () => debugPrint('New Folder...'),
label: 'New Folder',
showLabel: true,
tooltipMessage: 'This is a beautiful tooltip',
),
ToolBarIconButton(
- icon: const MacosIcon(
- CupertinoIcons.add_circled,
- ),
+ icon: const MacosIcon(CupertinoIcons.add_circled),
onPressed: () => debugPrint('Add...'),
label: 'Add',
showLabel: true,
@@ -37,17 +33,13 @@ class _ToolbarPageState extends State {
const ToolBarSpacer(),
ToolBarIconButton(
label: 'Delete',
- icon: const MacosIcon(
- CupertinoIcons.trash,
- ),
+ icon: const MacosIcon(CupertinoIcons.trash),
onPressed: () => debugPrint('pressed'),
showLabel: false,
),
const ToolBarIconButton(
label: 'Change View',
- icon: MacosIcon(
- CupertinoIcons.list_bullet,
- ),
+ icon: MacosIcon(CupertinoIcons.list_bullet),
showLabel: false,
),
ToolBarPullDownButton(
@@ -98,17 +90,13 @@ class _ToolbarPageState extends State {
const ToolBarDivider(),
ToolBarIconButton(
label: 'Table',
- icon: const MacosIcon(
- CupertinoIcons.square_grid_3x2,
- ),
+ icon: const MacosIcon(CupertinoIcons.square_grid_3x2),
onPressed: () => debugPrint('Table...'),
showLabel: false,
),
ToolBarIconButton(
label: 'Toggle Sidebar',
- icon: const MacosIcon(
- CupertinoIcons.sidebar_left,
- ),
+ icon: const MacosIcon(CupertinoIcons.sidebar_left),
onPressed: () => MacosWindowScope.of(context).toggleSidebar(),
showLabel: false,
),
@@ -146,9 +134,7 @@ class _ToolbarPageState extends State {
),
ToolBarIconButton(
label: 'Share',
- icon: const MacosIcon(
- CupertinoIcons.share,
- ),
+ icon: const MacosIcon(CupertinoIcons.share),
onPressed: () => debugPrint('pressed'),
showLabel: false,
),
diff --git a/example/lib/pages/typography_page.dart b/example/lib/pages/typography_page.dart
index 3779cb57..3dbf8d6d 100644
--- a/example/lib/pages/typography_page.dart
+++ b/example/lib/pages/typography_page.dart
@@ -19,9 +19,7 @@ class TypographyPage extends StatelessWidget {
);
return MacosScaffold(
- toolBar: const ToolBar(
- title: Text('Typography'),
- ),
+ toolBar: const ToolBar(title: Text('Typography')),
children: [
ContentArea(
builder: (context, scrollController) {
@@ -42,88 +40,99 @@ class TypographyPage extends StatelessWidget {
const SizedBox(height: 8.0),
Text(
'LargeTitle',
- style: typography.largeTitle
- .copyWith(fontWeight: FontWeight.w700),
+ style: typography.largeTitle.copyWith(
+ fontWeight: FontWeight.w700,
+ ),
),
const SizedBox(height: 24.0),
Text('Title1', style: typography.title1),
const SizedBox(height: 8.0),
Text(
'Title1',
- style: typography.title1
- .copyWith(fontWeight: FontWeight.w700),
+ style: typography.title1.copyWith(
+ fontWeight: FontWeight.w700,
+ ),
),
const SizedBox(height: 24.0),
Text('Title2', style: typography.title2),
const SizedBox(height: 8.0),
Text(
'Title2',
- style: typography.title2
- .copyWith(fontWeight: FontWeight.w700),
+ style: typography.title2.copyWith(
+ fontWeight: FontWeight.w700,
+ ),
),
const SizedBox(height: 24.0),
Text('Title3', style: typography.title3),
const SizedBox(height: 8.0),
Text(
'Title3',
- style: typography.title3
- .copyWith(fontWeight: FontWeight.w600),
+ style: typography.title3.copyWith(
+ fontWeight: FontWeight.w600,
+ ),
),
const SizedBox(height: 24.0),
Text('Headline', style: typography.headline),
const SizedBox(height: 8.0),
Text(
'Headline',
- style: typography.headline
- .copyWith(fontWeight: MacosFontWeight.w860),
+ style: typography.headline.copyWith(
+ fontWeight: MacosFontWeight.w860,
+ ),
),
const SizedBox(height: 24.0),
Text('Body', style: typography.body),
const SizedBox(height: 8.0),
Text(
'Body',
- style: typography.body
- .copyWith(fontWeight: MacosFontWeight.w590),
+ style: typography.body.copyWith(
+ fontWeight: MacosFontWeight.w590,
+ ),
),
const SizedBox(height: 24.0),
Text('Callout', style: typography.callout),
const SizedBox(height: 8.0),
Text(
'Callout',
- style: typography.callout
- .copyWith(fontWeight: MacosFontWeight.w590),
+ style: typography.callout.copyWith(
+ fontWeight: MacosFontWeight.w590,
+ ),
),
const SizedBox(height: 24.0),
Text('Subheadline', style: typography.subheadline),
const SizedBox(height: 8.0),
Text(
'Subheadline',
- style: typography.subheadline
- .copyWith(fontWeight: MacosFontWeight.w590),
+ style: typography.subheadline.copyWith(
+ fontWeight: MacosFontWeight.w590,
+ ),
),
const SizedBox(height: 24.0),
Text('Footnote', style: typography.subheadline),
const SizedBox(height: 8.0),
Text(
'Footnote',
- style: typography.subheadline
- .copyWith(fontWeight: MacosFontWeight.w590),
+ style: typography.subheadline.copyWith(
+ fontWeight: MacosFontWeight.w590,
+ ),
),
const SizedBox(height: 24.0),
Text('Caption1', style: typography.caption1),
const SizedBox(height: 8.0),
Text(
'Caption1',
- style: typography.caption1
- .copyWith(fontWeight: MacosFontWeight.w510),
+ style: typography.caption1.copyWith(
+ fontWeight: MacosFontWeight.w510,
+ ),
),
const SizedBox(height: 24.0),
Text('Caption2', style: typography.caption2),
const SizedBox(height: 8.0),
Text(
'Caption2',
- style: typography.caption2
- .copyWith(fontWeight: MacosFontWeight.w590),
+ style: typography.caption2.copyWith(
+ fontWeight: MacosFontWeight.w590,
+ ),
),
],
),
@@ -139,74 +148,63 @@ class TypographyPage extends StatelessWidget {
const SizedBox(height: 8.0),
Text(
'LargeTitle',
- style: secondaryTypography.largeTitle
- .copyWith(fontWeight: FontWeight.w700),
+ style: secondaryTypography.largeTitle.copyWith(
+ fontWeight: FontWeight.w700,
+ ),
),
const SizedBox(height: 24.0),
- Text(
- 'Title1',
- style: secondaryTypography.title1,
- ),
+ Text('Title1', style: secondaryTypography.title1),
const SizedBox(height: 8.0),
Text(
'Title1',
- style: secondaryTypography.title1
- .copyWith(fontWeight: FontWeight.w700),
+ style: secondaryTypography.title1.copyWith(
+ fontWeight: FontWeight.w700,
+ ),
),
const SizedBox(height: 24.0),
- Text(
- 'Title2',
- style: secondaryTypography.title2,
- ),
+ Text('Title2', style: secondaryTypography.title2),
const SizedBox(height: 8.0),
Text(
'Title2',
- style: secondaryTypography.title2
- .copyWith(fontWeight: FontWeight.w700),
+ style: secondaryTypography.title2.copyWith(
+ fontWeight: FontWeight.w700,
+ ),
),
const SizedBox(height: 24.0),
- Text(
- 'Title3',
- style: secondaryTypography.title3,
- ),
+ Text('Title3', style: secondaryTypography.title3),
const SizedBox(height: 8.0),
Text(
'Title3',
- style: secondaryTypography.title3
- .copyWith(fontWeight: FontWeight.w600),
+ style: secondaryTypography.title3.copyWith(
+ fontWeight: FontWeight.w600,
+ ),
),
const SizedBox(height: 24.0),
- Text(
- 'Headline',
- style: secondaryTypography.headline,
- ),
+ Text('Headline', style: secondaryTypography.headline),
const SizedBox(height: 8.0),
Text(
'Headline',
- style: secondaryTypography.headline
- .copyWith(fontWeight: MacosFontWeight.w860),
+ style: secondaryTypography.headline.copyWith(
+ fontWeight: MacosFontWeight.w860,
+ ),
),
const SizedBox(height: 24.0),
- Text(
- 'Body',
- style: secondaryTypography.body,
- ),
+ Text('Body', style: secondaryTypography.body),
const SizedBox(height: 8.0),
Text(
'Body',
- style: secondaryTypography.body
- .copyWith(fontWeight: MacosFontWeight.w590),
+ style: secondaryTypography.body.copyWith(
+ fontWeight: MacosFontWeight.w590,
+ ),
),
const SizedBox(height: 24.0),
- Text(
- 'Callout',
- style: secondaryTypography.callout,
- ),
+ Text('Callout', style: secondaryTypography.callout),
const SizedBox(height: 8.0),
Text(
'Callout',
- style: secondaryTypography.callout
- .copyWith(fontWeight: MacosFontWeight.w590),
+ style: secondaryTypography.callout.copyWith(
+ fontWeight: MacosFontWeight.w590,
+ ),
),
const SizedBox(height: 24.0),
Text(
@@ -216,41 +214,36 @@ class TypographyPage extends StatelessWidget {
const SizedBox(height: 8.0),
Text(
'Subheadline',
- style: secondaryTypography.subheadline
- .copyWith(fontWeight: FontWeight.w600),
+ style: secondaryTypography.subheadline.copyWith(
+ fontWeight: FontWeight.w600,
+ ),
),
const SizedBox(height: 24.0),
- Text(
- 'Footnote',
- style: secondaryTypography.footnote,
- ),
+ Text('Footnote', style: secondaryTypography.footnote),
const SizedBox(height: 8.0),
Text(
'Footnote',
- style: secondaryTypography.footnote
- .copyWith(fontWeight: MacosFontWeight.w590),
+ style: secondaryTypography.footnote.copyWith(
+ fontWeight: MacosFontWeight.w590,
+ ),
),
const SizedBox(height: 24.0),
- Text(
- 'Caption1',
- style: secondaryTypography.caption1,
- ),
+ Text('Caption1', style: secondaryTypography.caption1),
const SizedBox(height: 8.0),
Text(
'Caption1',
- style: secondaryTypography.caption1
- .copyWith(fontWeight: MacosFontWeight.w510),
+ style: secondaryTypography.caption1.copyWith(
+ fontWeight: MacosFontWeight.w510,
+ ),
),
const SizedBox(height: 24.0),
- Text(
- 'Caption2',
- style: secondaryTypography.caption2,
- ),
+ Text('Caption2', style: secondaryTypography.caption2),
const SizedBox(height: 8.0),
Text(
'Caption2',
- style: secondaryTypography.caption2
- .copyWith(fontWeight: MacosFontWeight.w590),
+ style: secondaryTypography.caption2.copyWith(
+ fontWeight: MacosFontWeight.w590,
+ ),
),
],
),
@@ -266,74 +259,63 @@ class TypographyPage extends StatelessWidget {
const SizedBox(height: 8.0),
Text(
'LargeTitle',
- style: tertiaryTypography.largeTitle
- .copyWith(fontWeight: FontWeight.w700),
+ style: tertiaryTypography.largeTitle.copyWith(
+ fontWeight: FontWeight.w700,
+ ),
),
const SizedBox(height: 24.0),
- Text(
- 'Title1',
- style: tertiaryTypography.title1,
- ),
+ Text('Title1', style: tertiaryTypography.title1),
const SizedBox(height: 8.0),
Text(
'Title1',
- style: tertiaryTypography.title1
- .copyWith(fontWeight: FontWeight.w700),
+ style: tertiaryTypography.title1.copyWith(
+ fontWeight: FontWeight.w700,
+ ),
),
const SizedBox(height: 24.0),
- Text(
- 'Title2',
- style: tertiaryTypography.title2,
- ),
+ Text('Title2', style: tertiaryTypography.title2),
const SizedBox(height: 8.0),
Text(
'Title2',
- style: tertiaryTypography.title2
- .copyWith(fontWeight: FontWeight.w700),
+ style: tertiaryTypography.title2.copyWith(
+ fontWeight: FontWeight.w700,
+ ),
),
const SizedBox(height: 24.0),
- Text(
- 'Title3',
- style: tertiaryTypography.title3,
- ),
+ Text('Title3', style: tertiaryTypography.title3),
const SizedBox(height: 8.0),
Text(
'Title3',
- style: tertiaryTypography.title3
- .copyWith(fontWeight: FontWeight.w600),
+ style: tertiaryTypography.title3.copyWith(
+ fontWeight: FontWeight.w600,
+ ),
),
const SizedBox(height: 24.0),
- Text(
- 'Headline',
- style: tertiaryTypography.headline,
- ),
+ Text('Headline', style: tertiaryTypography.headline),
const SizedBox(height: 8.0),
Text(
'Headline',
- style: tertiaryTypography.headline
- .copyWith(fontWeight: MacosFontWeight.w860),
+ style: tertiaryTypography.headline.copyWith(
+ fontWeight: MacosFontWeight.w860,
+ ),
),
const SizedBox(height: 24.0),
- Text(
- 'Body',
- style: tertiaryTypography.body,
- ),
+ Text('Body', style: tertiaryTypography.body),
const SizedBox(height: 8.0),
Text(
'Body',
- style: tertiaryTypography.body
- .copyWith(fontWeight: MacosFontWeight.w590),
+ style: tertiaryTypography.body.copyWith(
+ fontWeight: MacosFontWeight.w590,
+ ),
),
const SizedBox(height: 24.0),
- Text(
- 'Callout',
- style: tertiaryTypography.callout,
- ),
+ Text('Callout', style: tertiaryTypography.callout),
const SizedBox(height: 8.0),
Text(
'Callout',
- style: tertiaryTypography.callout
- .copyWith(fontWeight: MacosFontWeight.w590),
+ style: tertiaryTypography.callout.copyWith(
+ fontWeight: MacosFontWeight.w590,
+ ),
),
const SizedBox(height: 24.0),
Text(
@@ -343,41 +325,36 @@ class TypographyPage extends StatelessWidget {
const SizedBox(height: 8.0),
Text(
'Subheadline',
- style: tertiaryTypography.subheadline
- .copyWith(fontWeight: MacosFontWeight.w590),
+ style: tertiaryTypography.subheadline.copyWith(
+ fontWeight: MacosFontWeight.w590,
+ ),
),
const SizedBox(height: 24.0),
- Text(
- 'Footnote',
- style: tertiaryTypography.footnote,
- ),
+ Text('Footnote', style: tertiaryTypography.footnote),
const SizedBox(height: 8.0),
Text(
'Footnote',
- style: tertiaryTypography.footnote
- .copyWith(fontWeight: MacosFontWeight.w590),
+ style: tertiaryTypography.footnote.copyWith(
+ fontWeight: MacosFontWeight.w590,
+ ),
),
const SizedBox(height: 24.0),
- Text(
- 'Caption1',
- style: tertiaryTypography.caption1,
- ),
+ Text('Caption1', style: tertiaryTypography.caption1),
const SizedBox(height: 8.0),
Text(
'Caption1',
- style: tertiaryTypography.caption1
- .copyWith(fontWeight: MacosFontWeight.w510),
+ style: tertiaryTypography.caption1.copyWith(
+ fontWeight: MacosFontWeight.w510,
+ ),
),
const SizedBox(height: 24.0),
- Text(
- 'Caption2',
- style: tertiaryTypography.caption2,
- ),
+ Text('Caption2', style: tertiaryTypography.caption2),
const SizedBox(height: 8.0),
Text(
'Caption2',
- style: tertiaryTypography.caption2
- .copyWith(fontWeight: MacosFontWeight.w590),
+ style: tertiaryTypography.caption2.copyWith(
+ fontWeight: MacosFontWeight.w590,
+ ),
),
],
),
diff --git a/example/lib/platform_menus.dart b/example/lib/platform_menus.dart
index 91ba6a7c..3e920e32 100644
--- a/example/lib/platform_menus.dart
+++ b/example/lib/platform_menus.dart
@@ -17,12 +17,8 @@ List menuBarItems() {
PlatformMenu(
label: 'macos_ui Widget Gallery',
menus: [
- PlatformProvidedMenuItem(
- type: PlatformProvidedMenuItemType.about,
- ),
- PlatformProvidedMenuItem(
- type: PlatformProvidedMenuItemType.quit,
- ),
+ PlatformProvidedMenuItem(type: PlatformProvidedMenuItemType.about),
+ PlatformProvidedMenuItem(type: PlatformProvidedMenuItemType.quit),
],
),
PlatformMenu(
diff --git a/example/lib/widgets/widget_text_title1.dart b/example/lib/widgets/widget_text_title1.dart
index 77ab7314..121e0131 100644
--- a/example/lib/widgets/widget_text_title1.dart
+++ b/example/lib/widgets/widget_text_title1.dart
@@ -11,18 +11,16 @@ class WidgetTextTitle1 extends StatelessWidget {
Widget build(BuildContext context) {
return DecoratedBox(
decoration: BoxDecoration(
- color: MacosColors.systemGrayColor.withOpacity(0.5),
+ color: MacosColors.systemGrayColor.withValues(alpha: 0.5),
borderRadius: BorderRadius.circular(4.0),
),
child: Padding(
- padding: const EdgeInsets.symmetric(
- horizontal: 6.0,
- ),
+ padding: const EdgeInsets.symmetric(horizontal: 6.0),
child: Text(
widgetName,
- style: MacosTypography.of(context)
- .title1
- .copyWith(fontFamily: GoogleFonts.jetBrainsMono().fontFamily),
+ style: MacosTypography.of(
+ context,
+ ).title1.copyWith(fontFamily: GoogleFonts.jetBrainsMono().fontFamily),
),
),
);
diff --git a/example/lib/widgets/widget_text_title2.dart b/example/lib/widgets/widget_text_title2.dart
index 8da1135d..943e5025 100644
--- a/example/lib/widgets/widget_text_title2.dart
+++ b/example/lib/widgets/widget_text_title2.dart
@@ -11,18 +11,16 @@ class WidgetTextTitle2 extends StatelessWidget {
Widget build(BuildContext context) {
return DecoratedBox(
decoration: BoxDecoration(
- color: MacosColors.systemGrayColor.withOpacity(0.5),
+ color: MacosColors.systemGrayColor.withValues(alpha: 0.5),
borderRadius: BorderRadius.circular(4.0),
),
child: Padding(
- padding: const EdgeInsets.symmetric(
- horizontal: 6.0,
- ),
+ padding: const EdgeInsets.symmetric(horizontal: 6.0),
child: Text(
widgetName,
- style: MacosTypography.of(context)
- .title2
- .copyWith(fontFamily: GoogleFonts.jetBrainsMono().fontFamily),
+ style: MacosTypography.of(
+ context,
+ ).title2.copyWith(fontFamily: GoogleFonts.jetBrainsMono().fontFamily),
),
),
);
diff --git a/example/macos/Podfile.lock b/example/macos/Podfile.lock
index 475f42a3..b40e00de 100644
--- a/example/macos/Podfile.lock
+++ b/example/macos/Podfile.lock
@@ -35,13 +35,13 @@ EXTERNAL SOURCES:
:path: Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos
SPEC CHECKSUMS:
- appkit_ui_element_colors: 39bb2d80be3f19b152ccf4c70d5bbe6cba43d74a
- FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24
- macos_ui: 6229a8922cd97bafb7d9636c8eb8dfb0744183ca
- macos_window_utils: 933f91f64805e2eb91a5bd057cf97cd097276663
+ appkit_ui_element_colors: bb247a2d02b8313cc47e1b83be48d996034c4001
+ FlutterMacOS: d0db08ddef1a9af05a5ec4b724367152bb0500b1
+ macos_ui: 50a2048b7ef82bde42570e2775f50907537a0eeb
+ macos_window_utils: 721df4da91cb4bde7b2b7b6ae93cdead4851118f
path_provider_foundation: 2b6b4c569c0fb62ec74538f866245ac84301af46
- url_launcher_macos: 5f437abeda8c85500ceb03f5c1938a8c5a705399
+ url_launcher_macos: c82c93949963e55b228a30115bd219499a6fe404
PODFILE CHECKSUM: ff0a9a3ce75ee73f200ca7e2f47745698c917ef9
-COCOAPODS: 1.14.3
+COCOAPODS: 1.15.2
diff --git a/example/macos/Runner.xcodeproj/project.pbxproj b/example/macos/Runner.xcodeproj/project.pbxproj
index 717c51d9..d130c440 100644
--- a/example/macos/Runner.xcodeproj/project.pbxproj
+++ b/example/macos/Runner.xcodeproj/project.pbxproj
@@ -27,6 +27,7 @@
33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; };
33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; };
841463C0F24F8E3B273A97BD /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 22FC83C884F4624B8C19DB88 /* Pods_Runner.framework */; };
+ 78A318202AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage in Frameworks */ = {isa = PBXBuildFile; productRef = 78A3181F2AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@@ -80,6 +81,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
+ 78A318202AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage in Frameworks */,
841463C0F24F8E3B273A97BD /* Pods_Runner.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
@@ -174,6 +176,9 @@
/* Begin PBXNativeTarget section */
33CC10EC2044A3C60003C045 /* Runner */ = {
+ packageProductDependencies = (
+ 78A3181F2AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage */,
+ );
isa = PBXNativeTarget;
buildConfigurationList = 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */;
buildPhases = (
@@ -199,6 +204,9 @@
/* Begin PBXProject section */
33CC10E52044A3C60003C045 /* Project object */ = {
+ packageReferences = (
+ 781AD8BC2B33823900A9FFBB /* XCLocalSwiftPackageReference "Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage" */,
+ );
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0920;
@@ -627,6 +635,18 @@
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
+/* Begin XCLocalSwiftPackageReference section */
+ 781AD8BC2B33823900A9FFBB /* XCLocalSwiftPackageReference "Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage" */ = {
+ isa = XCLocalSwiftPackageReference;
+ relativePath = Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage;
+ };
+/* End XCLocalSwiftPackageReference section */
+/* Begin XCSwiftPackageProductDependency section */
+ 78A3181F2AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage */ = {
+ isa = XCSwiftPackageProductDependency;
+ productName = FlutterGeneratedPluginSwiftPackage;
+ };
+/* End XCSwiftPackageProductDependency section */
};
rootObject = 33CC10E52044A3C60003C045 /* Project object */;
}
diff --git a/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme
index 5b055a3a..8b5a3a28 100644
--- a/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme
+++ b/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme
@@ -5,6 +5,24 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/example/macos/Runner/AppDelegate.swift b/example/macos/Runner/AppDelegate.swift
index 8e02df28..b3c17614 100644
--- a/example/macos/Runner/AppDelegate.swift
+++ b/example/macos/Runner/AppDelegate.swift
@@ -6,4 +6,8 @@ class AppDelegate: FlutterAppDelegate {
override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
return true
}
+
+ override func applicationSupportsSecureRestorableState(_ app: NSApplication) -> Bool {
+ return true
+ }
}
diff --git a/example/pubspec.lock b/example/pubspec.lock
index 640f7187..fe0fd510 100644
--- a/example/pubspec.lock
+++ b/example/pubspec.lock
@@ -5,58 +5,58 @@ packages:
dependency: transitive
description:
name: appkit_ui_element_colors
- sha256: c3e50f900aae314d339de489535736238627071457c4a4a2dbbb1545b4f04f22
+ sha256: b88a7c35d440fa3ac75222d0e2b7e3259200e531e33b5d2468e358119f3481dc
url: "https://pub.dev"
source: hosted
- version: "1.0.0"
+ version: "1.0.1"
async:
dependency: transitive
description:
name: async
- sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c"
+ sha256: "758e6d74e971c3e5aceb4110bfd6698efc7f501675bcfe0c775459a8140750eb"
url: "https://pub.dev"
source: hosted
- version: "2.11.0"
+ version: "2.13.0"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
- sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66"
+ sha256: "8aab1771e1243a5063b8b0ff68042d67334e3feab9e95b9490f9a6ebf73b42ea"
url: "https://pub.dev"
source: hosted
- version: "2.1.1"
+ version: "2.1.2"
characters:
dependency: transitive
description:
name: characters
- sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605"
+ sha256: f71061c654a3380576a52b451dd5532377954cf9dbd272a78fc8479606670803
url: "https://pub.dev"
source: hosted
- version: "1.3.0"
+ version: "1.4.0"
clock:
dependency: transitive
description:
name: clock
- sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf
+ sha256: fddb70d9b5277016c77a80201021d40a2247104d9f4aa7bab7157b7e3f05b84b
url: "https://pub.dev"
source: hosted
- version: "1.1.1"
+ version: "1.1.2"
collection:
dependency: transitive
description:
name: collection
- sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
+ sha256: "2f5709ae4d3d59dd8f7cd309b4e023046b57d8a6c82130785d2b0e5868084e76"
url: "https://pub.dev"
source: hosted
- version: "1.18.0"
+ version: "1.19.1"
crypto:
dependency: transitive
description:
name: crypto
- sha256: ec30d999af904f33454ba22ed9a86162b35e52b44ac4807d1d93c288041d7d27
+ sha256: "1e445881f28f22d6140f181e07737b22f1e099a5e1ff94b0af2f9e4a463f4855"
url: "https://pub.dev"
source: hosted
- version: "3.0.5"
+ version: "3.0.6"
cupertino_icons:
dependency: "direct main"
description:
@@ -69,26 +69,26 @@ packages:
dependency: transitive
description:
name: equatable
- sha256: c2b87cb7756efdf69892005af546c56c0b5037f54d2a88269b4f347a505e3ca2
+ sha256: "567c64b3cb4cf82397aac55f4f0cbd3ca20d77c6c03bedbc4ceaddc08904aef7"
url: "https://pub.dev"
source: hosted
- version: "2.0.5"
+ version: "2.0.7"
fake_async:
dependency: transitive
description:
name: fake_async
- sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78"
+ sha256: "5368f224a74523e8d2e7399ea1638b37aecfca824a3cc4dfdf77bf1fa905ac44"
url: "https://pub.dev"
source: hosted
- version: "1.3.1"
+ version: "1.3.3"
ffi:
dependency: transitive
description:
name: ffi
- sha256: "16ed7b077ef01ad6170a3d0c57caa4a112a38d7a2ed5602e0aca9ca6f3d98da6"
+ sha256: "289279317b4b16eb2bb7e271abccd4bf84ec9bdcbe999e278a94b804f5630418"
url: "https://pub.dev"
source: hosted
- version: "2.1.3"
+ version: "2.1.4"
flutter:
dependency: "direct main"
description: flutter
@@ -98,10 +98,10 @@ packages:
dependency: "direct dev"
description:
name: flutter_lints
- sha256: "3f41d009ba7172d5ff9be5f6e6e6abb4300e263aab8866d2a0842ed2a70f8f0c"
+ sha256: "3105dc8492f6183fb076ccf1f351ac3d60564bff92e20bfc4af9cc1651f4e7e1"
url: "https://pub.dev"
source: hosted
- version: "4.0.0"
+ version: "6.0.0"
flutter_test:
dependency: "direct dev"
description: flutter
@@ -116,89 +116,89 @@ packages:
dependency: "direct main"
description:
name: google_fonts
- sha256: b1ac0fe2832c9cc95e5e88b57d627c5e68c223b9657f4b96e1487aa9098c7b82
+ sha256: "517b20870220c48752eafa0ba1a797a092fb22df0d89535fd9991e86ee2cdd9c"
url: "https://pub.dev"
source: hosted
- version: "6.2.1"
+ version: "6.3.2"
gradient_borders:
dependency: transitive
description:
name: gradient_borders
- sha256: b1cd969552c83f458ff755aa68e13a0327d09f06c3f42f471b423b01427f21f8
+ sha256: "492bc88ab8d88a4117a7f00e525a669b65f19973bea7ee677f9d9de7603bf037"
url: "https://pub.dev"
source: hosted
- version: "1.0.1"
+ version: "1.0.2"
http:
dependency: transitive
description:
name: http
- sha256: b9c29a161230ee03d3ccf545097fccd9b87a5264228c5d348202e0f0c28f9010
+ sha256: "2c11f3f94c687ee9bad77c171151672986360b2b001d109814ee7140b2cf261b"
url: "https://pub.dev"
source: hosted
- version: "1.2.2"
+ version: "1.4.0"
http_parser:
dependency: transitive
description:
name: http_parser
- sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b"
+ sha256: "178d74305e7866013777bab2c3d8726205dc5a4dd935297175b19a23a2e66571"
url: "https://pub.dev"
source: hosted
- version: "4.0.2"
+ version: "4.1.2"
leak_tracker:
dependency: transitive
description:
name: leak_tracker
- sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05"
+ sha256: "33e2e26bdd85a0112ec15400c8cbffea70d0f9c3407491f672a2fad47915e2de"
url: "https://pub.dev"
source: hosted
- version: "10.0.5"
+ version: "11.0.2"
leak_tracker_flutter_testing:
dependency: transitive
description:
name: leak_tracker_flutter_testing
- sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806"
+ sha256: "1dbc140bb5a23c75ea9c4811222756104fbcd1a27173f0c34ca01e16bea473c1"
url: "https://pub.dev"
source: hosted
- version: "3.0.5"
+ version: "3.0.10"
leak_tracker_testing:
dependency: transitive
description:
name: leak_tracker_testing
- sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3"
+ sha256: "8d5a2d49f4a66b49744b23b018848400d23e54caf9463f4eb20df3eb8acb2eb1"
url: "https://pub.dev"
source: hosted
- version: "3.0.1"
+ version: "3.0.2"
lints:
dependency: transitive
description:
name: lints
- sha256: "976c774dd944a42e83e2467f4cc670daef7eed6295b10b36ae8c85bcbf828235"
+ sha256: a5e2b223cb7c9c8efdc663ef484fdd95bb243bff242ef5b13e26883547fce9a0
url: "https://pub.dev"
source: hosted
- version: "4.0.0"
+ version: "6.0.0"
macos_ui:
dependency: "direct main"
description:
path: ".."
relative: true
source: path
- version: "2.1.0"
+ version: "2.2.1"
macos_window_utils:
dependency: transitive
description:
name: macos_window_utils
- sha256: "230be594d26f6dee92c5a1544f4242d25138a5bfb9f185b27f14de3949ef0be8"
+ sha256: d4df3501fd32ac0d2d7590cb6a8e4758337d061c8fa0db816fdd636be63a8438
url: "https://pub.dev"
source: hosted
- version: "1.5.0"
+ version: "1.9.0"
matcher:
dependency: transitive
description:
name: matcher
- sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb
+ sha256: dc58c723c3c24bf8d3e2d3ad3f2f9d7bd9cf43ec6feaa64181775e60190153f2
url: "https://pub.dev"
source: hosted
- version: "0.12.16+1"
+ version: "0.12.17"
material_color_utilities:
dependency: transitive
description:
@@ -211,10 +211,10 @@ packages:
dependency: transitive
description:
name: meta
- sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7
+ sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c
url: "https://pub.dev"
source: hosted
- version: "1.15.0"
+ version: "1.16.0"
nested:
dependency: transitive
description:
@@ -227,34 +227,34 @@ packages:
dependency: transitive
description:
name: path
- sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af"
+ sha256: "75cca69d1490965be98c73ceaea117e8a04dd21217b37b292c9ddbec0d955bc5"
url: "https://pub.dev"
source: hosted
- version: "1.9.0"
+ version: "1.9.1"
path_provider:
dependency: transitive
description:
name: path_provider
- sha256: fec0d61223fba3154d87759e3cc27fe2c8dc498f6386c6d6fc80d1afdd1bf378
+ sha256: "50c5dd5b6e1aaf6fb3a78b33f6aa3afca52bf903a8a5298f53101fdaee55bbcd"
url: "https://pub.dev"
source: hosted
- version: "2.1.4"
+ version: "2.1.5"
path_provider_android:
dependency: transitive
description:
name: path_provider_android
- sha256: "6f01f8e37ec30b07bc424b4deabac37cacb1bc7e2e515ad74486039918a37eb7"
+ sha256: d0d310befe2c8ab9e7f393288ccbb11b60c019c6b5afc21973eeee4dda2b35e9
url: "https://pub.dev"
source: hosted
- version: "2.2.10"
+ version: "2.2.17"
path_provider_foundation:
dependency: transitive
description:
name: path_provider_foundation
- sha256: f234384a3fdd67f989b4d54a5d73ca2a6c422fa55ae694381ae0f4375cd1ea16
+ sha256: "4843174df4d288f5e29185bd6e72a6fbdf5a4a4602717eed565497429f179942"
url: "https://pub.dev"
source: hosted
- version: "2.4.0"
+ version: "2.4.1"
path_provider_linux:
dependency: transitive
description:
@@ -283,10 +283,10 @@ packages:
dependency: transitive
description:
name: platform
- sha256: "9b71283fc13df574056616011fb138fd3b793ea47cc509c189a6c3fa5f8a1a65"
+ sha256: "5d6b1b0036a5f331ebc77c850ebc8506cbc1e9416c27e59b439f917a902a4984"
url: "https://pub.dev"
source: hosted
- version: "3.1.5"
+ version: "3.1.6"
plugin_platform_interface:
dependency: transitive
description:
@@ -299,111 +299,111 @@ packages:
dependency: "direct main"
description:
name: provider
- sha256: c8a055ee5ce3fd98d6fc872478b03823ffdb448699c6ebdbbc71d59b596fd48c
+ sha256: "4abbd070a04e9ddc287673bf5a030c7ca8b685ff70218720abab8b092f53dd84"
url: "https://pub.dev"
source: hosted
- version: "6.1.2"
+ version: "6.1.5"
sky_engine:
dependency: transitive
description: flutter
source: sdk
- version: "0.0.99"
+ version: "0.0.0"
source_span:
dependency: transitive
description:
name: source_span
- sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c"
+ sha256: "254ee5351d6cb365c859e20ee823c3bb479bf4a293c22d17a9f1bf144ce86f7c"
url: "https://pub.dev"
source: hosted
- version: "1.10.0"
+ version: "1.10.1"
stack_trace:
dependency: transitive
description:
name: stack_trace
- sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b"
+ sha256: "8b27215b45d22309b5cddda1aa2b19bdfec9df0e765f2de506401c071d38d1b1"
url: "https://pub.dev"
source: hosted
- version: "1.11.1"
+ version: "1.12.1"
stream_channel:
dependency: transitive
description:
name: stream_channel
- sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7
+ sha256: "969e04c80b8bcdf826f8f16579c7b14d780458bd97f56d107d3950fdbeef059d"
url: "https://pub.dev"
source: hosted
- version: "2.1.2"
+ version: "2.1.4"
string_scanner:
dependency: transitive
description:
name: string_scanner
- sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde"
+ sha256: "921cd31725b72fe181906c6a94d987c78e3b98c2e205b397ea399d4054872b43"
url: "https://pub.dev"
source: hosted
- version: "1.2.0"
+ version: "1.4.1"
term_glyph:
dependency: transitive
description:
name: term_glyph
- sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84
+ sha256: "7f554798625ea768a7518313e58f83891c7f5024f88e46e7182a4558850a4b8e"
url: "https://pub.dev"
source: hosted
- version: "1.2.1"
+ version: "1.2.2"
test_api:
dependency: transitive
description:
name: test_api
- sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb"
+ sha256: "522f00f556e73044315fa4585ec3270f1808a4b186c936e612cab0b565ff1e00"
url: "https://pub.dev"
source: hosted
- version: "0.7.2"
+ version: "0.7.6"
typed_data:
dependency: transitive
description:
name: typed_data
- sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c
+ sha256: f9049c039ebfeb4cf7a7104a675823cd72dba8297f264b6637062516699fa006
url: "https://pub.dev"
source: hosted
- version: "1.3.2"
+ version: "1.4.0"
url_launcher:
dependency: "direct main"
description:
name: url_launcher
- sha256: "21b704ce5fa560ea9f3b525b43601c678728ba46725bab9b01187b4831377ed3"
+ sha256: f6a7e5c4835bb4e3026a04793a4199ca2d14c739ec378fdfe23fc8075d0439f8
url: "https://pub.dev"
source: hosted
- version: "6.3.0"
+ version: "6.3.2"
url_launcher_android:
dependency: transitive
description:
name: url_launcher_android
- sha256: e35a698ac302dd68e41f73250bd9517fe3ab5fa4f18fe4647a0872db61bacbab
+ sha256: "8582d7f6fe14d2652b4c45c9b6c14c0b678c2af2d083a11b604caeba51930d79"
url: "https://pub.dev"
source: hosted
- version: "6.3.10"
+ version: "6.3.16"
url_launcher_ios:
dependency: transitive
description:
name: url_launcher_ios
- sha256: e43b677296fadce447e987a2f519dcf5f6d1e527dc35d01ffab4fff5b8a7063e
+ sha256: "7f2022359d4c099eea7df3fdf739f7d3d3b9faf3166fb1dd390775176e0b76cb"
url: "https://pub.dev"
source: hosted
- version: "6.3.1"
+ version: "6.3.3"
url_launcher_linux:
dependency: transitive
description:
name: url_launcher_linux
- sha256: e2b9622b4007f97f504cd64c0128309dfb978ae66adbe944125ed9e1750f06af
+ sha256: "4e9ba368772369e3e08f231d2301b4ef72b9ff87c31192ef471b380ef29a4935"
url: "https://pub.dev"
source: hosted
- version: "3.2.0"
+ version: "3.2.1"
url_launcher_macos:
dependency: transitive
description:
name: url_launcher_macos
- sha256: "9a1a42d5d2d95400c795b2914c36fdcb525870c752569438e4ebb09a2b5d90de"
+ sha256: "17ba2000b847f334f16626a574c702b196723af2a289e7a93ffcb79acff855c2"
url: "https://pub.dev"
source: hosted
- version: "3.2.0"
+ version: "3.2.2"
url_launcher_platform_interface:
dependency: transitive
description:
@@ -416,50 +416,50 @@ packages:
dependency: transitive
description:
name: url_launcher_web
- sha256: "772638d3b34c779ede05ba3d38af34657a05ac55b06279ea6edd409e323dca8e"
+ sha256: "4bd2b7b4dc4d4d0b94e5babfffbca8eac1a126c7f3d6ecbc1a11013faa3abba2"
url: "https://pub.dev"
source: hosted
- version: "2.3.3"
+ version: "2.4.1"
url_launcher_windows:
dependency: transitive
description:
name: url_launcher_windows
- sha256: "49c10f879746271804767cb45551ec5592cdab00ee105c06dddde1a98f73b185"
+ sha256: "3284b6d2ac454cf34f114e1d3319866fdd1e19cdc329999057e44ffe936cfa77"
url: "https://pub.dev"
source: hosted
- version: "3.1.2"
+ version: "3.1.4"
vector_math:
dependency: transitive
description:
name: vector_math
- sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803"
+ sha256: d530bd74fea330e6e364cda7a85019c434070188383e1cd8d9777ee586914c5b
url: "https://pub.dev"
source: hosted
- version: "2.1.4"
+ version: "2.2.0"
vm_service:
dependency: transitive
description:
name: vm_service
- sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d"
+ sha256: ddfa8d30d89985b96407efce8acbdd124701f96741f2d981ca860662f1c0dc02
url: "https://pub.dev"
source: hosted
- version: "14.2.5"
+ version: "15.0.0"
web:
dependency: transitive
description:
name: web
- sha256: d43c1d6b787bf0afad444700ae7f4db8827f701bc61c255ac8d328c6f4d52062
+ sha256: "868d88a33d8a87b18ffc05f9f030ba328ffefba92d6c127917a2ba740f9cfe4a"
url: "https://pub.dev"
source: hosted
- version: "1.0.0"
+ version: "1.1.1"
xdg_directories:
dependency: transitive
description:
name: xdg_directories
- sha256: faea9dee56b520b55a566385b84f2e8de55e7496104adada9962e0bd11bcff1d
+ sha256: "7a3f37b05d989967cdddcbb571f1ea834867ae2faa29725fd085180e0883aa15"
url: "https://pub.dev"
source: hosted
- version: "1.0.4"
+ version: "1.1.0"
sdks:
- dart: ">=3.5.3 <4.0.0"
- flutter: ">=3.24.0"
+ dart: ">=3.9.2 <4.0.0"
+ flutter: ">=3.35.0"
diff --git a/example/pubspec.yaml b/example/pubspec.yaml
index 22e45eb8..d57e3877 100644
--- a/example/pubspec.yaml
+++ b/example/pubspec.yaml
@@ -4,7 +4,7 @@ publish_to: 'none'
version: 1.0.0+1
environment:
- sdk: '>=3.5.3 <4.0.0'
+ sdk: '>=3.9.2 <4.0.0'
dependencies:
flutter:
@@ -13,14 +13,14 @@ dependencies:
cupertino_icons: ^1.0.8
macos_ui:
path: ..
- provider: ^6.1.2
- google_fonts: ^6.2.1
- url_launcher: ^6.3.0
+ provider: ^6.1.5
+ google_fonts: ^6.3.2
+ url_launcher: ^6.3.2
dev_dependencies:
flutter_test:
sdk: flutter
- flutter_lints: ^4.0.0
+ flutter_lints: ^6.0.0
flutter:
assets:
diff --git a/lib/macos_ui.dart b/lib/macos_ui.dart
index d47a163a..e0a5adcc 100644
--- a/lib/macos_ui.dart
+++ b/lib/macos_ui.dart
@@ -12,7 +12,7 @@
/// * [yaru_icons](https://pub.dev/packages/yaru_icons)
/// * [yaru_colors](https://pub.dev/packages/yaru_colors)
-library macos_ui;
+library;
export 'package:macos_window_utils/macos/ns_window_delegate.dart';
export 'package:macos_window_utils/macos_window_utils.dart';
@@ -89,3 +89,5 @@ export 'src/theme/time_picker_theme.dart';
export 'src/theme/tooltip_theme.dart';
export 'src/theme/typography.dart';
export 'src/enums/accent_color.dart';
+export 'src/utils/window_main_state_listener.dart';
+export 'src/utils/accent_color_listener.dart';
diff --git a/lib/src/buttons/back_button.dart b/lib/src/buttons/back_button.dart
index 605356a4..7882b168 100644
--- a/lib/src/buttons/back_button.dart
+++ b/lib/src/buttons/back_button.dart
@@ -41,11 +41,9 @@ class MacosBackButton extends StatefulWidget {
properties.add(ColorProperty('fillColor', fillColor));
properties.add(ColorProperty('hoverColor', fillColor));
properties.add(StringProperty('semanticLabel', semanticLabel));
- properties.add(FlagProperty(
- 'enabled',
- value: enabled,
- ifFalse: 'disabled',
- ));
+ properties.add(
+ FlagProperty('enabled', value: enabled, ifFalse: 'disabled'),
+ );
}
@override
@@ -191,11 +189,11 @@ class MacosBackButtonState extends State
decoration: BoxDecoration(
color: buttonHeldDown
? brightness == Brightness.dark
- ? const Color(0xff3C383C)
- : const Color(0xffE5E5E5)
+ ? const Color(0xff3C383C)
+ : const Color(0xffE5E5E5)
: _isHovered
- ? hoverColor
- : fillColor,
+ ? hoverColor
+ : fillColor,
borderRadius: const BorderRadius.all(Radius.circular(7)),
),
child: Icon(
diff --git a/lib/src/buttons/checkbox.dart b/lib/src/buttons/checkbox.dart
index 2d21e7c7..9695a500 100644
--- a/lib/src/buttons/checkbox.dart
+++ b/lib/src/buttons/checkbox.dart
@@ -58,19 +58,19 @@ class MacosCheckbox extends StatelessWidget {
@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
- properties.add(StringProperty(
- 'state',
- isMixed
- ? 'mixed'
- : value!
- ? 'checked'
- : 'unchecked',
- ));
- properties.add(FlagProperty(
- 'disabled',
- value: isDisabled,
- ifFalse: 'enabled',
- ));
+ properties.add(
+ StringProperty(
+ 'state',
+ isMixed
+ ? 'mixed'
+ : value!
+ ? 'checked'
+ : 'unchecked',
+ ),
+ );
+ properties.add(
+ FlagProperty('disabled', value: isDisabled, ifFalse: 'enabled'),
+ );
properties.add(DoubleProperty('size', size));
properties.add(ColorProperty('activeColor', activeColor));
properties.add(ColorProperty('disabledColor', disabledColor));
@@ -84,49 +84,50 @@ class MacosCheckbox extends StatelessWidget {
final MacosThemeData theme = MacosTheme.of(context);
bool isLight = !theme.brightness.isDark;
return StreamBuilder(
- stream: AccentColorListener.instance.onChanged,
- builder: (context, _) {
- return StreamBuilder(
- stream: WindowMainStateListener.instance.onChanged,
- builder: (context, _) {
- final accentColor =
- MacosTheme.of(context).accentColor ?? AccentColor.blue;
- final isMainWindow =
- MacosTheme.of(context).isMainWindow ?? true;
-
- return GestureDetector(
- onTap: () {
- if (value == null || value == false) {
- onChanged?.call(true);
- } else {
- onChanged?.call(false);
- }
- },
- child: Semantics(
- // value == true because [value] can be null
- checked: value == true,
- label: semanticLabel,
- child: Container(
- height: size,
- width: size,
- alignment: Alignment.center,
- child: SizedBox.expand(
- child: _DecoratedContainer(
- accentColor: accentColor,
- isDisabled: isDisabled,
- isLight: isLight,
- isMainWindow: isMainWindow,
- value: value,
- isMixed: isMixed,
- theme: theme,
- size: size,
- ),
- ),
+ stream: AccentColorListener.instance.onChanged,
+ builder: (context, _) {
+ return StreamBuilder(
+ stream: WindowMainStateListener.instance.onChanged,
+ builder: (context, _) {
+ final accentColor =
+ MacosTheme.of(context).accentColor ?? AccentColor.blue;
+ final isMainWindow = MacosTheme.of(context).isMainWindow ?? true;
+
+ return GestureDetector(
+ onTap: () {
+ if (value == null || value == false) {
+ onChanged?.call(true);
+ } else {
+ onChanged?.call(false);
+ }
+ },
+ child: Semantics(
+ // value == true because [value] can be null
+ checked: value == true,
+ label: semanticLabel,
+ child: Container(
+ height: size,
+ width: size,
+ alignment: Alignment.center,
+ child: SizedBox.expand(
+ child: _DecoratedContainer(
+ accentColor: accentColor,
+ isDisabled: isDisabled,
+ isLight: isLight,
+ isMainWindow: isMainWindow,
+ value: value,
+ isMixed: isMixed,
+ theme: theme,
+ size: size,
),
),
- );
- });
- });
+ ),
+ ),
+ );
+ },
+ );
+ },
+ );
}
}
@@ -192,20 +193,35 @@ class _CheckboxStack extends StatelessWidget {
final bool isMainWindow;
final double size;
+ Color _getCheckmarkColor() {
+ if (isDisabled) {
+ return const MacosColor.fromRGBO(172, 172, 172, 1.0);
+ }
+
+ if (theme.brightness.isDark) {
+ return theme.accentColor == AccentColor.graphite && isMainWindow
+ ? MacosColors.black
+ : MacosColors.white;
+ }
+
+ if (theme.isMainWindow == false) {
+ return MacosColors.black;
+ }
+
+ return MacosColors.white;
+ }
+
@override
Widget build(BuildContext context) {
final icon = value == false
? null
: isMixed
- ? CupertinoIcons.minus
- : CupertinoIcons.checkmark;
+ ? CupertinoIcons.minus
+ : CupertinoIcons.checkmark;
return Stack(
children: [
- _InnerDropShadow(
- value: value,
- isEnabled: !isDisabled,
- ),
+ _InnerDropShadow(value: value, isEnabled: !isDisabled),
Center(
child: Icon(
icon,
@@ -216,24 +232,6 @@ class _CheckboxStack extends StatelessWidget {
],
);
}
-
- _getCheckmarkColor() {
- if (isDisabled) {
- return const MacosColor.fromRGBO(172, 172, 172, 1.0);
- }
-
- if (theme.brightness.isDark) {
- return theme.accentColor == AccentColor.graphite && isMainWindow
- ? CupertinoColors.black
- : CupertinoColors.white;
- }
-
- if (theme.isMainWindow == false) {
- return CupertinoColors.black;
- }
-
- return CupertinoColors.white;
- }
}
/// A widget that paints an inner drop shadow for the checkbox in light mode.
@@ -245,10 +243,7 @@ class _InnerDropShadow extends StatelessWidget {
final bool isEnabled;
/// Creates a widget that paints an inner drop shadow for a checkbox.
- const _InnerDropShadow({
- required this.value,
- required this.isEnabled,
- });
+ const _InnerDropShadow({required this.value, required this.isEnabled});
@override
Widget build(BuildContext context) {
@@ -310,10 +305,7 @@ class _BoxDecorationBuilder {
MacosColor.fromRGBO(74, 74, 74, 1.0 * isEnabledFactor),
MacosColor.fromRGBO(101, 101, 101, 1.0 * isEnabledFactor),
]
- : const [
- MacosColors.transparent,
- MacosColors.transparent,
- ];
+ : const [MacosColors.transparent, MacosColors.transparent];
}
if (isDarkModeEnabled) {
@@ -365,9 +357,6 @@ class _BoxDecorationBuilder {
MacosColor.fromRGBO(148, 148, 148, 1.0 * isEnabledFactor),
MacosColor.fromRGBO(148, 148, 148, 1.0 * isEnabledFactor),
];
-
- default:
- throw UnimplementedError();
}
} else {
switch (accentColor) {
@@ -418,9 +407,6 @@ class _BoxDecorationBuilder {
MacosColor.fromRGBO(86, 86, 86, 1.0 * isEnabledFactor),
MacosColor.fromRGBO(55, 55, 55, 1.0 * isEnabledFactor),
];
-
- default:
- throw UnimplementedError();
}
}
}
@@ -443,7 +429,7 @@ class _BoxDecorationBuilder {
spreadRadius: -0.5,
offset: Offset(0.0, 0.5),
blurStyle: BlurStyle.outer,
- )
+ ),
]
: const [];
diff --git a/lib/src/buttons/disclosure_button.dart b/lib/src/buttons/disclosure_button.dart
index 5cef6e0e..6f8a9bee 100644
--- a/lib/src/buttons/disclosure_button.dart
+++ b/lib/src/buttons/disclosure_button.dart
@@ -44,11 +44,9 @@ class MacosDisclosureButton extends StatefulWidget {
properties.add(ColorProperty('fillColor', fillColor));
properties.add(ColorProperty('hoverColor', fillColor));
properties.add(StringProperty('semanticLabel', semanticLabel));
- properties.add(FlagProperty(
- 'enabled',
- value: enabled,
- ifFalse: 'disabled',
- ));
+ properties.add(
+ FlagProperty('enabled', value: enabled, ifFalse: 'disabled'),
+ );
}
@override
@@ -161,10 +159,7 @@ class MacosDisclosureButtonState extends State
child: Semantics(
button: true,
child: ConstrainedBox(
- constraints: const BoxConstraints(
- minWidth: 20,
- minHeight: 20,
- ),
+ constraints: const BoxConstraints(minWidth: 20, minHeight: 20),
child: FadeTransition(
opacity: _opacityAnimation,
child: AnimatedBuilder(
@@ -174,8 +169,8 @@ class MacosDisclosureButtonState extends State
decoration: BoxDecoration(
color: buttonHeldDown
? brightness == Brightness.dark
- ? const MacosColor(0xff3C383C)
- : const MacosColor(0xffE5E5E5)
+ ? const MacosColor(0xff3C383C)
+ : const MacosColor(0xffE5E5E5)
: fillColor,
borderRadius: const BorderRadius.all(Radius.circular(7)),
),
diff --git a/lib/src/buttons/help_button.dart b/lib/src/buttons/help_button.dart
index f825baf5..4a269a6a 100644
--- a/lib/src/buttons/help_button.dart
+++ b/lib/src/buttons/help_button.dart
@@ -20,8 +20,10 @@ class HelpButton extends StatefulWidget {
this.alignment = Alignment.center,
this.semanticLabel,
this.mouseCursor = SystemMouseCursors.basic,
- }) : assert(pressedOpacity == null ||
- (pressedOpacity >= 0.0 && pressedOpacity <= 1.0));
+ }) : assert(
+ pressedOpacity == null ||
+ (pressedOpacity >= 0.0 && pressedOpacity <= 1.0),
+ );
/// The color of the button's background.
final Color? color;
@@ -172,8 +174,8 @@ class HelpButtonState extends State
final Color foregroundColor = widget.enabled
? helpIconLuminance(backgroundColor, theme.brightness.isDark)
: theme.brightness.isDark
- ? const Color.fromRGBO(255, 255, 255, 0.25)
- : const Color.fromRGBO(0, 0, 0, 0.25);
+ ? const Color.fromRGBO(255, 255, 255, 0.25)
+ : const Color.fromRGBO(0, 0, 0, 0.25);
return MouseRegion(
cursor: widget.mouseCursor!,
diff --git a/lib/src/buttons/icon_button.dart b/lib/src/buttons/icon_button.dart
index 88e8ef20..7a7379b1 100644
--- a/lib/src/buttons/icon_button.dart
+++ b/lib/src/buttons/icon_button.dart
@@ -25,8 +25,10 @@ class MacosIconButton extends StatefulWidget {
),
this.padding,
this.mouseCursor = SystemMouseCursors.basic,
- }) : assert(pressedOpacity == null ||
- (pressedOpacity >= 0.0 && pressedOpacity <= 1.0));
+ }) : assert(
+ pressedOpacity == null ||
+ (pressedOpacity >= 0.0 && pressedOpacity <= 1.0),
+ );
/// The widget to use as the icon.
///
@@ -215,10 +217,7 @@ class MacosIconButtonState extends State
final Color? disabledColor;
if (widget.disabledColor != null) {
- disabledColor = MacosDynamicColor.resolve(
- widget.disabledColor!,
- context,
- );
+ disabledColor = MacosDynamicColor.resolve(widget.disabledColor!, context);
} else {
disabledColor = theme.disabledColor;
}
@@ -253,13 +252,13 @@ class MacosIconButtonState extends State
borderRadius: widget.borderRadius != null
? widget.borderRadius
: widget.shape == BoxShape.rectangle
- ? const BorderRadius.all(Radius.circular(7))
- : null,
+ ? const BorderRadius.all(Radius.circular(7))
+ : null,
color: !enabled
? disabledColor
: _isHovered
- ? hoverColor
- : backgroundColor,
+ ? hoverColor
+ : backgroundColor,
),
child: Padding(
padding: padding,
@@ -267,10 +266,7 @@ class MacosIconButtonState extends State
alignment: widget.alignment,
widthFactor: 1.0,
heightFactor: 1.0,
- child: FittedBox(
- fit: BoxFit.scaleDown,
- child: widget.icon,
- ),
+ child: FittedBox(fit: BoxFit.scaleDown, child: widget.icon),
),
),
),
diff --git a/lib/src/buttons/popup_button.dart b/lib/src/buttons/popup_button.dart
index 8082f78c..e862d9c5 100644
--- a/lib/src/buttons/popup_button.dart
+++ b/lib/src/buttons/popup_button.dart
@@ -45,23 +45,36 @@ class _MacosPopupMenuItemButton extends StatefulWidget {
class _MacosPopupMenuItemButtonState
extends State<_MacosPopupMenuItemButton> {
- bool _isHovered = false;
+ final _focusNode = FocusNode();
+
+ bool _isFocused = false;
+
+ bool get _isHighlighted => _isFocused;
+
+ /// The last time the mouse entered this item.
+ static DateTime _lastMouseEnterTime = DateTime.now();
+
+ /// The last time the focus changed that wasnโt caused by the mouse.
+ static DateTime _lastNonMouseFocusChange = DateTime.now();
void _handleFocusChange(bool focused) {
if (focused) {
- final _MenuLimits menuLimits = widget.route.getMenuLimits(
- widget.buttonRect,
- widget.constraints.maxHeight,
- widget.itemIndex,
- );
- widget.route.scrollController!.animateTo(
- menuLimits.scrollOffset,
- curve: Curves.easeInOut,
- duration: const Duration(milliseconds: 100),
+ final timeSinceMouseEnter = DateTime.now().difference(
+ _lastMouseEnterTime,
);
- setState(() => _isHovered = true);
+ if (timeSinceMouseEnter > const Duration(milliseconds: 50)) {
+ _lastNonMouseFocusChange = DateTime.now();
+
+ final _MenuLimits menuLimits = widget.route.getMenuLimits(
+ widget.buttonRect,
+ widget.constraints.maxHeight,
+ widget.itemIndex,
+ );
+ widget.route.scrollController!.jumpTo(menuLimits.scrollOffset);
+ }
+ setState(() => _isFocused = true);
} else {
- setState(() => _isHovered = false);
+ setState(() => _isFocused = false);
}
}
@@ -71,10 +84,7 @@ class _MacosPopupMenuItemButtonState
popupMenuItem.onTap?.call();
- Navigator.pop(
- context,
- _MacosPopupRouteResult(popupMenuItem.value),
- );
+ Navigator.pop(context, _MacosPopupRouteResult(popupMenuItem.value));
}
@override
@@ -91,14 +101,21 @@ class _MacosPopupMenuItemButtonState
child = MouseRegion(
cursor: SystemMouseCursors.basic,
onEnter: (_) {
- setState(() => _isHovered = true);
- },
- onExit: (_) {
- setState(() => _isHovered = false);
+ final timeSinceLastNonMouseFocusChange = DateTime.now().difference(
+ _lastNonMouseFocusChange,
+ );
+ if (timeSinceLastNonMouseFocusChange <
+ const Duration(milliseconds: 200)) {
+ return;
+ }
+
+ _lastMouseEnterTime = DateTime.now();
+ FocusScope.of(context).requestFocus(_focusNode);
},
child: GestureDetector(
onTap: _handleOnTap,
child: Focus(
+ focusNode: _focusNode,
onKeyEvent: (FocusNode node, KeyEvent event) {
if (event.logicalKey == LogicalKeyboardKey.enter) {
_handleOnTap();
@@ -110,7 +127,7 @@ class _MacosPopupMenuItemButtonState
autofocus: widget.itemIndex == widget.route.selectedIndex,
child: Container(
decoration: BoxDecoration(
- color: _isHovered
+ color: _isHighlighted
? MacosPopupButtonTheme.of(context).highlightColor
: Colors.transparent,
borderRadius: _kBorderRadius,
@@ -123,7 +140,7 @@ class _MacosPopupMenuItemButtonState
child: MacosIcon(
CupertinoIcons.checkmark_alt,
size: 16.0,
- color: _isHovered
+ color: _isHighlighted
? MacosColors.white
: brightness.resolve(
MacosColors.black,
@@ -135,7 +152,7 @@ class _MacosPopupMenuItemButtonState
DefaultTextStyle(
style: TextStyle(
fontSize: 13.0,
- color: _isHovered
+ color: _isHighlighted
? MacosColors.white
: brightness.resolve(
MacosColors.black,
@@ -218,8 +235,10 @@ class _MacosPopupMenuState extends State<_MacosPopupMenu> {
widget.popupColor ?? MacosPopupButtonTheme.of(context).popupColor,
context,
);
- final caretColor =
- brightness.resolve(CupertinoColors.black, CupertinoColors.white);
+ final caretColor = brightness.resolve(
+ CupertinoColors.black,
+ CupertinoColors.white,
+ );
final itemsList = ListView.builder(
controller: widget.route.scrollController,
@@ -252,16 +271,16 @@ class _MacosPopupMenuState extends State<_MacosPopupMenu> {
setState(() {
_showTopCaret =
widget.route.scrollController!.position.extentBefore >
- widget.buttonRect.height;
+ widget.buttonRect.height;
_showBottomCaret =
widget.route.scrollController!.position.extentAfter >
- widget.buttonRect.height;
+ widget.buttonRect.height;
});
}
return true;
},
child: MacosOverlayFilter(
- color: popupColor?.withOpacity(0.25),
+ color: popupColor?.withValues(alpha: 0.25),
borderRadius: _kBorderRadius,
child: Column(
mainAxisSize: MainAxisSize.min,
@@ -286,9 +305,7 @@ class _MacosPopupMenuState extends State<_MacosPopupMenu> {
// Wrap the items list with an Expanded widget for to
// avoid height overflow when having a lot of items.
_showTopCaret || _showBottomCaret
- ? Expanded(
- child: itemsList,
- )
+ ? Expanded(child: itemsList)
: itemsList,
_showBottomCaret
? Container(
@@ -334,8 +351,10 @@ class _MacosPopupMenuRouteLayout extends SingleChildLayoutDelegate {
// The maximum height of a simple menu should be one or more rows less than
// the view height. This ensures a tappable area outside of the simple menu
// with which to dismiss the menu.
- double maxHeight =
- math.max(0.0, constraints.maxHeight - 2 * _kMenuItemHeight);
+ double maxHeight = math.max(
+ 0.0,
+ constraints.maxHeight - 2 * _kMenuItemHeight,
+ );
if (route.menuMaxHeight != null && route.menuMaxHeight! <= maxHeight) {
maxHeight = route.menuMaxHeight!;
}
@@ -351,8 +370,11 @@ class _MacosPopupMenuRouteLayout extends SingleChildLayoutDelegate {
@override
Offset getPositionForChild(Size size, Size childSize) {
- final _MenuLimits menuLimits =
- route.getMenuLimits(buttonRect, size.height, route.selectedIndex);
+ final _MenuLimits menuLimits = route.getMenuLimits(
+ buttonRect,
+ size.height,
+ route.selectedIndex,
+ );
assert(() {
final Rect container = Offset.zero & size;
@@ -434,9 +456,9 @@ class _MacosPopupRoute extends PopupRoute<_MacosPopupRouteResult> {
this.popupColor,
this.menuMaxHeight,
}) : itemHeights = List.filled(
- items.length,
- itemHeight ?? _kMinInteractiveDimension,
- );
+ items.length,
+ itemHeight ?? _kMinInteractiveDimension,
+ );
final List<_MenuItem> items;
final EdgeInsetsGeometry padding;
@@ -525,15 +547,19 @@ class _MacosPopupRoute extends PopupRoute<_MacosPopupRouteResult> {
// In this case, we want to change the menu limits to align with the top
// or bottom edge of the button.
final double topLimit = math.min(_kMenuItemHeight, buttonTop);
- final double bottomLimit =
- math.max(availableHeight - _kMenuItemHeight, buttonBottom);
+ final double bottomLimit = math.max(
+ availableHeight - _kMenuItemHeight,
+ buttonBottom,
+ );
- double menuTop = (buttonTop - selectedItemOffset) -
+ double menuTop =
+ (buttonTop - selectedItemOffset) -
(itemHeights[selectedIndex] - buttonRect.height) / 2.0;
double preferredMenuHeight = 8.0;
if (items.isNotEmpty) {
- preferredMenuHeight +=
- itemHeights.reduce((double total, double height) => total + height);
+ preferredMenuHeight += itemHeights.reduce(
+ (double total, double height) => total + height,
+ );
}
// If there are too many elements in the menu, we need to shrink it down
@@ -558,7 +584,8 @@ class _MacosPopupRoute extends PopupRoute<_MacosPopupRouteResult> {
if (menuBottom - itemHeights[selectedIndex] / 2.0 <
buttonBottom - buttonRect.height / 2.0) {
- menuBottom = buttonBottom -
+ menuBottom =
+ buttonBottom -
buttonRect.height / 2.0 +
itemHeights[selectedIndex] / 2.0;
menuTop = menuBottom - menuHeight;
@@ -579,9 +606,11 @@ class _MacosPopupRoute extends PopupRoute<_MacosPopupRouteResult> {
// set it instead to the maximum allowed scroll offset.
scrollOffset = math.min(scrollOffset, preferredMenuHeight - menuHeight);
}
- bool hasTopItemsNotShown = preferredMenuHeight > computedMaxHeight &&
+ bool hasTopItemsNotShown =
+ preferredMenuHeight > computedMaxHeight &&
scrollOffset > buttonRect.height / 2.0;
- bool hasBottomItemsNotShown = preferredMenuHeight > computedMaxHeight &&
+ bool hasBottomItemsNotShown =
+ preferredMenuHeight > computedMaxHeight &&
scrollOffset < buttonRect.height / 2.0;
assert((menuBottom - menuTop - menuHeight).abs() < precisionErrorTolerance);
@@ -630,10 +659,14 @@ class _MacosPopupRoutePage extends StatelessWidget {
// and all of the items' intrinsic heights are less than _kMinInteractiveDimension.
// Otherwise the initialScrollOffset is just a rough approximation based on
// treating the items as if their heights were all equal to _kMinInteractiveDimension.
- final _MenuLimits menuLimits =
- route.getMenuLimits(buttonRect, constraints.maxHeight, selectedIndex);
- route.scrollController ??=
- ScrollController(initialScrollOffset: menuLimits.scrollOffset);
+ final _MenuLimits menuLimits = route.getMenuLimits(
+ buttonRect,
+ constraints.maxHeight,
+ selectedIndex,
+ );
+ route.scrollController ??= ScrollController(
+ initialScrollOffset: menuLimits.scrollOffset,
+ );
final TextDirection? textDirection = Directionality.maybeOf(context);
final Widget menu = _MacosPopupMenu(
@@ -674,11 +707,8 @@ class _MacosPopupRoutePage extends StatelessWidget {
// selected item lines up with the vertical center of the popup button,
// as closely as possible.
class _MenuItem extends SingleChildRenderObjectWidget {
- const _MenuItem({
- super.key,
- required this.onLayout,
- required this.item,
- }) : super(child: item);
+ const _MenuItem({super.key, required this.onLayout, required this.item})
+ : super(child: item);
final ValueChanged onLayout;
final MacosPopupMenuItem? item;
@@ -844,20 +874,20 @@ class MacosPopupButton extends StatefulWidget {
this.popupColor,
this.menuMaxHeight,
this.alignment = AlignmentDirectional.centerStart,
- }) : assert(
- items == null ||
- items.isEmpty ||
- value == null ||
- items.where((MacosPopupMenuItem item) {
- return item.value == value;
- }).length ==
- 1,
- "There should be exactly one item with [MacosPopupButton]'s value: "
- '$value. \n'
- 'Either zero or 2 or more [MacosPopupMenuItem]s were detected '
- 'with the same value',
- ),
- assert(itemHeight == null || itemHeight >= _kMinInteractiveDimension);
+ }) : assert(
+ items == null ||
+ items.isEmpty ||
+ value == null ||
+ items.where((MacosPopupMenuItem item) {
+ return item.value == value;
+ }).length ==
+ 1,
+ "There should be exactly one item with [MacosPopupButton]'s value: "
+ '$value. \n'
+ 'Either zero or 2 or more [MacosPopupMenuItem]s were detected '
+ 'with the same value',
+ ),
+ assert(itemHeight == null || itemHeight >= _kMinInteractiveDimension);
/// The list of items the user can select.
///
@@ -980,11 +1010,13 @@ class MacosPopupButton extends StatefulWidget {
@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
- properties.add(DoubleProperty(
- 'itemHeight',
- itemHeight,
- defaultValue: kMinInteractiveDimension,
- ));
+ properties.add(
+ DoubleProperty(
+ 'itemHeight',
+ itemHeight,
+ defaultValue: kMinInteractiveDimension,
+ ),
+ );
properties.add(
FlagProperty('hasAutofocus', value: autofocus, ifFalse: 'noAutofocus'),
);
@@ -1070,17 +1102,21 @@ class _MacosPopupButtonState extends State>
widget.items!.isEmpty ||
(widget.value == null &&
widget.items!
- .where((MacosPopupMenuItem item) =>
- item.enabled && item.value == widget.value)
+ .where(
+ (MacosPopupMenuItem item) =>
+ item.enabled && item.value == widget.value,
+ )
.isEmpty)) {
_selectedIndex = null;
return;
}
- assert(widget.items!
- .where((MacosPopupMenuItem item) => item.value == widget.value)
- .length ==
- 1);
+ assert(
+ widget.items!
+ .where((MacosPopupMenuItem item) => item.value == widget.value)
+ .length ==
+ 1,
+ );
for (int itemIndex = 0; itemIndex < widget.items!.length; itemIndex++) {
if (widget.items![itemIndex].value == widget.value) {
_selectedIndex = itemIndex;
@@ -1116,7 +1152,8 @@ class _MacosPopupButtonState extends State>
final NavigatorState navigator = Navigator.of(context);
assert(_popupRoute == null);
final RenderBox itemBox = context.findRenderObject()! as RenderBox;
- final Rect itemRect = itemBox.localToGlobal(
+ final Rect itemRect =
+ itemBox.localToGlobal(
_kPopupRouteOffset,
ancestor: navigator.context.findRenderObject(),
) &
@@ -1126,8 +1163,10 @@ class _MacosPopupButtonState extends State>
buttonRect: menuMargin.resolve(textDirection).inflateRect(itemRect),
padding: _kMenuItemPadding.resolve(textDirection),
selectedIndex: _selectedIndex ?? 0,
- capturedThemes:
- InheritedTheme.capture(from: context, to: navigator.context),
+ capturedThemes: InheritedTheme.capture(
+ from: context,
+ to: navigator.context,
+ ),
style: _textStyle!,
barrierLabel: MaterialLocalizations.of(context).modalBarrierDismissLabel,
itemHeight: widget.itemHeight,
@@ -1135,9 +1174,9 @@ class _MacosPopupButtonState extends State>
menuMaxHeight: widget.menuMaxHeight,
);
- navigator
- .push(_popupRoute!)
- .then((_MacosPopupRouteResult? newValue) {
+ navigator.push(_popupRoute!).then((
+ _MacosPopupRouteResult? newValue,
+ ) {
_removeMacosPopupRoute();
if (!mounted || newValue == null) return;
widget.onChanged?.call(newValue.result);
@@ -1150,8 +1189,9 @@ class _MacosPopupButtonState extends State>
void dispose() {
WidgetsBinding.instance.removeObserver(this);
_removeMacosPopupRoute();
- WidgetsBinding.instance.focusManager
- .removeHighlightModeListener(_handleFocusHighlightModeChange);
+ WidgetsBinding.instance.focusManager.removeHighlightModeListener(
+ _handleFocusHighlightModeChange,
+ );
focusNode!.removeListener(_handleFocusChanged);
_internalNode?.dispose();
super.dispose();
@@ -1187,20 +1227,15 @@ class _MacosPopupButtonState extends State>
int? hintIndex;
if (widget.hint != null || (!_enabled && widget.disabledHint != null)) {
- Widget displayedHint =
- _enabled ? widget.hint! : widget.disabledHint ?? widget.hint!;
+ Widget displayedHint = _enabled
+ ? widget.hint!
+ : widget.disabledHint ?? widget.hint!;
if (widget.selectedItemBuilder == null) {
displayedHint = _MacosPopupMenuItemContainer(child: displayedHint);
}
hintIndex = items.length;
- items.add(
- ExcludeSemantics(
- child: IgnorePointer(
- child: displayedHint,
- ),
- ),
- );
+ items.add(ExcludeSemantics(child: IgnorePointer(child: displayedHint)));
}
// If value is null (then _selectedIndex is null) then we
@@ -1228,9 +1263,7 @@ class _MacosPopupButtonState extends State>
);
Widget result = DefaultTextStyle(
- style: _textStyle!.copyWith(
- color: buttonStyles.textColor,
- ),
+ style: _textStyle!.copyWith(color: buttonStyles.textColor),
child: Container(
decoration: _showHighlight
? const BoxDecoration(
@@ -1247,10 +1280,7 @@ class _MacosPopupButtonState extends State>
),
],
color: buttonStyles.bgColor,
- border: Border.all(
- width: 0.5,
- color: buttonStyles.borderColor,
- ),
+ border: Border.all(width: 0.5, color: buttonStyles.borderColor),
borderRadius: _kBorderRadius,
),
padding: const EdgeInsets.only(left: 8.0, right: 2.0),
@@ -1302,10 +1332,7 @@ class _MacosPopupButtonState extends State>
// We use this utility function to get the appropriate styling, according to the
// macOS Design Guidelines and the current MacosPopupButtonTheme.
-_ButtonStyles _getButtonStyles(
- bool enabled,
- BuildContext context,
-) {
+_ButtonStyles _getButtonStyles(bool enabled, BuildContext context) {
final theme = MacosTheme.of(context);
final brightness = theme.brightness;
final popupTheme = MacosPopupButtonTheme.of(context);
@@ -1380,7 +1407,9 @@ class _UpDownCaretsPainter extends CustomPainter {
/// Draw background
canvas.drawRRect(
- BorderRadius.circular(radius).toRRect(Offset.zero & size),
+ const BorderRadius.all(
+ Radius.circular(radius),
+ ).toRRect(Offset.zero & size),
Paint()..color = backgroundColor,
);
diff --git a/lib/src/buttons/pulldown_button.dart b/lib/src/buttons/pulldown_button.dart
index 37c0e7d1..e0055c25 100644
--- a/lib/src/buttons/pulldown_button.dart
+++ b/lib/src/buttons/pulldown_button.dart
@@ -6,11 +6,7 @@ import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart';
import 'package:macos_ui/macos_ui.dart';
-enum PulldownButtonState {
- enabled,
- hovered,
- pressed,
-}
+enum PulldownButtonState { enabled, hovered, pressed }
const Duration _kMenuDuration = Duration(milliseconds: 300);
const double _kMenuItemHeight = 20.0;
@@ -19,10 +15,7 @@ const EdgeInsets _kMenuItemPadding = EdgeInsets.symmetric(horizontal: 6.0);
const BorderRadius _kBorderRadius = BorderRadius.all(Radius.circular(5.0));
const double _kMenuLeftOffset = 8.0;
-enum PulldownMenuAlignment {
- left,
- right,
-}
+enum PulldownMenuAlignment { left, right }
// The widget that is the button wrapping the menu items.
class _MacosPulldownMenuItemButton extends StatefulWidget {
@@ -65,8 +58,8 @@ class _MacosPulldownMenuItemButtonState
final MacosPulldownMenuEntry menuEntity =
widget.route.items[widget.itemIndex].item!;
if (menuEntity is MacosPulldownMenuItem) {
+ Navigator.of(context).pop();
menuEntity.onTap?.call();
- Navigator.pop(context);
}
}
@@ -200,9 +193,9 @@ class _MacosPulldownMenuState extends State<_MacosPulldownMenu> {
explicitChildNodes: true,
child: IntrinsicWidth(
child: MacosOverlayFilter(
- color: MacosPulldownButtonTheme.of(context)
- .pulldownColor
- ?.withOpacity(0.25),
+ color: MacosPulldownButtonTheme.of(
+ context,
+ ).pulldownColor?.withValues(alpha: 0.25),
borderRadius: _kBorderRadius,
child: Padding(
padding: const EdgeInsets.all(6.0),
@@ -294,11 +287,7 @@ class _MacosPulldownMenuRouteLayout extends SingleChildLayoutDelegate {
}
class _MenuLimits {
- const _MenuLimits(
- this.top,
- this.bottom,
- this.height,
- );
+ const _MenuLimits(this.top, this.bottom, this.height);
final double top;
final double bottom;
final double height;
@@ -315,9 +304,9 @@ class _MacosPulldownRoute extends PopupRoute {
this.itemHeight,
required this.menuAlignment,
}) : itemHeights = List.filled(
- items.length,
- itemHeight ?? _kMenuItemHeight,
- );
+ items.length,
+ itemHeight ?? _kMenuItemHeight,
+ );
final List<_MenuItem> items;
final EdgeInsetsGeometry padding;
@@ -368,10 +357,7 @@ class _MacosPulldownRoute extends PopupRoute {
}
}
- _MenuLimits getMenuLimits(
- Rect buttonRect,
- double availableHeight,
- ) {
+ _MenuLimits getMenuLimits(Rect buttonRect, double availableHeight) {
double computedMaxHeight = availableHeight - 2.0 * _kMenuItemHeight;
final double buttonTop = buttonRect.top;
@@ -381,14 +367,17 @@ class _MacosPulldownRoute extends PopupRoute {
// bottom may be less than [_kMenuItemHeight] from the edge of the screen.
// In this case, we want to change the menu limits to align with the top
// or bottom edge of the button.
- final double bottomLimit =
- math.max(availableHeight - _kMenuItemHeight, buttonBottom);
+ final double bottomLimit = math.max(
+ availableHeight - _kMenuItemHeight,
+ buttonBottom,
+ );
double menuTop = buttonTop + buttonRect.height;
double preferredMenuHeight = 8.0;
if (items.isNotEmpty) {
- preferredMenuHeight +=
- itemHeights.reduce((double total, double height) => total + height);
+ preferredMenuHeight += itemHeights.reduce(
+ (double total, double height) => total + height,
+ );
}
// If there are too many elements in the menu, we need to shrink it down
@@ -406,11 +395,7 @@ class _MacosPulldownRoute extends PopupRoute {
}
assert((menuBottom - menuTop - menuHeight).abs() < precisionErrorTolerance);
- return _MenuLimits(
- menuTop,
- menuBottom,
- menuHeight,
- );
+ return _MenuLimits(menuTop, menuBottom, menuHeight);
}
}
@@ -476,11 +461,8 @@ class _MacosPulldownRoutePage extends StatelessWidget {
// each menu item.
class _MenuItem extends SingleChildRenderObjectWidget {
// ignore: use_super_parameters
- const _MenuItem({
- Key? key,
- required this.onLayout,
- this.item,
- }) : super(key: key, child: item);
+ const _MenuItem({Key? key, required this.onLayout, this.item})
+ : super(key: key, child: item);
final ValueChanged onLayout;
@@ -538,9 +520,9 @@ class MacosPulldownMenuDivider extends StatelessWidget
alignment: Alignment.centerLeft,
child: Container(
color: MacosTheme.of(context).brightness.resolve(
- MacosColors.disabledControlTextColor,
- MacosColors.disabledControlTextColor.darkColor,
- ),
+ MacosColors.disabledControlTextColor,
+ MacosColors.disabledControlTextColor.darkColor,
+ ),
height: 0.5,
),
),
@@ -642,10 +624,11 @@ class MacosPulldownButton extends StatefulWidget {
this.autofocus = false,
this.alignment = AlignmentDirectional.centerStart,
this.menuAlignment = PulldownMenuAlignment.left,
- }) : assert(itemHeight == null || itemHeight >= _kMenuItemHeight),
- assert(
- (title != null || icon != null) && !(title != null && icon != null),
- "There should be either a title or an icon argument provided, and not both at at the same time.");
+ }) : assert(itemHeight == null || itemHeight >= _kMenuItemHeight),
+ assert(
+ (title != null || icon != null) && !(title != null && icon != null),
+ "There should be either a title or an icon argument provided, and not both at at the same time.",
+ );
/// The list of menu entries for the pull-down menu.
///
@@ -721,10 +704,7 @@ class MacosPulldownButton extends StatefulWidget {
@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
- properties.add(DoubleProperty(
- 'itemHeight',
- itemHeight,
- ));
+ properties.add(DoubleProperty('itemHeight', itemHeight));
properties.add(
FlagProperty('hasAutofocus', value: autofocus, ifFalse: 'noAutofocus'),
);
@@ -834,7 +814,8 @@ class _MacosPulldownButtonState extends State
final NavigatorState navigator = Navigator.of(context);
assert(_pulldownRoute == null);
final RenderBox itemBox = context.findRenderObject()! as RenderBox;
- final Rect itemRect = itemBox.localToGlobal(
+ final Rect itemRect =
+ itemBox.localToGlobal(
Offset.zero,
ancestor: navigator.context.findRenderObject(),
) &
@@ -843,8 +824,10 @@ class _MacosPulldownButtonState extends State
items: menuItems,
buttonRect: menuMargin.resolve(textDirection).inflateRect(itemRect),
padding: _kMenuItemPadding.resolve(textDirection),
- capturedThemes:
- InheritedTheme.capture(from: context, to: navigator.context),
+ capturedThemes: InheritedTheme.capture(
+ from: context,
+ to: navigator.context,
+ ),
style: _textStyle!,
barrierLabel: MaterialLocalizations.of(context).modalBarrierDismissLabel,
itemHeight: widget.itemHeight,
@@ -852,9 +835,9 @@ class _MacosPulldownButtonState extends State
);
navigator.push(_pulldownRoute!).then((_) {
+ if (!mounted) return;
setState(() => _pullDownButtonState = PulldownButtonState.enabled);
_removeMacosPulldownRoute();
- if (!mounted) return;
});
widget.onTap?.call();
@@ -877,8 +860,9 @@ class _MacosPulldownButtonState extends State
void dispose() {
WidgetsBinding.instance.removeObserver(this);
_removeMacosPulldownRoute();
- WidgetsBinding.instance.focusManager
- .removeHighlightModeListener(_handleFocusHighlightModeChange);
+ WidgetsBinding.instance.focusManager.removeHighlightModeListener(
+ _handleFocusHighlightModeChange,
+ );
focusNode!.removeListener(_handleFocusChanged);
_internalNode?.dispose();
super.dispose();
@@ -890,8 +874,12 @@ class _MacosPulldownButtonState extends State
final borderRadius = _hasIcon
? const BorderRadius.all(Radius.circular(7.0))
: _kBorderRadius;
- final buttonStyles =
- _getButtonStyles(_pullDownButtonState, _enabled, _hasIcon, context);
+ final buttonStyles = _getButtonStyles(
+ _pullDownButtonState,
+ _enabled,
+ _hasIcon,
+ context,
+ );
Widget result = Container(
decoration: _showHighlight
@@ -921,14 +909,14 @@ class _MacosPulldownButtonState extends State
_hasIcon
? MacosIcon(widget.icon!, color: buttonStyles.textColor)
: _enabled
- ? Text(
- widget.title!,
- style: TextStyle(color: buttonStyles.textColor),
- )
- : Text(
- widget.disabledTitle ?? widget.title!,
- style: TextStyle(color: buttonStyles.textColor),
- ),
+ ? Text(
+ widget.title!,
+ style: TextStyle(color: buttonStyles.textColor),
+ )
+ : Text(
+ widget.disabledTitle ?? widget.title!,
+ style: TextStyle(color: buttonStyles.textColor),
+ ),
Padding(
padding: EdgeInsets.only(left: _hasIcon ? 2.0 : 8.0),
child: SizedBox(
@@ -1042,7 +1030,7 @@ _ButtonStyles _getButtonStyles(
);
break;
case PulldownButtonState.pressed:
- textColor = caretColor = iconColor.withOpacity(0.85);
+ textColor = caretColor = iconColor.withValues(alpha: 0.85);
bgColor = brightness.resolve(
const Color.fromRGBO(0, 0, 0, 0.1),
const Color.fromRGBO(255, 255, 255, 0.1),
@@ -1061,8 +1049,8 @@ _ButtonStyles _getButtonStyles(
case PulldownButtonState.hovered:
break;
case PulldownButtonState.pressed:
- bgColor = pulldownTheme.backgroundColor!.withOpacity(0.4);
- caretBgColor = pulldownTheme.highlightColor!.withOpacity(0.9);
+ bgColor = pulldownTheme.backgroundColor!.withValues(alpha: 0.4);
+ caretBgColor = pulldownTheme.highlightColor!.withValues(alpha: 0.9);
break;
}
}
@@ -1093,10 +1081,7 @@ class _ButtonStyles {
}
class _DownCaretPainter extends CustomPainter {
- const _DownCaretPainter({
- required this.color,
- required this.backgroundColor,
- });
+ const _DownCaretPainter({required this.color, required this.backgroundColor});
final Color color;
final Color backgroundColor;
@@ -1108,7 +1093,9 @@ class _DownCaretPainter extends CustomPainter {
/// Draw background
canvas.drawRRect(
- BorderRadius.circular(radius).toRRect(Offset.zero & size),
+ const BorderRadius.all(
+ Radius.circular(radius),
+ ).toRRect(Offset.zero & size),
Paint()..color = backgroundColor,
);
diff --git a/lib/src/buttons/push_button.dart b/lib/src/buttons/push_button.dart
index e95a9857..e66d29e2 100644
--- a/lib/src/buttons/push_button.dart
+++ b/lib/src/buttons/push_button.dart
@@ -130,8 +130,10 @@ class PushButton extends StatefulWidget {
this.semanticLabel,
this.mouseCursor = SystemMouseCursors.basic,
this.secondary,
- }) : assert(pressedOpacity == null ||
- (pressedOpacity >= 0.0 && pressedOpacity <= 1.0));
+ }) : assert(
+ pressedOpacity == null ||
+ (pressedOpacity >= 0.0 && pressedOpacity <= 1.0),
+ );
/// The widget below this widget in the tree.
///
@@ -170,9 +172,11 @@ class PushButton extends StatefulWidget {
///
/// This defaults to 0.4. If null, opacity will not change on pressed if using
/// your own custom effects is desired.
- @Deprecated("'PushButton' animations now match their native macOSโ "
- "counterparts. Therefore, its opacity no longer changes when it is "
- "pressed.")
+ @Deprecated(
+ "'PushButton' animations now match their native macOSโ "
+ "counterparts. Therefore, its opacity no longer changes when it is "
+ "pressed.",
+ )
final double? pressedOpacity;
/// The radius of the button's corners when it has a background color.
@@ -215,11 +219,9 @@ class PushButton extends StatefulWidget {
properties.add(DiagnosticsProperty('alignment', alignment));
properties.add(StringProperty('semanticLabel', semanticLabel));
properties.add(DiagnosticsProperty('borderRadius', borderRadius));
- properties.add(FlagProperty(
- 'enabled',
- value: enabled,
- ifFalse: 'disabled',
- ));
+ properties.add(
+ FlagProperty('enabled', value: enabled, ifFalse: 'disabled'),
+ );
properties.add(DiagnosticsProperty('secondary', secondary));
}
@@ -298,12 +300,12 @@ class PushButtonState extends State
final blendedBackgroundColor = Color.lerp(
theme.canvasColor,
backgroundColor,
- backgroundColor.opacity,
+ backgroundColor.a,
)!;
return widget.enabled
? textLuminance(blendedBackgroundColor)
- : textLuminance(blendedBackgroundColor).withOpacity(0.25);
+ : textLuminance(blendedBackgroundColor).withValues(alpha: 0.25);
}
BoxDecoration _getClickEffectBoxDecoration() {
@@ -347,11 +349,13 @@ class PushButtonState extends State
builder: (context, _) {
final Color backgroundColor = _getBackgroundColor();
- final Color foregroundColor =
- _getForegroundColor(backgroundColor);
+ final Color foregroundColor = _getForegroundColor(
+ backgroundColor,
+ );
- final baseStyle =
- theme.typography.body.copyWith(color: foregroundColor);
+ final baseStyle = theme.typography.body.copyWith(
+ color: foregroundColor,
+ );
return DecoratedBox(
decoration: _getBoxDecoration().copyWith(
@@ -458,9 +462,6 @@ class _BoxDecorationBuilder {
MacosColor.fromRGBO(64, 64, 64, 1.0 * isEnabledFactor),
MacosColor.fromRGBO(57, 57, 57, 1.0 * isEnabledFactor),
];
-
- default:
- throw UnimplementedError();
}
} else {
switch (accentColor) {
@@ -511,9 +512,6 @@ class _BoxDecorationBuilder {
MacosColor.fromRGBO(86, 86, 86, 1.0 * isEnabledFactor),
MacosColor.fromRGBO(55, 55, 55, 1.0 * isEnabledFactor),
];
-
- default:
- throw UnimplementedError();
}
}
}
@@ -649,9 +647,6 @@ class _BoxDecorationBuilder {
blurStyle: isEnabled ? BlurStyle.normal : BlurStyle.outer,
),
];
-
- default:
- throw UnimplementedError();
}
}
}
diff --git a/lib/src/buttons/radio_button.dart b/lib/src/buttons/radio_button.dart
index eda3de26..b65c2ef7 100644
--- a/lib/src/buttons/radio_button.dart
+++ b/lib/src/buttons/radio_button.dart
@@ -28,7 +28,7 @@ class MacosRadioButton extends StatelessWidget {
/// Whether the button is checked or not
final T value;
-// The currently selected value for a group of radio buttons.
+ // The currently selected value for a group of radio buttons.
///
/// This radio button is considered selected if its [value] matches the
/// [groupValue].
@@ -73,11 +73,9 @@ class MacosRadioButton extends StatelessWidget {
// 'state',
// value ? 'checked' : 'unchecked',
// ));
- properties.add(FlagProperty(
- 'disabled',
- value: isDisabled,
- ifFalse: 'enabled',
- ));
+ properties.add(
+ FlagProperty('disabled', value: isDisabled, ifFalse: 'enabled'),
+ );
properties.add(DoubleProperty('size', size));
properties.add(ColorProperty('onColor', onColor));
properties.add(ColorProperty('offColor', offColor));
@@ -119,8 +117,8 @@ class MacosRadioButton extends StatelessWidget {
(isDisabled
? CupertinoColors.quaternarySystemFill
: selected || isLight
- ? CupertinoColors.white
- : CupertinoColors.tertiarySystemFill),
+ ? CupertinoColors.white
+ : CupertinoColors.tertiarySystemFill),
context,
),
boxShadow: const [
diff --git a/lib/src/buttons/segmented_control.dart b/lib/src/buttons/segmented_control.dart
index 45f36539..71aec8d0 100644
--- a/lib/src/buttons/segmented_control.dart
+++ b/lib/src/buttons/segmented_control.dart
@@ -58,58 +58,61 @@ class _MacosSegmentedControlState extends State {
spreadRadius: 0.5,
),
],
- borderRadius: const BorderRadius.all(
- Radius.circular(5.0),
- ),
+ borderRadius: const BorderRadius.all(Radius.circular(5.0)),
),
child: Padding(
padding: const EdgeInsets.all(0.5),
child: IntrinsicHeight(
child: IntrinsicWidth(
child: Row(
- children: widget.tabs.map((t) {
- final row = Row(
- children: [
- GestureDetector(
- onTap: () {
- setState(() {
- widget.controller.index = widget.tabs.indexOf(t);
- });
- },
- child: t.copyWith(
- active:
- widget.controller.index == widget.tabs.indexOf(t),
- ),
- ),
- ],
- );
- bool showDividerColor = true;
- final last = widget.tabs.indexOf(t) == widget.tabs.length - 1;
- if ((widget.controller.index - 1 == widget.tabs.indexOf(t)) ||
- (widget.controller.index + 1 ==
- widget.tabs.indexOf(t) + 1) ||
- last) {
- showDividerColor = false;
- }
+ children: widget.tabs
+ .map((t) {
+ final row = Row(
+ children: [
+ GestureDetector(
+ onTap: () {
+ setState(() {
+ widget.controller.index = widget.tabs.indexOf(t);
+ });
+ },
+ child: t.copyWith(
+ active:
+ widget.controller.index ==
+ widget.tabs.indexOf(t),
+ ),
+ ),
+ ],
+ );
+ bool showDividerColor = true;
+ final last =
+ widget.tabs.indexOf(t) == widget.tabs.length - 1;
+ if ((widget.controller.index - 1 ==
+ widget.tabs.indexOf(t)) ||
+ (widget.controller.index + 1 ==
+ widget.tabs.indexOf(t) + 1) ||
+ last) {
+ showDividerColor = false;
+ }
- if (!last) {
- row.children.add(
- VerticalDivider(
- color: showDividerColor
- ? brightness.resolve(
- const Color(0xFFC9C9C9),
- const Color(0xFF26222C),
- )
- : MacosColors.transparent,
- width: 2.0,
- indent: 5.0,
- endIndent: 5.0,
- ),
- );
- }
+ if (!last) {
+ row.children.add(
+ VerticalDivider(
+ color: showDividerColor
+ ? brightness.resolve(
+ const Color(0xFFC9C9C9),
+ const Color(0xFF26222C),
+ )
+ : MacosColors.transparent,
+ width: 2.0,
+ indent: 5.0,
+ endIndent: 5.0,
+ ),
+ );
+ }
- return row;
- }).toList(growable: false),
+ return row;
+ })
+ .toList(growable: false),
),
),
),
diff --git a/lib/src/buttons/switch.dart b/lib/src/buttons/switch.dart
index 25d7f637..08214c07 100644
--- a/lib/src/buttons/switch.dart
+++ b/lib/src/buttons/switch.dart
@@ -107,18 +107,12 @@ class MacosSwitch extends StatefulWidget {
@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
- properties.add(FlagProperty(
- 'checked',
- value: value,
- ifFalse: 'unchecked',
- ));
+ properties.add(FlagProperty('checked', value: value, ifFalse: 'unchecked'));
properties.add(EnumProperty('size', size));
properties.add(EnumProperty('dragStartBehavior', dragStartBehavior));
- properties.add(FlagProperty(
- 'enabled',
- value: onChanged == null,
- ifFalse: 'disabled',
- ));
+ properties.add(
+ FlagProperty('enabled', value: onChanged == null, ifFalse: 'disabled'),
+ );
properties.add(ColorProperty('activeColor', activeColor));
properties.add(ColorProperty('trackColor', trackColor));
properties.add(ColorProperty('knobColor', knobColor));
@@ -279,15 +273,25 @@ class _MacosSwitchState extends State
Widget build(BuildContext context) {
assert(debugCheckHasMacosTheme(context));
final MacosThemeData theme = MacosTheme.of(context);
- MacosColor borderColor =
- MacosDynamicColor.resolve(_kDefaultBorderColor, context).toMacosColor();
- MacosColor activeColor = MacosColor(MacosDynamicColor.resolve(
+ MacosColor borderColor = MacosDynamicColor.resolve(
+ _kDefaultBorderColor,
+ context,
+ ).toMacosColor();
+ final resolvedActiveColor = MacosDynamicColor.resolve(
widget.activeColor ?? theme.primaryColor,
context,
- ).value);
- MacosColor trackColor = widget.trackColor ??
+ );
+ MacosColor activeColor = MacosColor.fromRGBO(
+ (resolvedActiveColor.r * 255).toInt(),
+ (resolvedActiveColor.g * 255).toInt(),
+ (resolvedActiveColor.b * 255).toInt(),
+ resolvedActiveColor.a,
+ );
+ MacosColor trackColor =
+ widget.trackColor ??
MacosDynamicColor.resolve(_kDefaultTrackColor, context).toMacosColor();
- MacosColor knobColor = widget.knobColor ??
+ MacosColor knobColor =
+ widget.knobColor ??
MacosDynamicColor.resolve(_kDefaultKnobColor, context).toMacosColor();
// Shot in the dark to try and get the border color correct for each
@@ -430,21 +434,21 @@ class _RenderMacosSwitch extends RenderConstrainedBox {
required ValueChanged? onChanged,
required TextDirection textDirection,
required _MacosSwitchState state,
- }) : _value = value,
- _size = size,
- _activeColor = activeColor,
- _trackColor = trackColor,
- _knobPainter = MacosSwitchKnobPainter(color: knobColor),
- _borderColor = borderColor,
- _onChanged = onChanged,
- _textDirection = textDirection,
- _state = state,
- super(
- additionalConstraints: BoxConstraints.tightFor(
- width: size.trackSize.width,
- height: size.trackSize.height,
- ),
- ) {
+ }) : _value = value,
+ _size = size,
+ _activeColor = activeColor,
+ _trackColor = trackColor,
+ _knobPainter = MacosSwitchKnobPainter(color: knobColor),
+ _borderColor = borderColor,
+ _onChanged = onChanged,
+ _textDirection = textDirection,
+ _state = state,
+ super(
+ additionalConstraints: BoxConstraints.tightFor(
+ width: size.trackSize.width,
+ height: size.trackSize.height,
+ ),
+ ) {
state.position.addListener(markNeedsPaint);
state._reaction.addListener(markNeedsPaint);
}
@@ -646,21 +650,25 @@ class _RenderMacosSwitch extends RenderConstrainedBox {
@override
void debugFillProperties(DiagnosticPropertiesBuilder description) {
super.debugFillProperties(description);
- description.add(FlagProperty(
- 'value',
- value: value,
- ifTrue: 'checked',
- ifFalse: 'unchecked',
- showName: true,
- ));
- description.add(FlagProperty(
- 'isInteractive',
- value: isInteractive,
- ifTrue: 'enabled',
- ifFalse: 'disabled',
- showName: true,
- defaultValue: true,
- ));
+ description.add(
+ FlagProperty(
+ 'value',
+ value: value,
+ ifTrue: 'checked',
+ ifFalse: 'unchecked',
+ showName: true,
+ ),
+ );
+ description.add(
+ FlagProperty(
+ 'isInteractive',
+ value: isInteractive,
+ ifTrue: 'enabled',
+ ifFalse: 'disabled',
+ showName: true,
+ defaultValue: true,
+ ),
+ );
}
}
diff --git a/lib/src/buttons/toolbar/toolbar_icon_button.dart b/lib/src/buttons/toolbar/toolbar_icon_button.dart
index 4b165a3d..23abb84b 100644
--- a/lib/src/buttons/toolbar/toolbar_icon_button.dart
+++ b/lib/src/buttons/toolbar/toolbar_icon_button.dart
@@ -1,5 +1,6 @@
import 'package:macos_ui/macos_ui.dart';
import 'package:macos_ui/src/library.dart';
+import 'package:macos_window_utils/widgets/macos_toolbar_passthrough.dart';
/// An icon button suitable for the toolbar.
class ToolBarIconButton extends ToolbarItem {
@@ -57,12 +58,12 @@ class ToolBarIconButton extends ToolbarItem {
disabledColor: Colors.transparent,
icon: MacosIconTheme(
data: MacosTheme.of(context).iconTheme.copyWith(
- color: brightness.resolve(
- const Color.fromRGBO(0, 0, 0, 0.5),
- const Color.fromRGBO(255, 255, 255, 0.5),
- ),
- size: showLabel ? 16.0 : 20.0,
- ),
+ color: brightness.resolve(
+ const Color.fromRGBO(0, 0, 0, 0.5),
+ const Color.fromRGBO(255, 255, 255, 0.5),
+ ),
+ size: showLabel ? 16.0 : 20.0,
+ ),
child: icon,
),
onPressed: onPressed,
@@ -97,17 +98,11 @@ class ToolBarIconButton extends ToolbarItem {
}
if (tooltipMessage != null) {
- iconButton = MacosTooltip(
- message: tooltipMessage!,
- child: iconButton,
- );
+ iconButton = MacosTooltip(message: tooltipMessage!, child: iconButton);
}
- return iconButton;
+ return MacosToolbarPassthrough(child: iconButton);
} else {
- return ToolbarOverflowMenuItem(
- label: label,
- onPressed: onPressed,
- );
+ return ToolbarOverflowMenuItem(label: label, onPressed: onPressed);
}
}
}
diff --git a/lib/src/buttons/toolbar/toolbar_overflow_button.dart b/lib/src/buttons/toolbar/toolbar_overflow_button.dart
index 08584418..aa0a01f2 100644
--- a/lib/src/buttons/toolbar/toolbar_overflow_button.dart
+++ b/lib/src/buttons/toolbar/toolbar_overflow_button.dart
@@ -2,7 +2,7 @@ import 'package:macos_ui/macos_ui.dart';
import 'package:macos_ui/src/library.dart';
/// A button to show at the far right side of the toolbar.
-class ToolbarOverflowButton extends StatelessWidget {
+class ToolbarOverflowButton extends StatefulWidget {
/// Builds a button to show at the far right side of the toolbar, when the
/// toolbar actions are overflowing the available horizontal space.
///
@@ -20,25 +20,35 @@ class ToolbarOverflowButton extends StatelessWidget {
/// Whether the icon button should be smaller in size (half the toolbar height).
final bool isDense;
+ @override
+ State createState() => _ToolbarOverflowButtonState();
+}
+
+class _ToolbarOverflowButtonState extends State {
+ late final GlobalKey popupKey;
+
+ @override
+ void initState() {
+ super.initState();
+ popupKey = GlobalKey();
+ }
+
@override
Widget build(BuildContext context) {
- final popupKey = GlobalKey();
return ToolbarPopup(
key: popupKey,
- content: overflowContentBuilder,
+ content: widget.overflowContentBuilder,
verticalOffset: 8.0,
horizontalOffset: 10.0,
position: ToolbarPopupPosition.below,
placement: ToolbarPopupPlacement.end,
child: ToolBarIconButton(
label: "",
- icon: const MacosIcon(
- CupertinoIcons.chevron_right_2,
- ),
+ icon: const MacosIcon(CupertinoIcons.chevron_right_2),
onPressed: () {
popupKey.currentState?.openPopup();
},
- showLabel: isDense,
+ showLabel: widget.isDense,
).build(context, ToolbarItemDisplayMode.inToolbar),
);
}
diff --git a/lib/src/buttons/toolbar/toolbar_pulldown_button.dart b/lib/src/buttons/toolbar/toolbar_pulldown_button.dart
index 893d5a9f..64cc5e6d 100644
--- a/lib/src/buttons/toolbar/toolbar_pulldown_button.dart
+++ b/lib/src/buttons/toolbar/toolbar_pulldown_button.dart
@@ -1,5 +1,6 @@
import 'package:macos_ui/macos_ui.dart';
import 'package:macos_ui/src/library.dart';
+import 'package:macos_window_utils/widgets/macos_toolbar_passthrough.dart';
/// A pulldown button suitable for the toolbar.
class ToolBarPullDownButton extends ToolbarItem {
@@ -62,10 +63,7 @@ class ToolBarPullDownButton extends ToolbarItem {
const Color.fromRGBO(255, 255, 255, 0.5),
),
),
- child: MacosPulldownButton(
- icon: icon,
- items: items,
- ),
+ child: MacosPulldownButton(icon: icon, items: items),
),
);
@@ -75,7 +73,7 @@ class ToolBarPullDownButton extends ToolbarItem {
child: pulldownButton,
);
}
- return pulldownButton;
+ return MacosToolbarPassthrough(child: pulldownButton);
} else {
// We should show a submenu for the pulldown button items.
final subMenuKey = GlobalKey();
@@ -84,8 +82,10 @@ class ToolBarPullDownButton extends ToolbarItem {
// Convert the original pulldown menu items to toolbar overflow menu items.
items?.forEach((element) {
if (element is MacosPulldownMenuItem) {
- assert(element.label != null,
- 'When you use a MacosPulldownButton in the Toolbar, you must set the label property for all MacosPulldownMenuItems.');
+ assert(
+ element.label != null,
+ 'When you use a MacosPulldownButton in the Toolbar, you must set the label property for all MacosPulldownMenuItems.',
+ );
subMenuItems.add(
ToolbarOverflowMenuItem(
label: element.label!,
@@ -117,9 +117,9 @@ class ToolBarPullDownButton extends ToolbarItem {
placement: ToolbarPopupPlacement.start,
child: MouseRegion(
onHover: (e) {
- subMenuKey.currentState
- ?.openPopup()
- .then((value) => setState(() => isSelected = false));
+ subMenuKey.currentState?.openPopup().then(
+ (value) => setState(() => isSelected = false),
+ );
setState(() => isSelected = true);
},
child: ToolbarOverflowMenuItem(
diff --git a/lib/src/dialogs/macos_alert_dialog.dart b/lib/src/dialogs/macos_alert_dialog.dart
index 0dab2588..2ff9c239 100644
--- a/lib/src/dialogs/macos_alert_dialog.dart
+++ b/lib/src/dialogs/macos_alert_dialog.dart
@@ -3,10 +3,7 @@ import 'package:macos_ui/macos_ui.dart';
import 'package:macos_ui/src/library.dart';
const _kDialogBorderRadius = BorderRadius.all(Radius.circular(12.0));
-const _kDefaultDialogConstraints = BoxConstraints(
- minWidth: 260,
- maxWidth: 260,
-);
+const _kDefaultDialogConstraints = BoxConstraints(minWidth: 260, maxWidth: 260);
/// A macOS-style AlertDialog.
///
@@ -126,13 +123,13 @@ class MacosAlertDialog extends StatelessWidget {
final brightness = MacosTheme.brightnessOf(context);
final outerBorderColor = brightness.resolve(
- Colors.black.withOpacity(0.23),
- Colors.black.withOpacity(0.76),
+ Colors.black.withValues(alpha: 0.23),
+ Colors.black.withValues(alpha: 0.76),
);
final innerBorderColor = brightness.resolve(
- Colors.white.withOpacity(0.45),
- Colors.white.withOpacity(0.15),
+ Colors.white.withValues(alpha: 0.45),
+ Colors.white.withValues(alpha: 0.15),
);
return Dialog(
@@ -140,23 +137,15 @@ class MacosAlertDialog extends StatelessWidget {
CupertinoColors.systemGrey6.color,
MacosColors.controlBackgroundColor.darkColor,
),
- shape: const RoundedRectangleBorder(
- borderRadius: _kDialogBorderRadius,
- ),
+ shape: const RoundedRectangleBorder(borderRadius: _kDialogBorderRadius),
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
decoration: BoxDecoration(
- border: Border.all(
- width: 2,
- color: innerBorderColor,
- ),
+ border: Border.all(width: 2, color: innerBorderColor),
borderRadius: _kDialogBorderRadius,
),
foregroundDecoration: BoxDecoration(
- border: Border.all(
- width: 1,
- color: outerBorderColor,
- ),
+ border: Border.all(width: 1, color: outerBorderColor),
borderRadius: _kDialogBorderRadius,
),
child: ConstrainedBox(
@@ -166,10 +155,7 @@ class MacosAlertDialog extends StatelessWidget {
children: [
const SizedBox(height: 20),
ConstrainedBox(
- constraints: const BoxConstraints(
- maxHeight: 64,
- maxWidth: 64,
- ),
+ constraints: const BoxConstraints(maxHeight: 64, maxWidth: 64),
child: appIcon,
),
const SizedBox(height: 16),
@@ -186,11 +172,7 @@ class MacosAlertDialog extends StatelessWidget {
),
const SizedBox(height: 16),
if (secondaryButton == null) ...[
- Row(
- children: [
- Expanded(child: primaryButton),
- ],
- ),
+ Row(children: [Expanded(child: primaryButton)]),
] else ...[
if (horizontalActions!) ...[
Row(
@@ -199,29 +181,17 @@ class MacosAlertDialog extends StatelessWidget {
Expanded(child: secondaryButton!),
const SizedBox(width: 8.0),
],
- Expanded(
- child: primaryButton,
- ),
+ Expanded(child: primaryButton),
],
),
] else ...[
Column(
mainAxisSize: MainAxisSize.min,
children: [
- Row(
- children: [
- Expanded(child: primaryButton),
- ],
- ),
+ Row(children: [Expanded(child: primaryButton)]),
const SizedBox(height: 8.0),
if (secondaryButton != null) ...[
- Row(
- children: [
- Expanded(
- child: secondaryButton!,
- ),
- ],
- ),
+ Row(children: [Expanded(child: secondaryButton!)]),
],
],
),
@@ -256,7 +226,14 @@ Future showMacosAlertDialog({
barrierColor ??= MacosDynamicColor.resolve(
MacosColors.controlBackgroundColor,
context,
- ).withOpacity(0.6);
+ );
+
+ barrierColor = Color.fromRGBO(
+ (barrierColor.r * 255).floor(),
+ (barrierColor.g * 255).floor(),
+ (barrierColor.b * 255).floor(),
+ 0.6,
+ );
return Navigator.of(context, rootNavigator: useRootNavigator).push(
_MacosAlertDialogRoute(
@@ -266,7 +243,8 @@ Future showMacosAlertDialog({
},
barrierDismissible: barrierDismissible,
barrierColor: barrierColor,
- barrierLabel: barrierLabel ??
+ barrierLabel:
+ barrierLabel ??
MaterialLocalizations.of(context).modalBarrierDismissLabel,
),
);
@@ -279,10 +257,10 @@ class _MacosAlertDialogRoute extends PopupRoute {
Color? barrierColor = const Color(0x80000000),
String? barrierLabel,
super.settings,
- }) : _pageBuilder = pageBuilder,
- _barrierDismissible = barrierDismissible,
- _barrierLabel = barrierLabel,
- _barrierColor = barrierColor;
+ }) : _pageBuilder = pageBuilder,
+ _barrierDismissible = barrierDismissible,
+ _barrierLabel = barrierLabel,
+ _barrierColor = barrierColor;
final RoutePageBuilder _pageBuilder;
@@ -329,10 +307,7 @@ class _MacosAlertDialogRoute extends PopupRoute {
) {
if (animation.status == AnimationStatus.reverse) {
return FadeTransition(
- opacity: CurvedAnimation(
- parent: animation,
- curve: Curves.easeOutSine,
- ),
+ opacity: CurvedAnimation(parent: animation, curve: Curves.easeOutSine),
child: child,
);
}
@@ -358,11 +333,7 @@ class _SubtleBounceCurve extends Curve {
@override
double transform(double t) {
final simulation = SpringSimulation(
- const SpringDescription(
- damping: 14,
- mass: 1.4,
- stiffness: 180,
- ),
+ const SpringDescription(damping: 14, mass: 1.4, stiffness: 180),
0.0,
1.0,
0.1,
diff --git a/lib/src/fields/search_field.dart b/lib/src/fields/search_field.dart
index 2064ef9a..972280a9 100644
--- a/lib/src/fields/search_field.dart
+++ b/lib/src/fields/search_field.dart
@@ -259,24 +259,25 @@ class _MacosSearchFieldState extends State> {
return OverlayEntry(
builder: (context) => StreamBuilder?>(
stream: suggestionStream.stream,
- builder: (
- BuildContext context,
- AsyncSnapshot?> snapshot,
- ) {
- late var count = widget.maxResultsToShow;
- if (snapshot.data != null) {
- count = snapshot.data!.length;
- }
- return Positioned(
- left: offset.dx,
- width: size.width,
- child: CompositedTransformFollower(
- offset: _getYOffset(offset, size, count),
- link: _layerLink,
- child: _resultsBuilder(),
- ),
- );
- },
+ builder:
+ (
+ BuildContext context,
+ AsyncSnapshot?> snapshot,
+ ) {
+ late var count = widget.maxResultsToShow;
+ if (snapshot.data != null) {
+ count = snapshot.data!.length;
+ }
+ return Positioned(
+ left: offset.dx,
+ width: size.width,
+ child: CompositedTransformFollower(
+ offset: _getYOffset(offset, size, count),
+ link: _layerLink,
+ child: _resultsBuilder(),
+ ),
+ );
+ },
),
);
}
@@ -289,10 +290,7 @@ class _MacosSearchFieldState extends State> {
} else {
if (resultCount > widget.maxResultsToShow) {
showOverlayAbove = false;
- return Offset(
- 0,
- -(widget.resultHeight * widget.maxResultsToShow),
- );
+ return Offset(0, -(widget.resultHeight * widget.maxResultsToShow));
} else {
showOverlayAbove = true;
return Offset(0, -(widget.resultHeight * resultCount));
@@ -303,67 +301,72 @@ class _MacosSearchFieldState extends State> {
Widget _resultsBuilder() {
return StreamBuilder?>(
stream: suggestionStream.stream,
- builder: (
- BuildContext context,
- AsyncSnapshot?> snapshot,
- ) {
- if (widget.results == null ||
- snapshot.data == null ||
- !isResultExpanded) {
- return const SizedBox.shrink();
- } else if (snapshot.data!.isEmpty) {
- return MacosOverlayFilter(
- borderRadius: _kBorderRadius,
- child: widget.emptyWidget,
- );
- } else {
- if (snapshot.data!.length > widget.maxResultsToShow) {
- height = widget.resultHeight * widget.maxResultsToShow;
- } else if (snapshot.data!.length == 1) {
- height = widget.resultHeight;
- } else {
- height = snapshot.data!.length * widget.resultHeight;
- }
- height += _kResultsOverlayMargin;
-
- return TextFieldTapRegion(
- child: MacosOverlayFilter(
- borderRadius: _kBorderRadius,
- color: MacosSearchFieldTheme.of(context).resultsBackgroundColor,
- child: SizedBox(
- height: height,
- child: ListView.builder(
- reverse: showOverlayAbove,
- padding: const EdgeInsets.all(6.0),
- itemCount: snapshot.data!.length,
- itemBuilder: (context, index) {
- var selectedItem = snapshot.data![index]!;
- return _SearchResultItemButton(
- resultHeight: widget.resultHeight,
- onPressed: () {
- searchController!.text = selectedItem.searchKey;
- searchController!.selection =
- TextSelection.fromPosition(
- TextPosition(
- offset: searchController!.text.length,
- ),
+ builder:
+ (
+ BuildContext context,
+ AsyncSnapshot?> snapshot,
+ ) {
+ if (widget.results == null ||
+ snapshot.data == null ||
+ !isResultExpanded) {
+ return const SizedBox.shrink();
+ } else if (snapshot.data!.isEmpty) {
+ return MacosOverlayFilter(
+ borderRadius: _kBorderRadius,
+ child: widget.emptyWidget,
+ );
+ } else {
+ if (snapshot.data!.length > widget.maxResultsToShow) {
+ height = widget.resultHeight * widget.maxResultsToShow;
+ } else if (snapshot.data!.length == 1) {
+ height = widget.resultHeight;
+ } else {
+ height = snapshot.data!.length * widget.resultHeight;
+ }
+ height += _kResultsOverlayMargin;
+
+ return TextFieldTapRegion(
+ child: MacosOverlayFilter(
+ borderRadius: _kBorderRadius,
+ color: MacosSearchFieldTheme.of(
+ context,
+ ).resultsBackgroundColor,
+ child: SizedBox(
+ height: height,
+ child: ListView.builder(
+ reverse: showOverlayAbove,
+ padding: const EdgeInsets.all(6.0),
+ itemCount: snapshot.data!.length,
+ itemBuilder: (context, index) {
+ var selectedItem = snapshot.data![index]!;
+ return _SearchResultItemButton(
+ resultHeight: widget.resultHeight,
+ onPressed: () {
+ searchController!.text = selectedItem.searchKey;
+ searchController!.selection =
+ TextSelection.fromPosition(
+ TextPosition(
+ offset: searchController!.text.length,
+ ),
+ );
+ selectedItem.onSelected?.call();
+ // Hide the results
+ suggestionStream.sink.add(null);
+ if (widget.onResultSelected != null) {
+ widget.onResultSelected!(selectedItem);
+ }
+ },
+ child:
+ selectedItem.child ??
+ Text(selectedItem.searchKey),
);
- selectedItem.onSelected?.call();
- // Hide the results
- suggestionStream.sink.add(null);
- if (widget.onResultSelected != null) {
- widget.onResultSelected!(selectedItem);
- }
},
- child: selectedItem.child ?? Text(selectedItem.searchKey),
- );
- },
+ ),
+ ),
),
- ),
- ),
- );
- }
- },
+ );
+ }
+ },
);
}
@@ -413,9 +416,9 @@ class _MacosSearchFieldState extends State> {
}
if (widget.results != null) {
for (final suggestion in widget.results!) {
- if (suggestion.searchKey
- .toLowerCase()
- .contains(query.toLowerCase())) {
+ if (suggestion.searchKey.toLowerCase().contains(
+ query.toLowerCase(),
+ )) {
searchResult.add(suggestion);
}
}
@@ -450,11 +453,7 @@ class SearchResultItem {
/// field.
///
/// Can be further customized via its [child] property.
- const SearchResultItem(
- this.searchKey, {
- this.child,
- this.onSelected,
- });
+ const SearchResultItem(this.searchKey, {this.child, this.onSelected});
/// The string to search for.
final String searchKey;
@@ -527,10 +526,7 @@ class _SearchResultItemButtonState extends State<_SearchResultItemButton> {
fontSize: 13.0,
color: _isHovered
? MacosColors.white
- : brightness.resolve(
- MacosColors.black,
- MacosColors.white,
- ),
+ : brightness.resolve(MacosColors.black, MacosColors.white),
),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 8.0),
diff --git a/lib/src/fields/text_field.dart b/lib/src/fields/text_field.dart
index 8564301d..c62f2039 100644
--- a/lib/src/fields/text_field.dart
+++ b/lib/src/fields/text_field.dart
@@ -99,8 +99,8 @@ class _TextFieldSelectionGestureDetectorBuilder
extends TextSelectionGestureDetectorBuilder {
_TextFieldSelectionGestureDetectorBuilder({
required _MacosTextFieldState state,
- }) : _state = state,
- super(delegate: state);
+ }) : _state = state,
+ super(delegate: state);
final _MacosTextFieldState _state;
@@ -111,10 +111,12 @@ class _TextFieldSelectionGestureDetectorBuilder
// this handler. If the clear button widget recognizes the up event,
// then do not handle it.
if (_state._clearGlobalKey.currentContext != null) {
- final RenderBox renderBox = _state._clearGlobalKey.currentContext!
- .findRenderObject()! as RenderBox;
- final Offset localOffset =
- renderBox.globalToLocal(details.globalPosition);
+ final RenderBox renderBox =
+ _state._clearGlobalKey.currentContext!.findRenderObject()!
+ as RenderBox;
+ final Offset localOffset = renderBox.globalToLocal(
+ details.globalPosition,
+ );
if (renderBox.hitTest(BoxHitTestResult(), position: localOffset)) {
return;
}
@@ -293,31 +295,37 @@ class MacosTextField extends StatefulWidget {
this.scrollPhysics,
this.autofillHints,
this.restorationId,
- }) : smartDashesType = smartDashesType ??
- (obscureText ? SmartDashesType.disabled : SmartDashesType.enabled),
- smartQuotesType = smartQuotesType ??
- (obscureText ? SmartQuotesType.disabled : SmartQuotesType.enabled),
- assert(maxLines == null || maxLines > 0),
- assert(minLines == null || minLines > 0),
- assert(
- (maxLines == null) || (minLines == null) || (maxLines >= minLines),
- "minLines can't be greater than maxLines",
- ),
- assert(
- !expands || (maxLines == null && minLines == null),
- 'minLines and maxLines must be null when expands is true.',
- ),
- assert(!obscureText || maxLines == 1,
- 'Obscured fields cannot be multiline.'),
- assert(maxLength == null || maxLength > 0),
- // Assert the following instead of setting it directly to avoid surprising the user by silently changing the value they set.
- assert(
- !identical(textInputAction, TextInputAction.newline) ||
- maxLines == 1 ||
- !identical(keyboardType, TextInputType.text),
- 'Use keyboardType TextInputType.multiline when using TextInputAction.newline on a multiline TextField.'),
- keyboardType = keyboardType ??
- (maxLines == 1 ? TextInputType.text : TextInputType.multiline);
+ }) : smartDashesType =
+ smartDashesType ??
+ (obscureText ? SmartDashesType.disabled : SmartDashesType.enabled),
+ smartQuotesType =
+ smartQuotesType ??
+ (obscureText ? SmartQuotesType.disabled : SmartQuotesType.enabled),
+ assert(maxLines == null || maxLines > 0),
+ assert(minLines == null || minLines > 0),
+ assert(
+ (maxLines == null) || (minLines == null) || (maxLines >= minLines),
+ "minLines can't be greater than maxLines",
+ ),
+ assert(
+ !expands || (maxLines == null && minLines == null),
+ 'minLines and maxLines must be null when expands is true.',
+ ),
+ assert(
+ !obscureText || maxLines == 1,
+ 'Obscured fields cannot be multiline.',
+ ),
+ assert(maxLength == null || maxLength > 0),
+ // Assert the following instead of setting it directly to avoid surprising the user by silently changing the value they set.
+ assert(
+ !identical(textInputAction, TextInputAction.newline) ||
+ maxLines == 1 ||
+ !identical(keyboardType, TextInputType.text),
+ 'Use keyboardType TextInputType.multiline when using TextInputAction.newline on a multiline TextField.',
+ ),
+ keyboardType =
+ keyboardType ??
+ (maxLines == 1 ? TextInputType.text : TextInputType.multiline);
/// Creates a borderless macOS-style text field.
///
@@ -412,31 +420,37 @@ class MacosTextField extends StatefulWidget {
this.autofillHints,
this.restorationId,
this.contextMenuBuilder = _defaultContextMenuBuilder,
- }) : smartDashesType = smartDashesType ??
- (obscureText ? SmartDashesType.disabled : SmartDashesType.enabled),
- smartQuotesType = smartQuotesType ??
- (obscureText ? SmartQuotesType.disabled : SmartQuotesType.enabled),
- assert(maxLines == null || maxLines > 0),
- assert(minLines == null || minLines > 0),
- assert(
- (maxLines == null) || (minLines == null) || (maxLines >= minLines),
- "minLines can't be greater than maxLines",
- ),
- assert(
- !expands || (maxLines == null && minLines == null),
- 'minLines and maxLines must be null when expands is true.',
- ),
- assert(!obscureText || maxLines == 1,
- 'Obscured fields cannot be multiline.'),
- assert(maxLength == null || maxLength > 0),
- // Assert the following instead of setting it directly to avoid surprising the user by silently changing the value they set.
- assert(
- !identical(textInputAction, TextInputAction.newline) ||
- maxLines == 1 ||
- !identical(keyboardType, TextInputType.text),
- 'Use keyboardType TextInputType.multiline when using TextInputAction.newline on a multiline TextField.'),
- keyboardType = keyboardType ??
- (maxLines == 1 ? TextInputType.text : TextInputType.multiline);
+ }) : smartDashesType =
+ smartDashesType ??
+ (obscureText ? SmartDashesType.disabled : SmartDashesType.enabled),
+ smartQuotesType =
+ smartQuotesType ??
+ (obscureText ? SmartQuotesType.disabled : SmartQuotesType.enabled),
+ assert(maxLines == null || maxLines > 0),
+ assert(minLines == null || minLines > 0),
+ assert(
+ (maxLines == null) || (minLines == null) || (maxLines >= minLines),
+ "minLines can't be greater than maxLines",
+ ),
+ assert(
+ !expands || (maxLines == null && minLines == null),
+ 'minLines and maxLines must be null when expands is true.',
+ ),
+ assert(
+ !obscureText || maxLines == 1,
+ 'Obscured fields cannot be multiline.',
+ ),
+ assert(maxLength == null || maxLength > 0),
+ // Assert the following instead of setting it directly to avoid surprising the user by silently changing the value they set.
+ assert(
+ !identical(textInputAction, TextInputAction.newline) ||
+ maxLines == 1 ||
+ !identical(keyboardType, TextInputType.text),
+ 'Use keyboardType TextInputType.multiline when using TextInputAction.newline on a multiline TextField.',
+ ),
+ keyboardType =
+ keyboardType ??
+ (maxLines == 1 ? TextInputType.text : TextInputType.multiline);
static Widget _defaultContextMenuBuilder(
BuildContext context,
@@ -724,156 +738,184 @@ class MacosTextField extends StatefulWidget {
@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
- properties.add(DiagnosticsProperty(
- 'controller',
- controller,
- defaultValue: null,
- ));
- properties.add(DiagnosticsProperty(
- 'focusNode',
- focusNode,
- defaultValue: null,
- ));
- properties.add(DiagnosticsProperty(
- 'decoration',
- decoration,
- defaultValue: kDefaultRoundedBorderDecoration,
- ));
+ properties.add(
+ DiagnosticsProperty(
+ 'controller',
+ controller,
+ defaultValue: null,
+ ),
+ );
+ properties.add(
+ DiagnosticsProperty(
+ 'focusNode',
+ focusNode,
+ defaultValue: null,
+ ),
+ );
+ properties.add(
+ DiagnosticsProperty(
+ 'decoration',
+ decoration,
+ defaultValue: kDefaultRoundedBorderDecoration,
+ ),
+ );
properties.add(DiagnosticsProperty('padding', padding));
properties.add(StringProperty('placeholder', placeholder));
properties.add(
- DiagnosticsProperty(
- 'placeholderStyle',
- placeholderStyle,
+ DiagnosticsProperty('placeholderStyle', placeholderStyle),
+ );
+ properties.add(
+ EnumProperty(
+ 'prefix',
+ prefix == null ? null : prefixMode,
+ ),
+ );
+ properties.add(
+ EnumProperty(
+ 'suffix',
+ suffix == null ? null : suffixMode,
+ ),
+ );
+ properties.add(
+ EnumProperty('clearButtonMode', clearButtonMode),
+ );
+ properties.add(
+ DiagnosticsProperty(
+ 'keyboardType',
+ keyboardType,
+ defaultValue: TextInputType.text,
+ ),
+ );
+ properties.add(
+ DiagnosticsProperty('style', style, defaultValue: null),
+ );
+ properties.add(
+ DiagnosticsProperty('autofocus', autofocus, defaultValue: false),
+ );
+ properties.add(
+ DiagnosticsProperty(
+ 'obscuringCharacter',
+ obscuringCharacter,
+ defaultValue: 'โข',
+ ),
+ );
+ properties.add(
+ DiagnosticsProperty(
+ 'obscureText',
+ obscureText,
+ defaultValue: false,
+ ),
+ );
+ properties.add(
+ DiagnosticsProperty('autocorrect', autocorrect, defaultValue: true),
+ );
+ properties.add(
+ EnumProperty(
+ 'smartDashesType',
+ smartDashesType,
+ defaultValue: obscureText
+ ? SmartDashesType.disabled
+ : SmartDashesType.enabled,
+ ),
+ );
+ properties.add(
+ EnumProperty(
+ 'smartQuotesType',
+ smartQuotesType,
+ defaultValue: obscureText
+ ? SmartQuotesType.disabled
+ : SmartQuotesType.enabled,
+ ),
+ );
+ properties.add(
+ DiagnosticsProperty(
+ 'enableSuggestions',
+ enableSuggestions,
+ defaultValue: true,
),
);
- properties.add(EnumProperty(
- 'prefix',
- prefix == null ? null : prefixMode,
- ));
- properties.add(EnumProperty(
- 'suffix',
- suffix == null ? null : suffixMode,
- ));
- properties.add(EnumProperty(
- 'clearButtonMode',
- clearButtonMode,
- ));
- properties.add(DiagnosticsProperty(
- 'keyboardType',
- keyboardType,
- defaultValue: TextInputType.text,
- ));
- properties.add(DiagnosticsProperty(
- 'style',
- style,
- defaultValue: null,
- ));
- properties.add(DiagnosticsProperty(
- 'autofocus',
- autofocus,
- defaultValue: false,
- ));
- properties.add(DiagnosticsProperty(
- 'obscuringCharacter',
- obscuringCharacter,
- defaultValue: 'โข',
- ));
- properties.add(DiagnosticsProperty(
- 'obscureText',
- obscureText,
- defaultValue: false,
- ));
- properties.add(DiagnosticsProperty(
- 'autocorrect',
- autocorrect,
- defaultValue: true,
- ));
- properties.add(EnumProperty(
- 'smartDashesType',
- smartDashesType,
- defaultValue:
- obscureText ? SmartDashesType.disabled : SmartDashesType.enabled,
- ));
- properties.add(EnumProperty(
- 'smartQuotesType',
- smartQuotesType,
- defaultValue:
- obscureText ? SmartQuotesType.disabled : SmartQuotesType.enabled,
- ));
- properties.add(DiagnosticsProperty(
- 'enableSuggestions',
- enableSuggestions,
- defaultValue: true,
- ));
properties.add(IntProperty('maxLines', maxLines, defaultValue: 1));
properties.add(IntProperty('minLines', minLines, defaultValue: null));
- properties.add(DiagnosticsProperty(
- 'expands',
- expands,
- defaultValue: false,
- ));
+ properties.add(
+ DiagnosticsProperty('expands', expands, defaultValue: false),
+ );
properties.add(IntProperty('maxLength', maxLength, defaultValue: null));
- properties.add(EnumProperty(
- 'maxLengthEnforcement',
- maxLengthEnforcement,
- defaultValue: null,
- ));
- properties.add(DoubleProperty(
- 'cursorWidth',
- cursorWidth,
- defaultValue: 2.0,
- ));
- properties.add(DoubleProperty(
- 'cursorHeight',
- cursorHeight,
- defaultValue: null,
- ));
- properties.add(DiagnosticsProperty(
- 'cursorRadius',
- cursorRadius,
- defaultValue: null,
- ));
- properties.add(createCupertinoColorProperty(
- 'cursorColor',
- cursorColor,
- defaultValue: null,
- ));
- properties.add(FlagProperty(
- 'selectionEnabled',
- value: selectionEnabled,
- defaultValue: true,
- ifFalse: 'selection disabled',
- ));
- properties.add(DiagnosticsProperty(
- 'selectionControls',
- selectionControls,
- defaultValue: null,
- ));
- properties.add(DiagnosticsProperty(
- 'scrollController',
- scrollController,
- defaultValue: null,
- ));
- properties.add(DiagnosticsProperty(
- 'scrollPhysics',
- scrollPhysics,
- defaultValue: null,
- ));
- properties.add(EnumProperty(
- 'textAlign',
- textAlign,
- defaultValue: TextAlign.start,
- ));
- properties.add(DiagnosticsProperty(
- 'textAlignVertical',
- textAlignVertical,
- defaultValue: null,
- ));
- properties.add(DiagnosticsProperty(
- 'contextMenuBuilder',
- contextMenuBuilder,
- ));
+ properties.add(
+ EnumProperty(
+ 'maxLengthEnforcement',
+ maxLengthEnforcement,
+ defaultValue: null,
+ ),
+ );
+ properties.add(
+ DoubleProperty('cursorWidth', cursorWidth, defaultValue: 2.0),
+ );
+ properties.add(
+ DoubleProperty('cursorHeight', cursorHeight, defaultValue: null),
+ );
+ properties.add(
+ DiagnosticsProperty(
+ 'cursorRadius',
+ cursorRadius,
+ defaultValue: null,
+ ),
+ );
+ properties.add(
+ createCupertinoColorProperty(
+ 'cursorColor',
+ cursorColor,
+ defaultValue: null,
+ ),
+ );
+ properties.add(
+ FlagProperty(
+ 'selectionEnabled',
+ value: selectionEnabled,
+ defaultValue: true,
+ ifFalse: 'selection disabled',
+ ),
+ );
+ properties.add(
+ DiagnosticsProperty(
+ 'selectionControls',
+ selectionControls,
+ defaultValue: null,
+ ),
+ );
+ properties.add(
+ DiagnosticsProperty(
+ 'scrollController',
+ scrollController,
+ defaultValue: null,
+ ),
+ );
+ properties.add(
+ DiagnosticsProperty(
+ 'scrollPhysics',
+ scrollPhysics,
+ defaultValue: null,
+ ),
+ );
+ properties.add(
+ EnumProperty(
+ 'textAlign',
+ textAlign,
+ defaultValue: TextAlign.start,
+ ),
+ );
+ properties.add(
+ DiagnosticsProperty(
+ 'textAlignVertical',
+ textAlignVertical,
+ defaultValue: null,
+ ),
+ );
+ properties.add(
+ DiagnosticsProperty(
+ 'contextMenuBuilder',
+ contextMenuBuilder,
+ ),
+ );
}
}
@@ -897,7 +939,7 @@ class _MacosTextFieldState extends State
bool _showSelectionHandles = false;
late _TextFieldSelectionGestureDetectorBuilder
- _selectionGestureDetectorBuilder;
+ _selectionGestureDetectorBuilder;
// API for TextSelectionGestureDetectorBuilderDelegate.
@override
@@ -909,6 +951,7 @@ class _MacosTextFieldState extends State
@override
bool get selectionEnabled => widget.selectionEnabled;
+
// End of API for TextSelectionGestureDetectorBuilderDelegate.
@override
@@ -1046,7 +1089,7 @@ class _MacosTextFieldState extends State
? const Color.fromRGBO(255, 255, 255, 0.55)
: const Color.fromRGBO(0, 0, 0, 0.5);
if (widget.enabled != null && widget.enabled == false) {
- iconsColor = iconsColor.withOpacity(0.2);
+ iconsColor = iconsColor.withValues(alpha: 0.2);
}
// Otherwise, listen to the current state of the text entry.
@@ -1070,10 +1113,7 @@ class _MacosTextFieldState extends State
right: 6.0,
),
child: MacosIconTheme(
- data: MacosIconThemeData(
- color: iconsColor,
- size: 16.0,
- ),
+ data: MacosIconThemeData(color: iconsColor, size: 16.0),
child: widget.prefix!,
),
),
@@ -1146,6 +1186,54 @@ class _MacosTextFieldState extends State
);
}
+ Color? _resolveAccentColor(BuildContext context, AccentColor? accentColor) {
+ if (accentColor == null) {
+ return null;
+ }
+
+ final isDarkModeActive = MacosTheme.of(context).brightness.isDark;
+
+ if (isDarkModeActive) {
+ switch (accentColor) {
+ case AccentColor.blue:
+ return const Color.fromRGBO(0, 122, 255, 1.0);
+ case AccentColor.purple:
+ return const Color.fromRGBO(165, 80, 167, 1.0);
+ case AccentColor.pink:
+ return const Color.fromRGBO(247, 79, 158, 1.0);
+ case AccentColor.red:
+ return const Color.fromRGBO(255, 82, 87, 1.0);
+ case AccentColor.orange:
+ return const Color.fromRGBO(247, 130, 27, 1.0);
+ case AccentColor.yellow:
+ return const Color.fromRGBO(255, 198, 0, 1.0);
+ case AccentColor.green:
+ return const Color.fromRGBO(98, 186, 70, 1.0);
+ case AccentColor.graphite:
+ return const Color.fromRGBO(137, 137, 137, 1.0);
+ }
+ }
+
+ switch (accentColor) {
+ case AccentColor.blue:
+ return const Color.fromRGBO(0, 122, 255, 1.0);
+ case AccentColor.purple:
+ return const Color.fromRGBO(150, 51, 150, 1.0);
+ case AccentColor.pink:
+ return const Color.fromRGBO(247, 79, 158, 1.0);
+ case AccentColor.red:
+ return const Color.fromRGBO(224, 56, 62, 1.0);
+ case AccentColor.orange:
+ return const Color.fromRGBO(247, 130, 27, 1.0);
+ case AccentColor.yellow:
+ return const Color.fromRGBO(255, 199, 38, 1.0);
+ case AccentColor.green:
+ return const Color.fromRGBO(98, 186, 70, 1.0);
+ case AccentColor.graphite:
+ return const Color.fromRGBO(152, 152, 152, 1.0);
+ }
+ }
+
@override
void restoreState(RestorationBucket? oldBucket, bool initialRestore) {
if (_controller != null) {
@@ -1195,251 +1283,278 @@ class _MacosTextFieldState extends State
super.build(context); // See AutomaticKeepAliveClientMixin.
assert(debugCheckHasDirectionality(context));
assert(debugCheckHasMacosTheme(context));
- final TextEditingController controller = _effectiveController;
-
- TextSelectionControls? textSelectionControls = widget.selectionControls;
- switch (defaultTargetPlatform) {
- case TargetPlatform.iOS:
- case TargetPlatform.android:
- case TargetPlatform.fuchsia:
- textSelectionControls ??= cupertinoTextSelectionControls;
- break;
-
- case TargetPlatform.linux:
- case TargetPlatform.windows:
- case TargetPlatform.macOS:
- textSelectionControls ??= cupertinoDesktopTextSelectionControls;
- break;
- }
+ return StreamBuilder(
+ stream: AccentColorListener.instance.onChanged,
+ builder: (context, _) {
+ final TextEditingController controller = _effectiveController;
+
+ TextSelectionControls? textSelectionControls = widget.selectionControls;
+ switch (defaultTargetPlatform) {
+ case TargetPlatform.iOS:
+ case TargetPlatform.android:
+ case TargetPlatform.fuchsia:
+ textSelectionControls ??= cupertinoTextSelectionControls;
+ break;
+
+ case TargetPlatform.linux:
+ case TargetPlatform.windows:
+ case TargetPlatform.macOS:
+ textSelectionControls ??= cupertinoDesktopTextSelectionControls;
+ break;
+ }
- final bool enabled = widget.enabled ?? true;
- final Offset cursorOffset = Offset(
- _iOSHorizontalCursorOffsetPixels /
- MediaQuery.of(context).devicePixelRatio,
- 0,
- );
- final List formatters = [
- ...?widget.inputFormatters,
- if (widget.maxLength != null)
- LengthLimitingTextInputFormatter(
- widget.maxLength,
- maxLengthEnforcement: _effectiveMaxLengthEnforcement,
- ),
- ];
- final MacosThemeData themeData = MacosTheme.of(context);
-
- final TextStyle? resolvedStyle = widget.style?.copyWith(
- color: MacosDynamicColor.maybeResolve(widget.style?.color, context),
- backgroundColor: MacosDynamicColor.maybeResolve(
- widget.style?.backgroundColor,
- context,
- ),
- );
+ final bool enabled = widget.enabled ?? true;
+ final Offset cursorOffset = Offset(
+ _iOSHorizontalCursorOffsetPixels /
+ MediaQuery.of(context).devicePixelRatio,
+ 0,
+ );
+ final List formatters = [
+ ...?widget.inputFormatters,
+ if (widget.maxLength != null)
+ LengthLimitingTextInputFormatter(
+ widget.maxLength,
+ maxLengthEnforcement: _effectiveMaxLengthEnforcement,
+ ),
+ ];
+ final MacosThemeData themeData = MacosTheme.of(context);
+
+ final TextStyle? resolvedStyle = widget.style?.copyWith(
+ color: MacosDynamicColor.maybeResolve(widget.style?.color, context),
+ backgroundColor: MacosDynamicColor.maybeResolve(
+ widget.style?.backgroundColor,
+ context,
+ ),
+ );
- final textStyle = themeData.typography.body.merge(resolvedStyle);
+ final textStyle = themeData.typography.body.merge(resolvedStyle);
- final resolvedPlaceholderStyle = widget.placeholderStyle?.copyWith(
- color: MacosDynamicColor.maybeResolve(
- widget.placeholderStyle?.color,
- context,
- ),
- backgroundColor: MacosDynamicColor.maybeResolve(
- widget.placeholderStyle?.backgroundColor,
- context,
- ),
- );
+ final resolvedPlaceholderStyle = widget.placeholderStyle?.copyWith(
+ color: MacosDynamicColor.maybeResolve(
+ widget.placeholderStyle?.color,
+ context,
+ ),
+ backgroundColor: MacosDynamicColor.maybeResolve(
+ widget.placeholderStyle?.backgroundColor,
+ context,
+ ),
+ );
- final placeholderStyle = textStyle.merge(enabled
- ? resolvedPlaceholderStyle
- : resolvedPlaceholderStyle!
- .copyWith(color: resolvedPlaceholderStyle.color!.withOpacity(0.2)));
-
- final Brightness keyboardAppearance =
- widget.keyboardAppearance ?? MacosTheme.brightnessOf(context);
- Color? cursorColor;
- cursorColor = MacosDynamicColor.maybeResolve(widget.cursorColor, context);
- cursorColor ??=
- themeData.brightness.isDark ? MacosColors.white : MacosColors.black;
- final Color disabledColor =
- MacosDynamicColor.resolve(_kDisabledBackground, context);
-
- Color? decorationColor =
- MacosDynamicColor.maybeResolve(widget.decoration?.color, context);
- if (decorationColor.runtimeType == ResolvedMacosDynamicColor) {
- if ((decorationColor as ResolvedMacosDynamicColor).color ==
- const Color(0xffffffff) ||
- (decorationColor).darkColor == const Color(0xff000000)) {
- decorationColor = themeData.brightness.isDark
- ? const Color.fromRGBO(30, 30, 30, 1)
- : MacosColors.white;
- }
- }
+ final placeholderStyle = textStyle.merge(
+ enabled
+ ? resolvedPlaceholderStyle
+ : resolvedPlaceholderStyle!.copyWith(
+ color: resolvedPlaceholderStyle.color!.withValues(alpha: 0.2),
+ ),
+ );
- final BoxBorder? border = widget.decoration?.border;
- Border? resolvedBorder = border as Border?;
- if (border is Border) {
- BorderSide resolveBorderSide(BorderSide side) {
- return side == BorderSide.none
- ? side
- : side.copyWith(
- color: MacosDynamicColor.resolve(side.color, context),
- );
- }
+ final Brightness keyboardAppearance =
+ widget.keyboardAppearance ?? MacosTheme.brightnessOf(context);
+ Color? cursorColor;
+ cursorColor = MacosDynamicColor.maybeResolve(
+ widget.cursorColor,
+ context,
+ );
+ cursorColor ??= _resolveAccentColor(
+ context,
+ AccentColorListener.instance.currentAccentColor,
+ );
+ cursorColor ??= textStyle.color; // next best is "match text"
+ cursorColor ??= // last resort - fall back to theme forground color
+ themeData.brightness.isDark
+ ? MacosColors.white
+ : MacosColors.black;
+ final Color disabledColor = MacosDynamicColor.resolve(
+ _kDisabledBackground,
+ context,
+ );
- resolvedBorder = border.runtimeType != Border
- ? border
- : Border(
- top: resolveBorderSide(border.top),
- left: resolveBorderSide(border.left),
- bottom: resolveBorderSide(border.bottom),
- right: resolveBorderSide(border.right),
- );
- }
+ Color? decorationColor = MacosDynamicColor.maybeResolve(
+ widget.decoration?.color,
+ context,
+ );
+ if (decorationColor.runtimeType == ResolvedMacosDynamicColor) {
+ if ((decorationColor as ResolvedMacosDynamicColor).color ==
+ const Color(0xffffffff) ||
+ (decorationColor).darkColor == const Color(0xff000000)) {
+ decorationColor = themeData.brightness.isDark
+ ? const Color.fromRGBO(30, 30, 30, 1)
+ : MacosColors.white;
+ }
+ }
- final BoxDecoration? effectiveDecoration = widget.decoration?.copyWith(
- border: resolvedBorder,
- color: enabled ? decorationColor : disabledColor,
- );
+ final BoxBorder? border = widget.decoration?.border;
+ Border? resolvedBorder = border as Border?;
+ if (border is Border) {
+ BorderSide resolveBorderSide(BorderSide side) {
+ return side == BorderSide.none
+ ? side
+ : side.copyWith(
+ color: MacosDynamicColor.resolve(side.color, context),
+ );
+ }
- final BoxDecoration? focusedDecoration = widget.focusedDecoration?.copyWith(
- border: Border.all(
- width: 3.0,
- color: themeData.brightness.isDark
- ? const Color.fromRGBO(26, 169, 255, 0.3)
- : const Color.fromRGBO(0, 103, 244, 0.25),
- ),
- );
+ resolvedBorder = border.runtimeType != Border
+ ? border
+ : Border(
+ top: resolveBorderSide(border.top),
+ left: resolveBorderSide(border.left),
+ bottom: resolveBorderSide(border.bottom),
+ right: resolveBorderSide(border.right),
+ );
+ }
- final focusedPlaceholderDecoration = focusedDecoration?.copyWith(
- border: () {
- if (focusedDecoration.border is Border) {
- BorderSide borderSide(BorderSide fromSide) {
- return BorderSide(
- color: fromSide.color.withOpacity(0.0),
- style: fromSide.style,
- width: fromSide.width,
+ final BoxDecoration? effectiveDecoration = widget.decoration?.copyWith(
+ border: resolvedBorder,
+ color: enabled ? decorationColor : disabledColor,
+ );
+
+ final BoxDecoration? focusedDecoration = widget.focusedDecoration
+ ?.copyWith(
+ border: Border.all(
+ width: 3.0,
+ color: themeData.brightness.isDark
+ ? const Color.fromRGBO(26, 169, 255, 0.3)
+ : const Color.fromRGBO(0, 103, 244, 0.25),
+ ),
);
- }
- return Border(
- bottom: borderSide((focusedDecoration.border as Border).bottom),
- top: borderSide((focusedDecoration.border as Border).top),
- left: borderSide((focusedDecoration.border as Border).left),
- right: borderSide((focusedDecoration.border as Border).right),
- );
- }
- return focusedDecoration.border;
- }(),
- color: focusedDecoration.color ?? const Color(0x00000000),
- );
+ final focusedPlaceholderDecoration = focusedDecoration?.copyWith(
+ border: () {
+ if (focusedDecoration.border is Border) {
+ BorderSide borderSide(BorderSide fromSide) {
+ return BorderSide(
+ color: fromSide.color.withValues(alpha: 0.0),
+ style: fromSide.style,
+ width: fromSide.width,
+ );
+ }
- final Color selectionColor =
- MacosTheme.of(context).primaryColor.withOpacity(0.2);
-
- final Widget paddedEditable = Padding(
- padding: widget.padding,
- child: RepaintBoundary(
- child: UnmanagedRestorationScope(
- bucket: bucket,
- child: EditableText(
- key: editableTextKey,
- controller: controller,
- readOnly: widget.readOnly,
- showCursor: widget.showCursor,
- showSelectionHandles: _showSelectionHandles,
- focusNode: _effectiveFocusNode,
- keyboardType: widget.keyboardType,
- textInputAction: widget.textInputAction,
- textCapitalization: widget.textCapitalization,
- style: textStyle,
- strutStyle: widget.strutStyle,
- textAlign: widget.textAlign,
- autofocus: widget.autofocus,
- obscuringCharacter: widget.obscuringCharacter,
- obscureText: widget.obscureText,
- autocorrect: widget.autocorrect,
- smartDashesType: widget.smartDashesType,
- smartQuotesType: widget.smartQuotesType,
- enableSuggestions: widget.enableSuggestions,
- maxLines: widget.maxLines,
- minLines: widget.minLines,
- expands: widget.expands,
- selectionColor: selectionColor,
- selectionControls:
- widget.selectionEnabled ? textSelectionControls : null,
- onChanged: widget.onChanged,
- onSelectionChanged: _handleSelectionChanged,
- onEditingComplete: widget.onEditingComplete,
- onSubmitted: widget.onSubmitted,
- inputFormatters: formatters,
- rendererIgnoresPointer: true,
- cursorWidth: widget.cursorWidth,
- cursorHeight: widget.cursorHeight,
- cursorRadius: widget.cursorRadius,
- cursorColor: cursorColor,
- cursorOpacityAnimates: true,
- cursorOffset: cursorOffset,
- paintCursorAboveText: true,
- autocorrectionTextRectColor: selectionColor,
- backgroundCursorColor: MacosDynamicColor.resolve(
- CupertinoColors.inactiveGray,
- context,
+ return Border(
+ bottom: borderSide((focusedDecoration.border as Border).bottom),
+ top: borderSide((focusedDecoration.border as Border).top),
+ left: borderSide((focusedDecoration.border as Border).left),
+ right: borderSide((focusedDecoration.border as Border).right),
+ );
+ }
+ return focusedDecoration.border;
+ }(),
+ color: focusedDecoration.color ?? const Color(0x00000000),
+ );
+
+ final Color selectionColor = MacosTheme.of(
+ context,
+ ).primaryColor.withValues(alpha: 0.2);
+
+ final Widget paddedEditable = Padding(
+ padding: widget.padding,
+ child: RepaintBoundary(
+ child: UnmanagedRestorationScope(
+ bucket: bucket,
+ child: EditableText(
+ key: editableTextKey,
+ controller: controller,
+ readOnly: widget.readOnly,
+ showCursor: widget.showCursor,
+ showSelectionHandles: _showSelectionHandles,
+ focusNode: _effectiveFocusNode,
+ keyboardType: widget.keyboardType,
+ textInputAction: widget.textInputAction,
+ textCapitalization: widget.textCapitalization,
+ style: textStyle,
+ strutStyle: widget.strutStyle,
+ textAlign: widget.textAlign,
+ autofocus: widget.autofocus,
+ obscuringCharacter: widget.obscuringCharacter,
+ obscureText: widget.obscureText,
+ autocorrect: widget.autocorrect,
+ smartDashesType: widget.smartDashesType,
+ smartQuotesType: widget.smartQuotesType,
+ enableSuggestions: widget.enableSuggestions,
+ maxLines: widget.maxLines,
+ minLines: widget.minLines,
+ expands: widget.expands,
+ selectionColor: selectionColor,
+ selectionControls: widget.selectionEnabled
+ ? textSelectionControls
+ : null,
+ onChanged: widget.onChanged,
+ onSelectionChanged: _handleSelectionChanged,
+ onEditingComplete: widget.onEditingComplete,
+ onSubmitted: widget.onSubmitted,
+ inputFormatters: formatters,
+ rendererIgnoresPointer: true,
+ cursorWidth: widget.cursorWidth,
+ cursorHeight: widget.cursorHeight,
+ cursorRadius: widget.cursorRadius,
+ cursorColor: cursorColor,
+ cursorOpacityAnimates: true,
+ cursorOffset: cursorOffset,
+ paintCursorAboveText: true,
+ autocorrectionTextRectColor: selectionColor,
+ backgroundCursorColor: MacosDynamicColor.resolve(
+ CupertinoColors.inactiveGray,
+ context,
+ ),
+ selectionHeightStyle: widget.selectionHeightStyle,
+ selectionWidthStyle: widget.selectionWidthStyle,
+ scrollPadding: widget.scrollPadding,
+ keyboardAppearance: keyboardAppearance,
+ dragStartBehavior: widget.dragStartBehavior,
+ scrollController: widget.scrollController,
+ scrollPhysics: widget.scrollPhysics,
+ enableInteractiveSelection: widget.enableInteractiveSelection,
+ autofillHints: widget.autofillHints,
+ restorationId: 'editable',
+ mouseCursor: SystemMouseCursors.text,
+ contextMenuBuilder: widget.contextMenuBuilder,
+ ),
),
- selectionHeightStyle: widget.selectionHeightStyle,
- selectionWidthStyle: widget.selectionWidthStyle,
- scrollPadding: widget.scrollPadding,
- keyboardAppearance: keyboardAppearance,
- dragStartBehavior: widget.dragStartBehavior,
- scrollController: widget.scrollController,
- scrollPhysics: widget.scrollPhysics,
- enableInteractiveSelection: widget.enableInteractiveSelection,
- autofillHints: widget.autofillHints,
- restorationId: 'editable',
- mouseCursor: SystemMouseCursors.text,
- contextMenuBuilder: widget.contextMenuBuilder,
),
- ),
- ),
- );
+ );
- return Semantics(
- enabled: enabled,
- onTap: !enabled || widget.readOnly
- ? null
- : () {
- if (!controller.selection.isValid) {
- controller.selection =
- TextSelection.collapsed(offset: controller.text.length);
- }
- _requestKeyboard();
- },
- child: IgnorePointer(
- ignoring: !enabled,
- child: AnimatedContainer(
- /// Value eyeballed from MacOS Big Sur
- duration: const Duration(milliseconds: 125),
- decoration: _effectiveFocusNode.hasFocus
- ? focusedDecoration
- : focusedPlaceholderDecoration,
- child: Container(
- decoration:
- _effectiveFocusNode.hasFocus ? null : effectiveDecoration,
- child: _selectionGestureDetectorBuilder.buildGestureDetector(
- behavior: HitTestBehavior.translucent,
- child: Align(
- alignment: Alignment(-1.0, _textAlignVertical.y),
- widthFactor: 1.0,
- heightFactor: 1.0,
- child: _addTextDependentAttachments(
- paddedEditable,
- textStyle,
- placeholderStyle,
+ return Semantics(
+ enabled: enabled,
+ onTap: !enabled || widget.readOnly
+ ? null
+ : () {
+ if (!controller.selection.isValid) {
+ controller.selection = TextSelection.collapsed(
+ offset: controller.text.length,
+ );
+ }
+ _requestKeyboard();
+ },
+ child: IgnorePointer(
+ ignoring: !enabled,
+ child: AnimatedContainer(
+ /// Value eyeballed from MacOS Big Sur
+ duration: const Duration(milliseconds: 125),
+ decoration: _effectiveFocusNode.hasFocus
+ ? focusedDecoration
+ : focusedPlaceholderDecoration,
+ child: Container(
+ decoration: _effectiveFocusNode.hasFocus
+ ? null
+ : effectiveDecoration,
+ child: _selectionGestureDetectorBuilder.buildGestureDetector(
+ behavior: HitTestBehavior.translucent,
+ child: Align(
+ alignment: Alignment(-1.0, _textAlignVertical.y),
+ widthFactor: 1.0,
+ heightFactor: 1.0,
+ child: _addTextDependentAttachments(
+ paddedEditable,
+ textStyle,
+ placeholderStyle,
+ ),
+ ),
),
),
),
),
- ),
- ),
+ );
+ },
);
}
}
diff --git a/lib/src/icon/image_icon.dart b/lib/src/icon/image_icon.dart
index 55986dd1..2e7e8a87 100644
--- a/lib/src/icon/image_icon.dart
+++ b/lib/src/icon/image_icon.dart
@@ -71,7 +71,7 @@ class MacosImageIcon extends StatelessWidget {
Color iconColor = color ?? iconTheme.color!;
if (iconOpacity != null && iconOpacity != 1.0) {
- iconColor = iconColor.withOpacity(iconColor.opacity * iconOpacity);
+ iconColor = iconColor.withValues(alpha: iconColor.a * iconOpacity);
}
return Semantics(
@@ -90,12 +90,14 @@ class MacosImageIcon extends StatelessWidget {
@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
- properties.add(DiagnosticsProperty(
- 'image',
- image,
- ifNull: '',
- showName: false,
- ));
+ properties.add(
+ DiagnosticsProperty(
+ 'image',
+ image,
+ ifNull: '',
+ showName: false,
+ ),
+ );
properties.add(DoubleProperty('size', size, defaultValue: null));
properties.add(ColorProperty('color', color, defaultValue: null));
}
diff --git a/lib/src/icon/macos_icon.dart b/lib/src/icon/macos_icon.dart
index 6664ffb4..26beecaa 100644
--- a/lib/src/icon/macos_icon.dart
+++ b/lib/src/icon/macos_icon.dart
@@ -1,6 +1,7 @@
import 'package:flutter/foundation.dart';
import 'package:macos_ui/macos_ui.dart';
import 'package:macos_ui/src/library.dart';
+import 'package:vector_math/vector_math_64.dart';
/// An Icon widget that respects a macOS icon theme.
class MacosIcon extends StatelessWidget {
@@ -85,17 +86,14 @@ class MacosIcon extends StatelessWidget {
if (icon == null) {
return Semantics(
label: semanticLabel,
- child: SizedBox(
- width: iconSize,
- height: iconSize,
- ),
+ child: SizedBox(width: iconSize, height: iconSize),
);
}
final iconOpacity = iconTheme.opacity ?? 1.0;
Color iconColor = color ?? iconTheme.color!;
if (iconOpacity != 1.0) {
- iconColor = iconColor.withOpacity(iconColor.opacity * iconOpacity);
+ iconColor = iconColor.withValues(alpha: iconColor.a * iconOpacity);
}
Widget iconWidget = RichText(
@@ -117,7 +115,8 @@ class MacosIcon extends StatelessWidget {
switch (textDirection) {
case TextDirection.rtl:
iconWidget = Transform(
- transform: Matrix4.identity()..scale(-1.0, 1.0, 1.0),
+ transform: Matrix4.identity()
+ ..scaleByVector3(Vector3(-1.0, 1.0, 1.0)),
alignment: Alignment.center,
transformHitTests: false,
child: iconWidget,
@@ -134,9 +133,7 @@ class MacosIcon extends StatelessWidget {
child: SizedBox(
width: iconSize,
height: iconSize,
- child: Center(
- child: iconWidget,
- ),
+ child: Center(child: iconWidget),
),
),
);
@@ -145,12 +142,9 @@ class MacosIcon extends StatelessWidget {
@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
- properties.add(IconDataProperty(
- 'icon',
- icon,
- ifNull: '',
- showName: false,
- ));
+ properties.add(
+ IconDataProperty('icon', icon, ifNull: '', showName: false),
+ );
properties.add(DoubleProperty('size', size, defaultValue: null));
properties.add(ColorProperty('color', color, defaultValue: null));
}
diff --git a/lib/src/indicators/capacity_indicators.dart b/lib/src/indicators/capacity_indicators.dart
index ed26f90f..57d6ab59 100644
--- a/lib/src/indicators/capacity_indicators.dart
+++ b/lib/src/indicators/capacity_indicators.dart
@@ -80,8 +80,9 @@ class CapacityIndicator extends StatelessWidget {
super.debugFillProperties(properties);
properties.add(DoubleProperty('value', value));
properties.add(ObjectFlagProperty.has('onChanged', onChanged));
- properties
- .add(FlagProperty('discrete', value: discrete, ifFalse: 'continuous'));
+ properties.add(
+ FlagProperty('discrete', value: discrete, ifFalse: 'continuous'),
+ );
properties.add(IntProperty('splits', splits));
properties.add(ColorProperty('color', color));
properties.add(ColorProperty('backgroundColor', backgroundColor));
@@ -101,61 +102,64 @@ class CapacityIndicator extends StatelessWidget {
label: semanticLabel,
value: value.toStringAsFixed(2),
child: Container(
- constraints:
- const BoxConstraints(minWidth: _kCapacityIndicatorMinWidth),
- child: LayoutBuilder(builder: (context, consts) {
- double width = consts.maxWidth;
- if (width.isInfinite) width = 100;
- final splitWidth = width / splits;
- if (discrete) {
- final fillToIndex = (value / 100) * splits - 1;
- return SizedBox(
- width: width,
- child: GestureDetector(
- onPanStart: (event) =>
- _handleUpdate(event.localPosition, splitWidth),
- onPanUpdate: (event) =>
- _handleUpdate(event.localPosition, splitWidth),
- onPanDown: (event) =>
- _handleUpdate(event.localPosition, splitWidth),
- child: Row(
- children: List.generate(splits, (index) {
- return Container(
- padding: EdgeInsets.only(
- right: index == splits - 1 ? 0 : 2.0,
- ),
- width: splitWidth,
- child: CapacityIndicatorCell(
- value: value > 0 && fillToIndex >= index ? 100 : 0,
- backgroundColor: backgroundColor,
- borderColor: borderColor,
- color: color,
- ),
- );
- }),
+ constraints: const BoxConstraints(
+ minWidth: _kCapacityIndicatorMinWidth,
+ ),
+ child: LayoutBuilder(
+ builder: (context, consts) {
+ double width = consts.maxWidth;
+ if (width.isInfinite) width = 100;
+ final splitWidth = width / splits;
+ if (discrete) {
+ final fillToIndex = (value / 100) * splits - 1;
+ return SizedBox(
+ width: width,
+ child: GestureDetector(
+ onPanStart: (event) =>
+ _handleUpdate(event.localPosition, splitWidth),
+ onPanUpdate: (event) =>
+ _handleUpdate(event.localPosition, splitWidth),
+ onPanDown: (event) =>
+ _handleUpdate(event.localPosition, splitWidth),
+ child: Row(
+ children: List.generate(splits, (index) {
+ return Container(
+ padding: EdgeInsets.only(
+ right: index == splits - 1 ? 0 : 2.0,
+ ),
+ width: splitWidth,
+ child: CapacityIndicatorCell(
+ value: value > 0 && fillToIndex >= index ? 100 : 0,
+ backgroundColor: backgroundColor,
+ borderColor: borderColor,
+ color: color,
+ ),
+ );
+ }),
+ ),
),
- ),
- );
- } else {
- return SizedBox(
- width: width,
- child: GestureDetector(
- onPanStart: (event) =>
- _handleUpdate(event.localPosition, splitWidth),
- onPanUpdate: (event) =>
- _handleUpdate(event.localPosition, splitWidth),
- onPanDown: (event) =>
- _handleUpdate(event.localPosition, splitWidth),
- child: CapacityIndicatorCell(
- value: value,
- backgroundColor: backgroundColor,
- borderColor: borderColor,
- color: color,
+ );
+ } else {
+ return SizedBox(
+ width: width,
+ child: GestureDetector(
+ onPanStart: (event) =>
+ _handleUpdate(event.localPosition, splitWidth),
+ onPanUpdate: (event) =>
+ _handleUpdate(event.localPosition, splitWidth),
+ onPanDown: (event) =>
+ _handleUpdate(event.localPosition, splitWidth),
+ child: CapacityIndicatorCell(
+ value: value,
+ backgroundColor: backgroundColor,
+ borderColor: borderColor,
+ color: color,
+ ),
),
- ),
- );
- }
- }),
+ );
+ }
+ },
+ ),
),
);
}
@@ -221,7 +225,9 @@ class _CapacityCellPainter extends CustomPainter {
/// Draw background
canvas.drawRRect(
- BorderRadius.circular(radius).toRRect(Offset.zero & size),
+ const BorderRadius.all(
+ Radius.circular(radius),
+ ).toRRect(Offset.zero & size),
Paint()..color = backgroundColor,
);
@@ -238,7 +244,9 @@ class _CapacityCellPainter extends CustomPainter {
/// Draw border
canvas.drawRRect(
- BorderRadius.circular(radius).toRRect(Offset.zero & size),
+ const BorderRadius.all(
+ Radius.circular(radius),
+ ).toRRect(Offset.zero & size),
Paint()
..color = borderColor
..style = PaintingStyle.stroke
diff --git a/lib/src/indicators/progress_indicators.dart b/lib/src/indicators/progress_indicators.dart
index 6fe47cd9..8124d330 100644
--- a/lib/src/indicators/progress_indicators.dart
+++ b/lib/src/indicators/progress_indicators.dart
@@ -20,8 +20,8 @@ class ProgressCircle extends StatelessWidget {
this.innerColor,
this.borderColor,
this.semanticLabel,
- }) : assert(value == null || value >= 0 && value <= 100),
- assert(radius >= 0);
+ }) : assert(value == null || value >= 0 && value <= 100),
+ assert(radius >= 0);
/// The value of the progress circle. If non-null, this has to
/// be non-negative and less the 100. If null, the progress circle
@@ -53,11 +53,13 @@ class ProgressCircle extends StatelessWidget {
properties.add(ColorProperty('innerColor', innerColor));
properties.add(ColorProperty('borderColor', borderColor));
properties.add(StringProperty('semanticLabel', semanticLabel));
- properties.add(FlagProperty(
- 'determinate',
- value: isDeterminate,
- ifFalse: 'indeterminate',
- ));
+ properties.add(
+ FlagProperty(
+ 'determinate',
+ value: isDeterminate,
+ ifFalse: 'indeterminate',
+ ),
+ );
}
@override
@@ -87,9 +89,7 @@ class ProgressCircle extends StatelessWidget {
} else {
return Semantics(
label: semanticLabel,
- child: c.CupertinoActivityIndicator(
- radius: radius,
- ),
+ child: c.CupertinoActivityIndicator(radius: radius),
);
}
}
@@ -114,11 +114,7 @@ class _DeterminateCirclePainter extends CustomPainter {
@override
void paint(Canvas canvas, Size size) {
/// Draw an arc
- void drawArc(
- double value, {
- Paint? paint,
- bool useCenter = true,
- }) {
+ void drawArc(double value, {Paint? paint, bool useCenter = true}) {
canvas.drawArc(
Offset.zero & size,
_startAngle,
@@ -163,8 +159,8 @@ class ProgressBar extends StatelessWidget {
this.trackColor,
this.backgroundColor,
this.semanticLabel,
- }) : assert(value >= 0 && value <= 100),
- assert(height >= 0);
+ }) : assert(value >= 0 && value <= 100),
+ assert(height >= 0);
/// The value of the progress bar. If non-null, this has to
/// be non-negative and less the 100. If null, the progress bar
@@ -240,9 +236,7 @@ class _DeterminateBarPainter extends CustomPainter {
void paint(Canvas canvas, Size size) {
// Draw the background line
canvas.drawRRect(
- const BorderRadius.all(Radius.circular(100)).toRRect(
- Offset.zero & size,
- ),
+ const BorderRadius.all(Radius.circular(100)).toRRect(Offset.zero & size),
Paint()
..color = backgroundColor ?? CupertinoColors.secondarySystemFill
..style = PaintingStyle.fill,
@@ -252,10 +246,7 @@ class _DeterminateBarPainter extends CustomPainter {
canvas.drawRRect(
const BorderRadius.horizontal(left: Radius.circular(100)).toRRect(
Offset.zero &
- Size(
- (value / 100).clamp(0.0, 1.0) * size.width,
- size.height,
- ),
+ Size((value / 100).clamp(0.0, 1.0) * size.width, size.height),
),
Paint()
..color = activeColor ?? CupertinoColors.activeBlue
diff --git a/lib/src/indicators/rating_indicator.dart b/lib/src/indicators/rating_indicator.dart
index eb3cdb7c..172174fb 100644
--- a/lib/src/indicators/rating_indicator.dart
+++ b/lib/src/indicators/rating_indicator.dart
@@ -28,9 +28,9 @@ class RatingIndicator extends StatelessWidget {
this.iconSize = 16,
this.onChanged,
this.semanticLabel,
- }) : assert(iconSize >= 0),
- assert(amount > 0),
- assert(value >= 0 && value <= amount);
+ }) : assert(iconSize >= 0),
+ assert(amount > 0),
+ assert(value >= 0 && value <= amount);
/// The icon used when the star is rated. [CupertinoIcons.star_fill]
/// is used by default. If you must replace the star with a custom
diff --git a/lib/src/indicators/relevance_indicator.dart b/lib/src/indicators/relevance_indicator.dart
index 5d8d0dd2..78482622 100644
--- a/lib/src/indicators/relevance_indicator.dart
+++ b/lib/src/indicators/relevance_indicator.dart
@@ -23,10 +23,10 @@ class RelevanceIndicator extends StatelessWidget {
this.selectedColor = CupertinoColors.label,
this.unselectedColor = CupertinoColors.secondaryLabel,
this.semanticLabel,
- }) : assert(value >= 0 && value <= amount),
- assert(amount > 0),
- assert(barHeight >= 0),
- assert(barWidth >= 0);
+ }) : assert(value >= 0 && value <= amount),
+ assert(amount > 0),
+ assert(barHeight >= 0),
+ assert(barWidth >= 0);
/// The current value of the indicator. It must be in the range
/// of 0 to [amount]
diff --git a/lib/src/indicators/slider.dart b/lib/src/indicators/slider.dart
index e32fc360..f8dde671 100644
--- a/lib/src/indicators/slider.dart
+++ b/lib/src/indicators/slider.dart
@@ -36,9 +36,9 @@ class MacosSlider extends StatelessWidget {
this.tickBackgroundColor = MacosColors.tickBackgroundColor,
this.thumbColor = MacosColors.sliderThumbColor,
this.semanticLabel,
- }) : assert(value >= min && value <= max),
- assert(min < max),
- assert(splits >= 2);
+ }) : assert(value >= min && value <= max),
+ assert(min < max),
+ assert(splits >= 2);
/// The value of this slider.
///
@@ -99,8 +99,9 @@ class MacosSlider extends StatelessWidget {
properties.add(ColorProperty('backgroundColor', backgroundColor));
properties.add(ColorProperty('tickBackgroundColor', tickBackgroundColor));
properties.add(ColorProperty('thumbColor', thumbColor));
- properties
- .add(FlagProperty('discrete', value: discrete, ifTrue: 'discrete'));
+ properties.add(
+ FlagProperty('discrete', value: discrete, ifTrue: 'discrete'),
+ );
properties.add(IntProperty('splits', splits));
properties.add(StringProperty('semanticLabel', semanticLabel));
}
@@ -168,8 +169,9 @@ class MacosSlider extends StatelessWidget {
children: [
Center(
child: Container(
- margin:
- EdgeInsets.symmetric(horizontal: horizontalPadding),
+ margin: EdgeInsets.symmetric(
+ horizontal: horizontalPadding,
+ ),
height: _kSliderHeight,
width: width,
decoration: BoxDecoration(
@@ -186,8 +188,9 @@ class MacosSlider extends StatelessWidget {
Align(
alignment: Alignment.centerLeft,
child: Container(
- margin:
- EdgeInsets.symmetric(horizontal: horizontalPadding),
+ margin: EdgeInsets.symmetric(
+ horizontal: horizontalPadding,
+ ),
height: _kSliderHeight,
width: width * _percentage,
decoration: BoxDecoration(
@@ -200,8 +203,9 @@ class MacosSlider extends StatelessWidget {
),
if (discrete)
Padding(
- padding:
- EdgeInsets.symmetric(horizontal: horizontalPadding),
+ padding: EdgeInsets.symmetric(
+ horizontal: horizontalPadding,
+ ),
child: SizedBox(
height: _kOverallHeight,
width: width,
@@ -229,8 +233,10 @@ class MacosSlider extends StatelessWidget {
horizontal: horizontalPadding,
),
child: _ContinuousThumb(
- color:
- MacosDynamicColor.resolve(thumbColor, context),
+ color: MacosDynamicColor.resolve(
+ thumbColor,
+ context,
+ ),
),
),
),
@@ -244,8 +250,10 @@ class MacosSlider extends StatelessWidget {
horizontal: horizontalPadding,
),
child: _DiscreteThumb(
- color:
- MacosDynamicColor.resolve(thumbColor, context),
+ color: MacosDynamicColor.resolve(
+ thumbColor,
+ context,
+ ),
),
),
),
@@ -261,9 +269,7 @@ class MacosSlider extends StatelessWidget {
}
class _ContinuousThumb extends StatelessWidget {
- const _ContinuousThumb({
- required this.color,
- });
+ const _ContinuousThumb({required this.color});
final Color color;
@@ -274,8 +280,9 @@ class _ContinuousThumb extends StatelessWidget {
width: _kContinuousThumbSize,
decoration: BoxDecoration(
color: color,
- borderRadius:
- const BorderRadius.all(Radius.circular(_kContinuousThumbSize)),
+ borderRadius: const BorderRadius.all(
+ Radius.circular(_kContinuousThumbSize),
+ ),
boxShadow: const [
BoxShadow(
color: Color.fromRGBO(0, 0, 0, 0.1),
@@ -290,9 +297,7 @@ class _ContinuousThumb extends StatelessWidget {
}
class _DiscreteThumb extends StatelessWidget {
- const _DiscreteThumb({
- required this.color,
- });
+ const _DiscreteThumb({required this.color});
final Color color;
@override
diff --git a/lib/src/labels/tooltip.dart b/lib/src/labels/tooltip.dart
index 35022953..90518765 100644
--- a/lib/src/labels/tooltip.dart
+++ b/lib/src/labels/tooltip.dart
@@ -92,8 +92,9 @@ class _MacosTooltipState extends State
vsync: this,
)..addStatusListener(_handleStatusChanged);
// Listen to see when a mouse is added.
- RendererBinding.instance.mouseTracker
- .addListener(_handleMouseTrackerChange);
+ RendererBinding.instance.mouseTracker.addListener(
+ _handleMouseTrackerChange,
+ );
// Listen to global pointer events so that we can hide a tooltip immediately
// if some other control is clicked on.
GestureBinding.instance.pointerRouter.addGlobalRoute(_handlePointerEvent);
@@ -244,10 +245,12 @@ class _MacosTooltipState extends State
@override
void dispose() {
- GestureBinding.instance.pointerRouter
- .removeGlobalRoute(_handlePointerEvent);
- RendererBinding.instance.mouseTracker
- .removeListener(_handleMouseTrackerChange);
+ GestureBinding.instance.pointerRouter.removeGlobalRoute(
+ _handlePointerEvent,
+ );
+ RendererBinding.instance.mouseTracker.removeListener(
+ _handleMouseTrackerChange,
+ );
if (_entry != null) _removeEntry();
_controller.dispose();
super.dispose();
@@ -392,10 +395,7 @@ class _TooltipOverlay extends StatelessWidget {
child: Center(
widthFactor: 1.0,
heightFactor: 1.0,
- child: Text(
- message,
- style: textStyle,
- ),
+ child: Text(message, style: textStyle),
),
),
),
diff --git a/lib/src/layout/content_area.dart b/lib/src/layout/content_area.dart
index 5026e260..a7f6b915 100644
--- a/lib/src/layout/content_area.dart
+++ b/lib/src/layout/content_area.dart
@@ -10,10 +10,8 @@ class ContentArea extends StatelessWidget {
///
/// The width of this
/// widget is automatically calculated in [MacosScaffoldScope].
- const ContentArea({
- required this.builder,
- this.minWidth = 300,
- }) : super(key: const Key('macos_scaffold_content_area'));
+ const ContentArea({required this.builder, this.minWidth = 300})
+ : super(key: const Key('macos_scaffold_content_area'));
/// The builder that creates a child to display in this widget.
final ScrollableWidgetBuilder? builder;
@@ -24,9 +22,7 @@ class ContentArea extends StatelessWidget {
@override
Widget build(BuildContext context) {
return ConstrainedBox(
- constraints: const BoxConstraints.expand().copyWith(
- minWidth: minWidth,
- ),
+ constraints: const BoxConstraints.expand().copyWith(minWidth: minWidth),
child: SafeArea(
left: false,
right: false,
diff --git a/lib/src/layout/macos_list_tile.dart b/lib/src/layout/macos_list_tile.dart
index 1251e755..2bac3daf 100644
--- a/lib/src/layout/macos_list_tile.dart
+++ b/lib/src/layout/macos_list_tile.dart
@@ -56,16 +56,14 @@ class MacosListTile extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
DefaultTextStyle(
- style: MacosTheme.of(context).typography.headline.copyWith(
- fontWeight: FontWeight.bold,
- ),
+ style: MacosTheme.of(
+ context,
+ ).typography.headline.copyWith(fontWeight: FontWeight.bold),
child: title,
),
if (subtitle != null)
DefaultTextStyle(
- style: MacosTheme.of(context)
- .typography
- .subheadline
+ style: MacosTheme.of(context).typography.subheadline
.copyWith(
color: MacosTheme.brightnessOf(context).isDark
? MacosColors.systemGrayColor
diff --git a/lib/src/layout/resizable_pane.dart b/lib/src/layout/resizable_pane.dart
index 97836bdd..837c83a7 100644
--- a/lib/src/layout/resizable_pane.dart
+++ b/lib/src/layout/resizable_pane.dart
@@ -46,16 +46,13 @@ class ResizablePane extends StatefulWidget {
required this.resizableSide,
this.windowBreakpoint,
required this.startSize,
- }) : child = null,
- useScrollBar = true,
- assert(
- maxSize >= minSize,
- 'minSize should not be more than maxSize.',
- ),
- assert(
- (startSize >= minSize) && (startSize <= maxSize),
- 'startSize must not be less than minSize or more than maxWidth',
- );
+ }) : child = null,
+ useScrollBar = true,
+ assert(maxSize >= minSize, 'minSize should not be more than maxSize.'),
+ assert(
+ (startSize >= minSize) && (startSize <= maxSize),
+ 'startSize must not be less than minSize or more than maxWidth',
+ );
/// Creates a [ResizablePane] without an internal [MacosScrollbar].
///
@@ -75,16 +72,13 @@ class ResizablePane extends StatefulWidget {
required this.resizableSide,
this.windowBreakpoint,
required this.startSize,
- }) : builder = null,
- useScrollBar = false,
- assert(
- maxSize >= minSize,
- 'minSize should not be more than maxSize.',
- ),
- assert(
- (startSize >= minSize) && (startSize <= maxSize),
- 'startSize must not be less than minSize or more than maxWidth',
- );
+ }) : builder = null,
+ useScrollBar = false,
+ assert(maxSize >= minSize, 'minSize should not be more than maxSize.'),
+ assert(
+ (startSize >= minSize) && (startSize <= maxSize),
+ 'startSize must not be less than minSize or more than maxWidth',
+ );
/// The builder that creates a child to display in this widget, which will
/// use the provided [_scrollController] to enable the scrollbar to work.
@@ -206,14 +200,12 @@ class _ResizablePaneState extends State {
},
onVerticalDragUpdate: (details) {
setState(() {
- final newHeight = _dragStartSize +
+ final newHeight =
+ _dragStartSize +
(_dragStartPosition - details.globalPosition.dy);
_size = math.max(
widget.minSize,
- math.min(
- widget.maxSize,
- newHeight,
- ),
+ math.min(widget.maxSize, newHeight),
);
if (_size == widget.minSize) {
_cursor = SystemMouseCursors.resizeUp;
@@ -239,15 +231,12 @@ class _ResizablePaneState extends State {
setState(() {
final newWidth = _resizeOnRight
? _dragStartSize -
- (_dragStartPosition - details.globalPosition.dx)
+ (_dragStartPosition - details.globalPosition.dx)
: _dragStartSize +
- (_dragStartPosition - details.globalPosition.dx);
+ (_dragStartPosition - details.globalPosition.dx);
_size = math.max(
widget.minSize,
- math.min(
- widget.maxSize,
- newWidth,
- ),
+ math.min(widget.maxSize, newWidth),
);
if (_size == widget.minSize) {
_cursor = _resizeOnRight
@@ -343,12 +332,7 @@ class _ResizablePaneState extends State