Skip to main content

toastio 1.1.0 copy "toastio: ^1.1.0" to clipboard
toastio: ^1.1.0 copied to clipboard

A lightweight, animated Glassmorphism toast for Flutter with global and context-based APIs.

example/lib/main.dart

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

final navigatorKey = GlobalKey<NavigatorState>();

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  Toastio.initialize(navigatorKey);
  runApp(const ExampleApp());
}

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      navigatorKey: navigatorKey,
      debugShowCheckedModeBanner: false,
      theme: ThemeData.dark(),
      home: const ExamplePage(),
    );
  }
}

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('App Toast')),
      body: Center(
        child: Wrap(
          spacing: 12,
          runSpacing: 12,
          alignment: WrapAlignment.center,
          children: [
            ElevatedButton(
              onPressed: () => Toastio.success('Profile updated'),
              child: const Text('Success'),
            ),
            ElevatedButton(
              onPressed: () => Toastio.error(
                'Please try again later',
                title: 'Something went wrong',
              ),
              child: const Text('Error'),
            ),
            ElevatedButton(
              onPressed: () => Toastio.warning('Check your input'),
              child: const Text('Warning'),
            ),
            ElevatedButton(
              onPressed: () => Toastio.info(
                'You have a new notification',
                title: 'New notification',
              ),
              child: const Text('Info'),
            ),
            ElevatedButton(
              onPressed: () => Toastio.showGlobal(
                'Top positioned toast',
                type: ToastType.info,
                position: ToastPosition.top,
              ),
              child: const Text('Top'),
            ),
            ElevatedButton(
              onPressed: () => Toastio.showGlobal(
                'Image toast with icon',
                icon: const Icon(Icons.notifications_active_outlined),
                appIcon: const AssetImage('assets/success.png'),
                bgColor: const Color(0xFF16352B),
                accentColor: Colors.tealAccent,
                iconColor: Colors.tealAccent,
                type: ToastType.info,
                position: ToastPosition.top,
              ),
              child: const Text('Image'),
            ),
          ],
        ),
      ),
    );
  }
}
1
likes
160
points
296
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A lightweight, animated Glassmorphism toast for Flutter with global and context-based APIs.

Repository (GitHub)
View/report issues

Topics

#toast #flutter #notification #snackbar #glassmorphism

License

MIT (license)

Dependencies

flutter

More

Packages that depend on toastio