show_overlay 0.0.5 copy "show_overlay: ^0.0.5" to clipboard
show_overlay: ^0.0.5 copied to clipboard

outdated

Quickly and easily create an OverlayEntry with animate.

example/lib/main.dart

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

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'showOverlay example',
      home: Scaffold(body: Body()),
    );
  }
}

class Body extends StatelessWidget {
  showOverlayByDefault(BuildContext context) {
    showOverlay(
      context: context,
      barrierDismissible: false,
      builder: (_, __, close) {
        return RaisedButton(
          onPressed: close,
          child: Text('关闭'),
        );
      },
    );
  }

  showOverlayByWithBarrier(BuildContext context) {
    showOverlay(
      barrier: true,
      context: context,
      barrierBlur: true,
      barrierDismissible: true,
      barrierColor: Colors.black.withOpacity(0.2),
      builder: (_, __, close) {
        return RaisedButton(
          onPressed: close,
          child: Text('关闭'),
        );
      },
    );
  }

  showOverlayByWithAnimation(BuildContext context) {
    showOverlay(
      context: context,
      animationDuration: Duration(milliseconds: 300),
      barrierDismissible: false,
      builder: (_, animation, close) {
        return ScaleTransition (
          scale: animation,
          child: RaisedButton(
            onPressed: close,
            child: Text('关闭'),
          ),
        );
      },
    );
  }

  @override
  Widget build(BuildContext context) {
    return Center(
      child: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: <Widget>[
          RaisedButton(
            onPressed: () => showOverlayByDefault(context),
            child: Text('Default'),
          ),
          RaisedButton(
            onPressed: () => showOverlayByWithBarrier(context),
            child: Text('Default With Barrier'),
          ),
          RaisedButton(
            onPressed: () => showOverlayByWithAnimation(context),
            child: Text('Default With Animation'),
          )
        ],
      ),
    );
  }
}
6
likes
0
pub points
35%
popularity

Publisher

verified publisheryinxulai.com

Quickly and easily create an OverlayEntry with animate.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on show_overlay