Git Product home page Git Product logo

onur0481 / i_toast Goto Github PK

View Code? Open in Web Editor NEW

This project forked from iwalletmobile/i_toast

0.0 0.0 0.0 7 MB

A Flutter package for displaying customizable toast notifications. Provides easy-to-use and non-intrusive toast messages with options for customization including duration, position, and appearance.

License: MIT License

C++ 31.52% C 1.89% Objective-C 0.05% Kotlin 0.16% Dart 35.88% Swift 2.29% HTML 2.44% CMake 25.76%

i_toast's Introduction

i_toast

i_toast is a Flutter package used to display toast messages in applications. This package is utilized to provide users with temporary notifications, typically used to convey successful operations, errors, warnings, or informative messages.

Example Project

Table of contents

Features

  • Title and description content: iToast allows including both title and description content in the toast messages.
  • Complementary content with an icon or custom widget: Users can add icons or custom widgets to enhance the toast messages.
  • Display duration as desired: iToast provides options to specify the duration for which the toast message is displayed.
  • Customizable background color, border color, and border radius: Users can customize the background color, border color, and border radius of the toast messages according to their preferences.
  • Custom sizing options: iToast offers customization options for the width and height of the toast messages.

itoast Message Types

iToast offers five different types of toast messages:

  • InfoToastMessage: Used for informative messages.
  • SuccessToastMessage: Indicates successful operations.
  • WarningToastMessage: Alerts the user to potential issues.
  • ErrorToastMessage: Reports error situations.
  • CustomToastMessage: Utilized to create customized toast messages. Users can specify properties such as background color, border color, border radius, width, and height.

Installation

dependencies:
  itoast: <latest version>

Import

import 'package:itoast/itoast.dart';

Usage

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

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

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const IToast(),
    );
  }
}

class IToast extends StatelessWidget {
  const IToast({super.key});

  @override
  Widget build(BuildContext context) {
    final List<ToastType> toastType = [ToastType.error, ToastType.info, ToastType.success, ToastType.warning];
    return Scaffold(
      appBar: AppBar(
        title: const Text("iToast Example"),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            ListView.builder(
              shrinkWrap: true,
              itemCount: toastType.length,
              padding: const EdgeInsets.symmetric(horizontal: 120),
              itemBuilder: (context, index) => ElevatedButton(
                onPressed: () {
                  _showToastMessage(
                    context,
                    toastType[index].name.substring(0, 1).toUpperCase() + toastType[index].name.substring(1),
                    "${toastType[index].name} description.",
                    toastType[index],
                    leading: const Icon(Icons.info),
                  );
                },
                child: const Text("Show iToast"),
              ),
            ),
            ElevatedButton(
              onPressed: () {
                _showToastMessage(
                  context,
                  'Custom iToast',
                  "Custom iToast description.",
                  ToastType.custom,
                  backgroundColor: Colors.blueGrey.shade50,
                  borderColor: Colors.blueGrey,
                  leading: const Icon(Icons.explore, color: Colors.teal),
                  borderRadius: BorderRadius.circular(24),
                );
              },
              child: const Text('Show Custom iToast'),
            ),
          ],
        ),
      ),
    );
  }
}

void _showToastMessage(
  BuildContext context,
  String title,
  String description,
  ToastType toastType, {
  Color? backgroundColor,
  Color? borderColor,
  Widget? leading,
  BorderRadius? borderRadius,
}) {
  iToast(
    context,
    title: Text(title),
    description: Text(description),
    trailing: const Icon(Icons.close_rounded),
    toastType: toastType,
    leading: leading,
    duration: Durations.extralong4,
    toastBackgroundColor: backgroundColor,
    toastBorderColor: borderColor,
    toastBorderRadius: borderRadius,
  );
}

License

MIT License

Copyright (c) 2024 iWallet Türkiye

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

i_toast's People

Contributors

codermuss avatar iwalletmobile avatar bedirhanssaglam avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.