Using a Mac? You might find www.synapsemac.com useful :)

Tuesday, 26 September 2023

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);

No comments:

Post a Comment