kumi_popup_window 1.0.9

  • Readme
  • Changelog
  • Example
  • Installing
  • 87

✨ kumi_popup_window #

pub package

[Language] English | 中文文档

A simple and easy-to-use pop-up window. There are no flashy preset templates. Everything you want to pop up is customized by you.

1.Install

dependencies:
  kumi_popup_window: ^1.0.9

2.Import

import 'package:kumi_popup_window/kumi_popup_window.dart';

3.Use

//both sowPopupWindow and createPopupWindow
showPopupWindow(
  context,
  gravity: KumiPopupGravity.rightBottom,
  bgColor: Colors.grey.withOpacity(0.5),
  clickOutDismiss: true,
  clickBackDismiss: true,
  customAnimation: false,
  customPop: false,
  customPage: false,
  //targetRenderBox: (btnKey.currentContext.findRenderObject() as RenderBox),
  //childSize: null,
  underStatusBar: false,
  underAppBar: true,
  offsetX: 0,
  offsetY: 0,
  duration: Duration(milliseconds: 200),
  onShowStart: (pop) {
    print("showStart");
  },
  onShowFinish: (pop) {
    print("showFinish");
  },
  onDismissStart: (pop) {
    print("dismissStart");
  },
  onDismissFinish: (pop) {
    print("dismissFinish");
  },
  onClickOut: (pop){
    print("onClickOut");
  },
  onClickBack: (pop){
    print("onClickBack");
  },
  childFun: (pop) {
    return Container(
      key: GlobalKey(),
      padding: EdgeInsets.all(10),
      height: 100,
      width: 100,
      color: Colors.redAccent,
    );
  },
);

note Please use ValueNotifier for data update, don't use setState, usage can be Baidu, Google, or see [example] (example/lib/main.dart)

Brief description, see here for details

paramsdescriptiondefault
childFunMethod for customizing the content of the popup window. The returned widget will be used as the content of the popup windownull,(require)
gravityRelative position of the pop-up window.KumiPopupGravity.center
customAnimationCustom popupWindow animationfalse
customPopCustomize the position and animation of popupWindowfalse
customPageCustomize the entire page, including Scaffoldfalse
bgColorThe color of the mask layerColors.black.withOpacity(0.5)
targetRenderBoxRenderBox of the target widgetnull
underStatusBarWhen the top pops up, is it below the statusBarfalse
underAppBarWhen the top pops up, is it below the AppBarfalse
clickOutDismissClick outside the pop-up window to dismisstrue
clickBackDismissClick the physical back button to dismisstrue
offsetXOffset at horizontal axis edge0.0
offsetYOffset at vertical axis edge0.0
durationDuration of the animationDuration(milliseconds: 200)
isShowWhether the current popup frame is displayedfalse
onShowStartWhen the popupWindow show animation startnull
onShowEndWhen the popupWindow show animation finishnull
onDismissStartWhen the popupWindow dismiss animation startnull
onDismissEndWhen the popupWindow dismiss animation finishnull
onClickOutClick on the listener outside the popupnull
onClickBackListening on clicking the physical back buttonnull
property/methoddescription
childPopup window widget,Get its size and position by GlobalKey
controllerAnimation Controller
show()popup window show
dismiss()popup window dismiss

About #

  • QQ:876625596
  • Email:876625596@qq.com
  • Github:https://github.com/q876625596

License #

MIT License

Copyright (c) 2020 q876625596

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.

[1.0.9] #

  • 调用dismiss()之前判断isShow
  • Determine isShow before calling dismiss ()

[1.0.8] #

  • 删除SafeArea
  • Delete SafeArea

[1.0.7] #

  • 新增isShow属性
  • Added isShow property

[1.0.6] #

  • dismiss()方法添加禁止动画的参数
  • dismiss () method adds a parameter that prohibits animation

[1.0.5] #

  • 修改默认遮罩层颜色
  • Modify the default mask layer color

[1.0.4] #

  • 为dismiss()法新增可选参数
  • Added optional parameters for dismiss()

[1.0.3] #

  • fix bug

[1.0.2] #

  • 新增onClickOut()和onClickBack()
  • Added onClickOut () and onClickBack ()

[1.0.1] #

*修改部分方法

  • Modification method.

[1.0.0] #

  • first version.

