motion_toast 1.2.0 copy "motion_toast: ^1.2.0" to clipboard
motion_toast: ^1.2.0 copied to clipboard

outdated

A beautiful designed toast with animations, contains multiple built in designs and let you design your toast

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:motion_toast/motion_toast.dart';
import 'package:motion_toast/resources/arrays.dart';

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

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Motion Toast Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: Scaffold(
        body: HomePage(),
      ),
    );
  }
}

class HomePage extends StatelessWidget {
  const HomePage({
    Key? key,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return SafeArea(
      child: Container(
        width: double.infinity,
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            Text(
              "Motion Toast Examples",
              style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18),
            ),
            SizedBox(
              height: 30,
            ),
            Container(
              width: 200,
              child: ElevatedButton(
                  onPressed: () {
                    _displaySuccessMotionToast(context);
                  },
                  child: Text("Success Motion Toast")),
            ),
            SizedBox(
              height: 10,
            ),
            Container(
              width: 200,
              child: ElevatedButton(
                  onPressed: () {
                    _displayWarningMotionToast(context);
                  },
                  child: Text("Warning Motion Toast")),
            ),
            SizedBox(
              height: 10,
            ),
            Container(
              width: 200,
              child: ElevatedButton(
                  onPressed: () {
                    _displayErrorMotionToast(context);
                  },
                  child: Text("Error Motion Toast")),
            ),
            SizedBox(
              height: 10,
            ),
            Container(
              width: 200,
              child: ElevatedButton(
                  onPressed: () {
                    _displayInfoMotionToast(context);
                  },
                  child: Text("Info Motion Toast")),
            ),
            SizedBox(
              height: 10,
            ),
            Container(
              width: 200,
              child: ElevatedButton(
                  onPressed: () {
                    _displayDeleteMotionToast(context);
                  },
                  child: Text("Delete Motion Toast")),
            ),
            SizedBox(
              height: 10,
            ),
            Container(
              width: 200,
              child: ElevatedButton(
                  onPressed: () {
                    _displayCustomMotionToast(context);
                  },
                  child: Text("Custom Motion Toast")),
            ),
            SizedBox(
              height: 10,
            ),
            Container(
              width: 200,
              child: ElevatedButton(
                  onPressed: () {
                    _displayCenterMotionToast(context);
                  },
                  child: Text("Center Motion Toast")),
            ),
            SizedBox(
              height: 10,
            ),
            Container(
              width: 200,
              child: ElevatedButton(
                  onPressed: () {
                    _displayTopMotionToast(context);
                  },
                  child: Text("Top Motion Toast")),
            ),
          ],
        ),
      ),
    );
  }

  _displaySuccessMotionToast(BuildContext context) {
    MotionToast.success(
      title: "من اليمين",
      titleStyle: TextStyle(fontWeight: FontWeight.bold),
      description: "هذا مثال بالعربية",
      descriptionStyle: TextStyle(fontSize: 12),
      layoutOrientation: ORIENTATION.RTL,
      animationType: ANIMATION.FROM_RIGHT,
      width: 300,
    ).show(context);
  }

  _displayWarningMotionToast(BuildContext context) {
    MotionToast.warning(
      title: "Warning Motion Toast",
      titleStyle: TextStyle(fontWeight: FontWeight.bold),
      description: "This is a Warning",
      animationCurve: Curves.bounceIn,
      animationDuration: Duration(milliseconds: 1000),
    ).show(context);
  }

  _displayErrorMotionToast(BuildContext context) {
    MotionToast.error(
      title: "Error",
      titleStyle: TextStyle(fontWeight: FontWeight.bold),
      description: "Please enter your name",
      animationType: ANIMATION.FROM_LEFT,
      position: MOTION_TOAST_POSITION.TOP,
      width: 300,
    ).show(context);
  }

  _displayInfoMotionToast(BuildContext context) {
    MotionToast.info(
            title: "Info Motion Toast",
            titleStyle: TextStyle(fontWeight: FontWeight.bold),
            position: MOTION_TOAST_POSITION.CENTER,
            description: "Example of Info Toast")
        .show(context);
  }

  _displayDeleteMotionToast(BuildContext context) {
    MotionToast.delete(
      title: "Deleted",
      titleStyle: TextStyle(fontWeight: FontWeight.bold),
      description: "The item is deleted",
      animationType: ANIMATION.FROM_TOP,
      position: MOTION_TOAST_POSITION.TOP,
    ).show(context);
  }

  _displayCustomMotionToast(BuildContext context) {
    MotionToast(
      icon: Icons.alarm,
      color: Colors.pink,
      title: "Custom Toast",
      titleStyle: TextStyle(fontWeight: FontWeight.bold),
      description: "You can customize the toast!",
      animationType: ANIMATION.FROM_RIGHT,
      position: MOTION_TOAST_POSITION.TOP,
      width: 300,
    ).show(context);
  }

  _displayCenterMotionToast(BuildContext context) {
    MotionToast(
      icon: Icons.alarm,
      color: Colors.deepOrange,
      title: "Center Toast",
      titleStyle: TextStyle(fontWeight: FontWeight.bold),
      description: "Center displayed motion toast",
      width: 350,
      position: MOTION_TOAST_POSITION.CENTER,
    ).show(context);
  }

  _displayTopMotionToast(BuildContext context) {
    MotionToast(
      icon: Icons.zoom_out,
      color: Colors.deepOrange,
      title: "Top Motion Toast",
      titleStyle: TextStyle(fontWeight: FontWeight.bold),
      description: "Another motion toast example",
      width: 400,
      position: MOTION_TOAST_POSITION.TOP,
      animationType: ANIMATION.FROM_TOP,
    ).show(context);
  }
}
435
likes
0
pub points
96%
popularity

Publisher

verified publisherbadrkouki.dev

A beautiful designed toast with animations, contains multiple built in designs and let you design your toast

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on motion_toast