pm_toast 1.0.8

SDKflutter
Platformandroidioswindowslinuxmacosweb

A Flutter package showcasing customizable toast messages with optional images and buttons, supporting both Android and iOS.

Flutter PM Toast

Custom Toast Library for Flutter

pub package

A flutter widget for the display of messages

Supported Platforms

  • Android
  • IOS

How to Use

# add this line to your dependencies
pm_toast: ^1.0.8
import 'package:pm_toast/pm_toast.dart';

Flutter PM Toast (Android & iOS)

import 'package:flutter/material.dart';
import 'package:pm_toast/pm_toast.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: HomeScreen(),
    );
  }
}

class HomeScreen extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
          title: const Center(child: Text(' PM Toast Package ')),
          backgroundColor: Colors.purple[100]),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            ElevatedButton(
              onPressed: () {
                PMToast(
                  context: context,
                  message: 'This is a simple toast!',
                ).show();
              },
              child: const Text('Show Simple Toast'),
            ),
            const SizedBox(height: 20),
            ElevatedButton(
              onPressed: () {
                PMToast(
                  context: context,
                  message: 'This is a toast with a button!',
                  backgroundColor: Colors.purple,
                  textColor: Colors.white,
                  fontSize: 18.0,
                  borderRadius: const BorderRadius.all(Radius.circular(20.0)),
                  position: ToastPosition.bottom,
                  leftImage: const Icon(Icons.info, color: Colors.white),
                  rightButton: const Icon(Icons.close, color: Colors.white),
                  onRightButtonPressed: () {
                    print('Right button pressed');
                  },
                ).show();
              },
              child: const Text('Show Toast with Button'),
            ),
          ],
        ),
      ),
    );
  }
}

propertydescriptiondefault
messageString (Not Null)(required)required
durationDuration(seconds: 2) (optional)2 (sec)
toastLengthToast.LENGTH_SHORT or Toast.LENGTH_LONG (optional)Toast.LENGTH_SHORT
gravityToastGravity.TOP (or) ToastGravity.CENTER (or) ToastGravity.BOTTOMToastGravity.BOTTOM
backgroundColorColors.rednull
textcolorColors.whitenull
fontSize16.0 (float)null
borderRadius8.0 (float)8

For more details check the example project

propertydescriptiondefault
childWidget (Not Null)(required)required
toastDurationDuration (optional)
gravityToastGravity.*

Preview Example (BuildContext)

example

Author

PM Coding

Contributing

Contributions, issues, and feature requests are welcome!

Show your Support

Give a star if this project helped you.