overlay_support 0.0.1 copy "overlay_support: ^0.0.1" to clipboard
overlay_support: ^0.0.1 copied to clipboard

outdated

proivder support for overlay, easy to build toast and internal notification

example/lib/main.dart

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

void main() {
  kNotificationSlideDuration = const Duration(milliseconds: 500);
  kNotificationDuration = const Duration(milliseconds: 1500);
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Overlay Support Example',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: HomePage(),
    );
  }
}

class HomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text("overlay support example")),
      body: ListView(
        children: <Widget>[
          _Section(
            title: 'Notification',
            children: <Widget>[
              RaisedButton(
                onPressed: () {
                  showSimpleNotification(context,
                      Text("this is a message from simple notification"),
                      background: Colors.green);
                },
                child: Text("simple Auto Dismiss"),
              ),
              RaisedButton(
                onPressed: () {
                  NotificationEntry entry;
                  entry = showSimpleNotification(
                    context,
                    Text("you got a simple message"),
                    trailing: FlatButton(
                        textColor: Colors.yellow,
                        onPressed: () {
                          entry.dismiss();
                        },
                        child: Text('Dismiss')),
                    background: Colors.green,
                    autoDismiss: false,
                  );
                },
                child: Text("simple fixed"),
              ),
            ],
          ),
          _Section(title: 'toast', children: [
            RaisedButton(
              onPressed: () {
                toast(context, 'this is a message from toast');
              },
              child: Text('toast'),
            )
          ]),
        ],
      ),
    );
  }
}

class _Section extends StatelessWidget {
  final String title;

  final List<Widget> children;

  const _Section({Key key, @required this.title, @required this.children})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Padding(
      padding: const EdgeInsets.symmetric(horizontal: 8),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: <Widget>[
          SizedBox(height: 16),
          _Title(title: title),
          Wrap(spacing: 8, children: children),
        ],
      ),
    );
  }
}

class _Title extends StatelessWidget {
  final String title;

  const _Title({Key key, @required this.title}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      margin: const EdgeInsets.only(left: 16, top: 10, bottom: 8),
      child: Text(
        title,
        style: TextStyle(fontWeight: FontWeight.bold, fontSize: 17),
      ),
    );
  }
}
673
likes
0
pub points
99%
popularity

Publisher

verified publishersoit.tech

proivder support for overlay, easy to build toast and internal notification

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on overlay_support