nank1ro / flutter-shadcn-ui

shadcn-ui ported in Flutter. Awesome UI components for Flutter, fully customizable.
https://flutter-shadcn-ui.mariuti.com
MIT License
1.11k stars 63 forks source link

ShadBorder sides isn't merged #184

Open dickermoshe opened 22 hours ago

dickermoshe commented 22 hours ago

Steps to reproduce

  1. Merge a ShadBorder with another ShadBorder

Expected results

  1. Get a mix of the 2

Actual results

It's completely replaced!

image

ShadBorder sides has a default of BorderSide.none instead of null, so a copyWith will result in these values getting replaced!

shadcn_ui version

0.14.1

Platform

MacOS, Windows, Linux, Android, iOS, Web

Code sample

Code sample ```dart ShadInput( placeholder: const Text('Search'), decoration: ShadDecoration( focusedBorder: ShadBorder( radius: BorderRadius.circular(16)), border: ShadBorder( radius: BorderRadius.circular(16))), ) ```

Screenshots or Video

Screenshots / Video demonstration Why is the border gone https://github.com/user-attachments/assets/df2bb663-294f-43e0-99c4-698716941bae

Logs

Logs ```console N/A```

Flutter Doctor output

Doctor output ```console Doctor summary (to see all details, run flutter doctor -v): [√] Flutter (Channel stable, 3.24.3, on Microsoft Windows [Version 10.0.22631.4317], locale en-US) [√] Windows Version (Installed version of Windows is version 10 or higher) [√] Android toolchain - develop for Android devices (Android SDK version 34.0.0) [√] Chrome - develop for the web [√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.11.5) [√] Android Studio (version 2023.1) [√] VS Code, 64-bit edition (version 1.93.1) [!] Proxy Configuration ! NO_PROXY does not contain ::1 [√] Connected device (3 available) [√] Network resources ! Doctor found issues in 1 category. ```
nank1ro commented 20 hours ago

I was sure that I already addressed this issue. With ShadBorder.all do you have the same issue?

This is the default border of the input theme

border: ShadBorder.all(
  width: 2,
  color: colorScheme.border,
  radius: radius,
),

And if in the Input field I use border: ShadBorder.all(radius: BorderRadius.circular(50)) the radius is merged correctly.

dickermoshe commented 2 hours ago

This is a broader issue. merge() should only override explicitly set properties. So there can't be defaults on themes anywhere. I'm gonna work on a PR which will resolve all of this. The package is littered with many instances of themes with defaults.

dickermoshe commented 1 hour ago

For this specifically, the merge is much more complex: See the flutter code for BorderSide.merge.

https://github.com/flutter/flutter/blob/2da2332ad1be7ed6efc049155e1f47d1fde2276b/packages/flutter/lib/src/painting/borders.dart#L85-L106

dickermoshe commented 1 hour ago

https://github.com/nank1ro/flutter-shadcn-ui/pull/185