darioielardi / flutter_speed_dial

Flutter plugin to implement a Material Design Speed Dial
https://pub.dev/packages/flutter_speed_dial
MIT License
416 stars 178 forks source link

Material 3 #279

Open yegor-pelykh opened 1 year ago

yegor-pelykh commented 1 year ago

Hi! Is it possible to make this control look like Material 3 FAB if that "Material 3" mode is used in the application?

Just for information: The "Material 3" theme mode can be set using the useMaterial3 property of the ThemeData class when setting it as a theme in the MaterialApp widget. example

In fact, I have already tried this "Material 3" mode in my app with a SpeedDial. This control already looks pretty good when opened: speed-dial example

But the main FAB button still looks wrong, which looks quite inappropriate.

Could you fix this button with some styling, please?

For reference, the documentation for Material 3 FAB: https://m3.material.io/components/floating-action-button

nvi9 commented 1 year ago

You can specify the shape to override the currently default StadiumBorder, this way it looks similar to M3 FAB:

SpeedDial(
  shape: RoundedRectangleBorder(
    borderRadius: BorderRadius.circular(16),
  ),
  ...
)
yegor-pelykh commented 1 year ago

Yes, I can specify this shape, but in fact, I am now noticed that this is not enough to match Material 3. Both in part of the main fab, and in part of speed-dial children. Could you please do a full inspection of the controls to match Material 3?

For the reference: https://m3.material.io/components/floating-action-button/specs Section "Small FAB layout".

Specs

nizioleque commented 1 year ago

Hi, after some tweaking I found the configuration that matches the M3 spec :)

Here is some example code

SpeedDial(
  shape: const RoundedRectangleBorder(
    borderRadius: BorderRadius.all(Radius.circular(16)),
  ),
  spacing: 16,
  childMargin: EdgeInsets.zero,
  childPadding: const EdgeInsets.all(8.0),
  children: [
    SpeedDialChild(
      shape: const RoundedRectangleBorder(
        borderRadius: BorderRadius.all(Radius.circular(12)),
      ),
    ),
    SpeedDialChild(
      shape: const RoundedRectangleBorder(
        borderRadius: BorderRadius.all(Radius.circular(12)),
      ),
    ),
  ]
)

and here is the result image

and a comparison image