example/lib/main.dart

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

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        // This is the theme of your application.
        //
        // Try running your application with "flutter run". You'll see the
        // application has a blue toolbar. Then, without quitting the app, try
        // changing the primarySwatch below to Colors.green and then invoke
        // "hot reload" (press "r" in the console where you ran "flutter run",
        // or simply save your changes to "hot reload" in a Flutter IDE).
        // Notice that the counter didn't reset back to zero; the application
        // is not restarted.
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  // This widget is the home page of your application. It is stateful, meaning
  // that it has a State object (defined below) that contains fields that affect
  // how it looks.

  // This class is the configuration for the state. It holds the values (in this
  // case the title) provided by the parent (in this case the App widget) and
  // used by the build method of the State. Fields in a Widget subclass are
  // always marked "final".

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  GlobalKey btnKey = GlobalKey();
  KumiPopupWindow popupWindow;

  ValueNotifier<bool> isSelect = ValueNotifier(false);

  @override
  Widget build(BuildContext context) {
    // This method is rerun every time setState is called, for instance as done
    // by the _incrementCounter method above.
    //
    // The Flutter framework has been optimized to make rerunning build methods
    // fast, so that you can just rebuild anything that needs updating rather
    // than having to individually change instances of widgets.
    return Scaffold(
      appBar: AppBar(
        // Here we take the value from the MyHomePage object that was created by
        // the App.build method, and use it to set our appbar title.
        title: Text(widget.title),
      ),
      body: Center(
        // Center is a layout widget. It takes a single child and positions it
        // in the middle of the parent.
        child: MaterialButton(
            key: btnKey,
            child: Text("popup"),
            color: Colors.redAccent,
            onPressed: () {
              /* if (popupWindow == null) {
                popupWindow = createPopupWindow(
                  context,
                  gravity: KumiPopupGravity.rightBottom,
                  bgColor: Colors.grey.withOpacity(0.5),
                  clickOutDismiss: true,
                  clickBackDismiss: true,
                  customAnimation: false,
                  customPop: false,
                  customPage: false,
                  //targetRenderBox: (btnKey.currentContext.findRenderObject() as RenderBox),
                  underStatusBar: false,
                  underAppBar: true,
                  offsetX: 0,
                  offsetY: 0,
                  duration: Duration(milliseconds: 200),
                  onShowStart: (pop) {
                    print("showStart");
                  },
                  onShowFinish: (pop) {
                    print("showFinish");
                  },
                  onDismissStart: (pop) {
                    print("dismissStart");
                  },
                  onDismissFinish: (pop) {
                    print("dismissFinish");
                  },
                  onClickOut: (pop){
                    print("onClickOut");
                  },
                  onClickBack: (pop){
                    print("onClickBack");
                  },
                  childFun: (controller) {
                    return Container(
                      key: GlobalKey(),
                      padding: EdgeInsets.all(10),
                      height: 100,
                      width: 100,
                      color: Colors.redAccent,
                    );
                  },
                );
              }
              popupWindow.show(context);*/
              showPopupWindow(
                context,
                gravity: KumiPopupGravity.rightBottom,
                bgColor: Colors.grey.withOpacity(0.5),
                clickOutDismiss: true,
                clickBackDismiss: true,
                customAnimation: false,
                customPop: false,
                customPage: false,
                //targetRenderBox: (btnKey.currentContext.findRenderObject() as RenderBox),
                underStatusBar: false,
                underAppBar: true,
                offsetX: 0,
                offsetY: 0,
                duration: Duration(milliseconds: 200),
                onShowStart: (pop) {
                  print("showStart");
                },
                onShowFinish: (pop) {
                  print("showFinish");
                },
                onDismissStart: (pop) {
                  print("dismissStart");
                },
                onDismissFinish: (pop) {
                  print("dismissFinish");
                },
                onClickOut: (pop) {
                  print("onClickOut");
                },
                onClickBack: (pop) {
                  print("onClickBack");
                },
                childFun: (pop) {
                  return GestureDetector(
                    key: GlobalKey(),
                    onTap: () {
                      isSelect.value = !isSelect.value;
                    },
                    child: Container(
                      padding: EdgeInsets.all(10),
                      height: 100,
                      width: 100,
                      color: Colors.redAccent,
                      alignment: Alignment.center,
                      child: ValueListenableBuilder(
                          valueListenable: isSelect,
                          builder: (context, bool select, child) {
                            return Text(isSelect.value.toString());
                          }),
                    ),
                  );
                },
              );
            }),
      ), // This trailing comma makes auto-formatting nicer for build methods.
    );
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  kumi_popup_window: ^1.0.9

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:kumi_popup_window/kumi_popup_window.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
73
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
87
Learn more about scoring.

We analyzed this package on May 26, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.1
  • pana: 0.13.8-dev
  • Flutter: 1.17.0

Health suggestions

Format lib/PopRoute.dart.

Run flutter format to format lib/PopRoute.dart.

Format lib/kumi_popup_window.dart.

Run flutter format to format lib/kumi_popup_window.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test