How to use your flutter app project flutter Custom widget as like notification Widget?
Here is an example:
import 'package:flutter/material.dart';
class NotificationWidget extends StatelessWidget {
final String message;
const NotificationWidget({Key key, this.message}) : super(key: key);
@override
Widget build(BuildContext context) {
return Container(
padding: EdgeInsets.all(10),
decoration: BoxDecoration(
color: Colors.red,
borderRadius: BorderRadius.circular(10),
),
child: Text(
message,
style: TextStyle(color: Colors.white),
),
);
}
}
You can use this NotificationWidget
in your other widgets and pass the message as a parameter. It will create a notification container with red background and white text.
NotificationWidget(message: "Notification message here")
You can customize the look and feel of the notification according to your app’s design. Also, you can use the showDialog()
function to show the notification as a dialog box instead of using it as a widget.
Read also: Flutter Gradient (linear and radial) and How to use positioned Widget?