Skip to content

Latest commit

 

History

History
110 lines (92 loc) · 3.74 KB

README.md

File metadata and controls

110 lines (92 loc) · 3.74 KB

balloon_widget

pub package github

a simple balloon widget.

nip_position_grid.png position_balloon.png borderRadius_balloon_color_grid.png include_nip_height_grid.png inner_padding_grid.png shadow_grid.png custom_shadow_grid.png nip_target_position_grid.png

Usage

Use as a widget

Balloon(
  child: Text('Hello, Balloon!'),
);

Use as a widget which placed at the specific widget.

bool isVisible = true;

@override
Widget build(BuildContext context) {
  // if you want apply decoration on balloon widget, use `PositionedBalloon.decorateBuilder` widget.
  // or just need fade-in/out effect, use `PositionedBalloon.fade` constructor.
  return PositionedBalloon(
    show: isVisible,
    balloon: Balloon(
      nipPosition: BalloonNipPosition.topCenter,
      child: Text("now go shopping, you got a event coin!"),
    ),
    child: TextButton(
      onPressed: () {
        openUrl(this.goodsUrl);
        setState(() => isVisible = false);
      },
      text: Text("go shopping"),
    ),
  );
}

Use as a widget which placed at the specific widget with Focus. (easy way to handle dynamic-visibility without variable)

@override
Widget build(BuildContext context) {
  return PositionedBalloon.focusable( // or you can use `FocusablePositionedBalloon` widget.
    autofocus: true, // default is false
    balloon: Balloon(
      nipPosition: BalloonNipPosition.topCenter,
      child: Text("now go shopping, you got a event coin!"),
    ),
    childBuilder: (context, focusNode) =>
        TextButton(
          onPressed: () {
            openUrl(this.goodsUrl);
            if (focusNode.hasFocus) focusNode.unfocus();
          },
          text: Text("go shopping"),
        ),
  );
}

Use as a widget which placed at the specific widget and include button on the balloon widget.

bool isVisible = true;

@override
Widget build(BuildContext context) {
  return BalloonTapDelegator(
      child: Scaffold(
          body: ListView(
              children: [
                PositionedBalloon(
                    show: isVisible,
                    balloon: Balloon(
                        nipPosition: BalloonNipPosition.topCenter,
                        child: Row(children: [
                          Text("now go shopping, you got a event coin!"),
                          IconButton(
                              onPressed: () => setState(() => isVisible = false),
                              icon: Icon(Icons.close)),
                        ]),
                        child: TextButton(
                          onPressed: () {
                            openUrl(this.goodsUrl);
                            setState(() => isVisible = false);
                          },
                          text: Text("go shopping"),
                        ))),
              ])));
}