Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

speech bubble

a flutter widget for chat like a speech bubble in whatsapp and others.

speech bubble

example

see sources.

usage

bubble(
  child: text('hello, world!'),
),

bubble

– nip

bubble(
  nip: bubblenip.top_right,
  child: text('hello, world!'),
),
bubble(
  margin: bubbleedges.only(top: 10),
  nip: bubblenip.top_left,
  child: text('hello, programmer!'),
),

bubble

– alignment

bubble(
  alignment: alignment.topright,
  nip: bubblenip.top_right,
  child: text('hello, world!'),
),
bubble(
  margin: bubbleedges.only(top: 10),
  alignment: alignment.topleft,
  nip: bubblenip.top_left,
  child: text('hello, programmer!'),
),

bubble

– color

bubble(
  alignment: alignment.topright,
  nip: bubblenip.top_right,
  color: color.fromargb(255, 225, 255, 199),
  child: text('hello, world!'),
),
bubble(
  margin: bubbleedges.only(top: 10),
  alignment: alignment.topleft,
  nip: bubblenip.top_left,
  child: text('hello, programmer!'),
),

bubble

– radius

bubble(
  alignment: alignment.topright,
  nip: bubblenip.top_right,
  radius: 0,
  color: color.fromargb(255, 225, 255, 199),
  child: text('hello, world!'),
),
bubble(
  margin: bubbleedges.only(top: 10),
  alignment: alignment.topright,
  nip: bubblenip.top_right,
  radius: 10,
  color: color.fromargb(255, 225, 255, 199),
  child: text('hello, world!'),
),
bubble(
  margin: bubbleedges.only(top: 10),
  alignment: alignment.topleft,
  nip: bubblenip.top_left,
  radius: 0,
  child: text('hello, programmer!'),
),
bubble(
  margin: bubbleedges.only(top: 10),
  alignment: alignment.topleft,
  nip: bubblenip.top_left,
  radius: 10,
  child: text('hello, programmer!'),
),

bubble

– nipwidth and nipheight

bubble(
  alignment: alignment.topright,
  nip: bubblenip.top_right,
  nipwidth: 8,
  nipheight: 20,
  color: color.fromargb(255, 225, 255, 199),
  child: text('hello, world!'),
),
bubble(
  margin: bubbleedges.only(top: 10),
  alignment: alignment.topleft,
  nip: bubblenip.top_left,
  nipwidth: 8,
  nipheight: 20,
  child: text('hello, programmer!'),
),

bubble

bubble(
  alignment: alignment.topright,
  nip: bubblenip.top_right,
  nipwidth: 30,
  nipheight: 12,
  color: color.fromargb(255, 225, 255, 199),
  child: text('hello, world!'),
),
bubble(
  margin: bubbleedges.only(top: 10),
  alignment: alignment.topleft,
  nip: bubblenip.top_left,
  nipwidth: 30,
  nipheight: 12,
  child: text('hello, programmer!'),
),

bubble

– nipradius

for (var i = 0; i <= 6; i++)
  bubble(
    margin: bubbleedges.only(top: 4),
    alignment: alignment.topright,
    nip: bubblenip.top_right,
    nipwidth: 30,
    nipheight: 12,
    nipradius: i.todouble(),
    color: color.fromargb(255, 225, 255, 199),
    child: text('hello, world!'),
  ),
for (var i = 0; i <= 6; i++)
  bubble(
    margin: bubbleedges.only(top: 4),
    alignment: alignment.topleft,
    nip: bubblenip.top_left,
    nipwidth: 30,
    nipheight: 12,
    nipradius: i.todouble(),
    child: text('hello, programmer!'),
  ),

bubble

scheme:

bubble

– nipoffset

for (var i = 0; i <= 6; i++)
  bubble(
    margin: bubbleedges.only(top: 4),
    alignment: alignment.topright,
    nip: bubblenip.top_right,
    nipwidth: 30,
    nipheight: 12,
    nipradius: i.todouble(),
    nipoffset: 8,
    color: color.fromargb(255, 225, 255, 199),
    child: text('hello, world!'),
  ),
for (var i = 0; i <= 6; i++)
  bubble(
    margin: bubbleedges.only(top: 4),
    alignment: alignment.topleft,
    nip: bubblenip.top_left,
    nipwidth: 30,
    nipheight: 12,
    nipradius: i.todouble(),
    nipoffset: 8,
    child: text('hello, programmer!'),
  ),

bubble

for (var i = 0; i <= 12; i += 3)
  bubble(
    margin: bubbleedges.only(top: 4),
    alignment: alignment.topright,
    nip: bubblenip.top_right,
    nipoffset: i.todouble(),
    color: color.fromargb(255, 225, 255, 199),
    child: text('hello, world!'),
  ),
