nice_overlay 1.0.1 copy "nice_overlay: ^1.0.1" to clipboard
nice_overlay: ^1.0.1 copied to clipboard

A package for controlling overlay components such as in-app notification, toast, and snack bar.

example/lib/main.dart

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

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

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

  @override
  Widget build(BuildContext context) {
    GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();
    NiceOverlay.init(navigatorKey);
    return MaterialApp(
      navigatorKey: navigatorKey,
      title: 'NiceOverlay Example',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const HomePage(),
    );
  }
}

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

  @override
  Widget build(BuildContext context) {
    return SafeArea(
      child: Scaffold(
        appBar: AppBar(),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.spaceAround,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              ElevatedButton(
                child: const Text('Show NiceInAppNotification'),
                onPressed: () => NiceOverlay.showInAppNotification(
                  NiceInAppNotification(
                    title: const Text('In app notification'),
                    body: const Text('What a nice in app notification!'),
                    onTap: () => debugPrint('Tap'),
                  ),
                ),
              ),
              ElevatedButton(
                child: const Text('Show NiceSnackBar'),
                onPressed: () => NiceOverlay.showSnackBar(
                  NiceSnackBar(
                    message: const Text('What a nice snack bar!'),
                    action: GestureDetector(
                      onTap: NiceOverlay.closeSnackBar,
                      child: const Text('close'),
                    ),
                  ),
                ),
              ),
              ElevatedButton(
                child: const Text('Show NiceToast'),
                onPressed: () => NiceOverlay.showToast(
                  NiceToast(
                    message: const Text('What a nice toast!'),
                    onTap: () => debugPrint('Tap'),
                  ),
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
5
likes
150
pub points
42%
popularity

Publisher

verified publisherterry1213.com

A package for controlling overlay components such as in-app notification, toast, and snack bar.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on nice_overlay