app_toast 0.0.5

SDKflutter
Platformandroidiosweb

A simple Flutter package for displaying toast messages and snackbars with customizable options.

app_toast

A simple Flutter package for displaying toast messages and snackbars with customizable options.

Features

  • Show toast messages with different durations and styles.
  • Display snackbars using the ScaffoldMessenger.
  • Customizable background color, text color, font size, and gravity for toast messages.
  • Built-in error message styling.

Installation

Add the following dependency to your pubspec.yaml file:

dependencies:
  app_toast: latest_version

Then, run:

flutter pub get

Usage

Show a Toast Message

import 'package:app_toast/app_toast.dart';

AppToast.showToast(
  msg: "This is a toast message",
  longTime: true,  // Set to false for a short duration
  gravity: ToastGravity.BOTTOM,
  bgColor: Colors.black,
  txtColor: Colors.white,
  fontSize: 16.0,
  isErrorMsg: false, // Set to true for error messages
);

Show a Snackbar

import 'package:app_toast/app_toast.dart';

AppToast.showSnackBar(
  context: context,
  msg: "This is a snackbar message",
  bgColor: Colors.blueGrey,
);

Parameters

showToast Method

ParameterTypeDefault ValueDescription
msgStringRequiredThe message to display.
longTimebooltrueSet to false for a short duration.
timeint2Duration for iOS/Web (in seconds).
gravityToastGravityToastGravity.SNACKBARThe position of the toast.
bgColorColor?Colors.blueGrey.shade800Background color of the toast.
txtColorColor?Colors.whiteText color of the toast.
fontSizedouble14.0Font size of the text.
isErrorMsgboolfalseIf true, the toast will have an error style.

showSnackBar Method

ParameterTypeDescription
contextBuildContextRequired. The current context.
msgStringRequired. The message to display.
bgColorColor?Optional. Background color of the snackbar.

Dependencies

This package depends on:

  • fluttertoast for displaying toast messages.

Make sure to include fluttertoast in your project:

dependencies:
  fluttertoast: latest_version

License

This package is available under the MIT license.

Contributions

Contributions are welcome! Feel free to open issues or submit PRs on GitHub.

Support

If you find this package helpful, consider giving it a ⭐ on GitHub!