Custom toast message in flutter

 import 'package:flutter/material.dart';


class CustomToast {
  static void show(String message, BuildContext context) {
    ScaffoldMessenger.of(context).showSnackBar(
      SnackBar(
        content: Text(
          message,
          style: TextStyle(color: Colors.white),
        ),
        backgroundColor: Colors.black,
        duration: const Duration(seconds: 2),
        behavior: SnackBarBehavior.floating,
        shape: RoundedRectangleBorder(
          borderRadius: BorderRadius.circular(10), // Set border radius to 10px
        ),
      ),
    );
  }
}



//call it like this
CustomToast.show("Item deleted!", context);

Comments