for (var i = 0; i <= 12; i += 3)
  bubble(
    margin: bubbleedges.only(top: 4),
    alignment: alignment.topleft,
    nip: bubblenip.top_left,
    nipoffset: i.todouble(),
    child: text('hello, programmer!'),
  ),

bubble

– shownip

add second bubble to everyone.

bubble(
  alignment: alignment.topright,
  nip: bubblenip.top_right,
  color: color.fromargb(255, 225, 255, 199),
  child: text('hello, world!'),
),
bubble(
  margin: bubbleedges.only(top: 2),
  alignment: alignment.topright,
  nip: bubblenip.top_right,
  color: color.fromargb(255, 225, 255, 199),
  child: text('how are you?'),
),
bubble(
  margin: bubbleedges.only(top: 10),
  alignment: alignment.topleft,
  nip: bubblenip.top_left,
  child: text('hello, programmer!'),
),
bubble(
  margin: bubbleedges.only(top: 2),
  alignment: alignment.topleft,
  nip: bubblenip.top_left,
  child: text('and how are you?'),
),

bubble

second, third et al bubbles in whatsapp haven’t nips. remove them.

bubble(
  alignment: alignment.topright,
  nip: bubblenip.top_right,
  color: color.fromargb(255, 225, 255, 199),
  child: text('hello, world!'),
),
bubble(
  margin: bubbleedges.only(top: 2),
  alignment: alignment.topright,
  //nip: bubblenip.top_right,
  color: color.fromargb(255, 225, 255, 199),
  child: text('how are you?'),
),
bubble(
  margin: bubbleedges.only(top: 10),
  alignment: alignment.topleft,
  nip: bubblenip.top_left,
  child: text('hello, programmer!'),
),
bubble(
  margin: bubbleedges.only(top: 2),
  alignment: alignment.topleft,
  //nip: bubblenip.top_left,
  child: text('and how are you?'),
),

bubble

it’s not that. hide nips!

bubble(
  alignment: alignment.topright,
  nip: bubblenip.top_right,
  color: color.fromargb(255, 225, 255, 199),
  child: text('hello, world!'),
),
bubble(
  margin: bubbleedges.only(top: 2),
  alignment: alignment.topright,
  nip: bubblenip.top_right,
  shownip: false,
  color: color.fromargb(255, 225, 255, 199),
  child: text('how are you?'),
),
bubble(
  margin: bubbleedges.only(top: 10),
  alignment: alignment.topleft,
  nip: bubblenip.top_left,
  child: text('hello, programmer!'),
),
bubble(
  margin: bubbleedges.only(top: 2),
  alignment: alignment.topleft,
  nip: bubblenip.top_left,
  shownip: false,
  child: text('and how are you?'),
),

bubble

it’s ok 🙂

– elevation

a thick shadow.

for (var i = 1; i <= 8; i *= 2)
  column(
    children: <widget>[
      bubble(
        margin: bubbleedges.only(top: 10),
        alignment: alignment.topright,
        nip: bubblenip.top_right,
        color: color.fromargb(255, 225, 255, 199),
        elevation: i.todouble(),
        child: text('hello, world!'),
      ),
      bubble(
        margin: bubbleedges.only(top: 10),
        alignment: alignment.topleft,
        nip: bubblenip.top_left,
        elevation: i.todouble(),
        child: text('hello, programmer!'),
      ),
    ],
  ),

bubble

a thin shadow.

double px = 1 / mediaquery.of(context).devicepixelratio;

...
bubble(
  alignment: alignment.topright,
  nip: bubblenip.top_right,
  color: color.fromargb(255, 225, 255, 199),
  elevation: 0,
  child: text('hello, world!'),
),
bubble(
  margin: bubbleedges.only(top: 10),
  alignment: alignment.topright,
  nip: bubblenip.top_right,
  color: color.fromargb(255, 225, 255, 199),
  elevation: 0.5 * px,
  child: text('hello, world!'),
),
bubble(
  margin: bubbleedges.only(top: 10),
  alignment: alignment.topright,
  nip: bubblenip.top_right,
  color: color.fromargb(255, 225, 255, 199),
  elevation: 1 * px,
  child: text('hello, world!'),
),
bubble(
  margin: bubbleedges.only(top: 10),
  alignment: alignment.topright,
  nip: bubblenip.top_right,
  color: color.fromargb(255, 225, 255, 199),
  elevation: 1,
  child: text('hello, world!'),
),
bubble(
  margin: bubbleedges.only(top: 10),
  alignment: alignment.topleft,
  nip: bubblenip.top_left,
  elevation: 0,
  child: text('hello, programmer!'),
),
bubble(
  margin: bubbleedges.only(top: 10),
  alignment: alignment.topleft,
  nip: bubblenip.top_left,
  elevation: 0.5 * px,
  child: text('hello, programmer!'),
),
bubble(
  margin: bubbleedges.only(top: 10),
  alignment: alignment.topleft,
  nip: bubblenip.top_left,
  elevation: 1 * px,
  child: text('hello, programmer!'),
),
bubble(
  margin: bubbleedges.only(top: 10),
  alignment: alignment.topleft,
  nip: bubblenip.top_left,
  elevation: 1,
  child: text('hello, programmer!'),
),

