cmdrootaccess / another-flushbar

A flexible widget for user notification. Customize your text, button, duration, animations and much more. For Android devs, it is made to replace Snackbars and Toasts.
https://pub.dev/packages/another_flushbar
MIT License
146 stars 90 forks source link

FlushbarHelper.createAction() "button" parameter takes a FlatButton which is now deprecated in favor of TextButton. #4

Closed wayne-werner closed 3 years ago

wayne-werner commented 3 years ago

FlushbarHelper.createAction() "button" parameter takes a FlatButton which is now deprecated in favor of TextButton (at least on beta channel, so stable can't be far behind if not there already). This, of course, causes a deprecation warning.

This is just passed through to Flushbar ctor's "mainButton" parameter, which takes a Widget:

  /// Get a flushbar that can receive a user action through a button.
  static Flushbar createAction(
      {@required String message,
        @required FlatButton button, // deprecated
        String title,
        Duration duration = const Duration(seconds: 3)}) {
    return Flushbar(
      title: title,
      message: message,
      duration: duration,
      mainButton: button,
    );

This can be most easily and probably very safely corrected by doing what Flushbar itself does for mainButton, and accept a Widget:

  /// Get a flushbar that can receive a user action through a button.
  static Flushbar createAction(
      {@required String message,
        @required Widget button, // does the trick
        String title,
        Duration duration = const Duration(seconds: 3)}) {
    return Flushbar(
      title: title,
      message: message,
      duration: duration,
      mainButton: button,
    );

Shouldn't break any existing code, and has the advantage of offering the user more choice to pass what they want, like an ElevatedButton or an IconButton.

The documentation should also be amended to merely recommend TextButton for createAction.

BTW, StatelessWidget is the closest common ancestor for TextButton and FlatButton, so, might as well just go to Widget. Can't hurt.

Thanks for taking over flushbar! another_flushbar is much appreciated!

cmdrootaccess commented 3 years ago

fixed in 1.10.10. Thanks