bubble

– shadowcolor

bubble(
  alignment: alignment.topright,
  nip: bubblenip.top_right,
  color: color.fromargb(255, 225, 255, 199),
  elevation: 2,
  shadowcolor: colors.red,
  child: text('hello, world!'),
),
bubble(
  margin: bubbleedges.only(top: 10),
  alignment: alignment.topright,
  nip: bubblenip.top_right,
  color: color.fromargb(255, 225, 255, 199),
  elevation: 2,
  shadowcolor: colors.green,
  child: text('hello, world!'),
),
bubble(
  margin: bubbleedges.only(top: 10),
  alignment: alignment.topright,
  nip: bubblenip.top_right,
  color: color.fromargb(255, 225, 255, 199),
  elevation: 2,
  shadowcolor: colors.blue,
  child: text('hello, world!'),
),
bubble(
  margin: bubbleedges.only(top: 10),
  alignment: alignment.topleft,
  nip: bubblenip.top_left,
  elevation: 2,
  shadowcolor: colors.red,
  child: text('hello, programmer!'),
),
bubble(
  margin: bubbleedges.only(top: 10),
  alignment: alignment.topleft,
  nip: bubblenip.top_left,
  elevation: 2,
  shadowcolor: colors.green,
  child: text('hello, programmer!'),
),
bubble(
  margin: bubbleedges.only(top: 10),
  alignment: alignment.topleft,
  nip: bubblenip.top_left,
  elevation: 2,
  shadowcolor: colors.blue,
  child: text('hello, programmer!'),
),

bubble

– margin

bubble(
  alignment: alignment.topright,
  nip: bubblenip.top_right,
  color: color.fromargb(255, 225, 255, 199),
  child: text('hello, world! hello, world! hello, world! hello, world! hello, world! hello, world!'
    'hello, world! hello, world! hello, world! hello, world! hello, world! hello, world!'),
),
bubble(
  margin: bubbleedges.only(top: 10),
  alignment: alignment.topleft,
  nip: bubblenip.top_left,
  child: text('hello, programmer! hello, programmer! hello, programmer! hello, programmer! '
    'hello, programmer! hello, programmer! hello, programmer! hello, programmer!'),
),

bubble

bubble(
  margin: bubbleedges.only(left: 50),
  alignment: alignment.topright,
  nip: bubblenip.top_right,
  color: color.fromargb(255, 225, 255, 199),
  child: text('hello, world! hello, world! hello, world! hello, world! hello, world! hello, world!'
    'hello, world! hello, world! hello, world! hello, world! hello, world! hello, world!'),
),
bubble(
  margin: bubbleedges.only(top: 10, right: 50),
  alignment: alignment.topleft,
  nip: bubblenip.top_left,
  child: text('hello, programmer! hello, programmer! hello, programmer! hello, programmer! '
    'hello, programmer! hello, programmer! hello, programmer! hello, programmer!'),
),

bubble

– padding

bubble(
  alignment: alignment.topright,
  nip: bubblenip.top_right,
  color: color.fromargb(255, 225, 255, 199),
  padding: bubbleedges.all(2),
  child: text('hello, world!'),
),
bubble(
  margin: bubbleedges.only(top: 10),
  alignment: alignment.topleft,
  nip: bubblenip.top_left,
  padding: bubbleedges.all(2),
  child: text('hello, programmer!'),
),
bubble(
  margin: bubbleedges.only(top: 10),
  alignment: alignment.topright,
  nip: bubblenip.top_right,
  color: color.fromargb(255, 225, 255, 199),
  padding: bubbleedges.all(20),
  child: text('hello, world!'),
),
bubble(
  margin: bubbleedges.only(top: 10),
  alignment: alignment.topleft,
  nip: bubblenip.top_left,
  padding: bubbleedges.all(20),
  child: text('hello, programmer!'),
),

bubble


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

Comments are closed.