bubble 1.1.7 copy "bubble: ^1.1.7" to clipboard
bubble: ^1.1.7 copied to clipboard

outdated

A Flutter widget for chat like a speech bubble in Whatsapp and others.

example/lib/main.dart

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

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

class MyApp extends StatelessWidget {
  static const TITLE = 'Bubble Demo';
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: TITLE,
      theme: ThemeData(
        primarySwatch: Colors.teal,
      ),
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key}) : super(key: key);

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

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    double pixelRatio = MediaQuery.of(context).devicePixelRatio;
    double px = 1 / pixelRatio;

    BubbleStyle styleSomebody = BubbleStyle(
      nip: BubbleNip.TOP_LEFT,
      color: Colors.white,
      elevation: 1 * px,
      margin: BubbleEdges.only(top: 8, right: 50),
      alignment: Alignment.topLeft,
    );
    BubbleStyle styleMe = BubbleStyle(
      nip: BubbleNip.TOP_RIGHT,
      color: Color.fromARGB(255, 225, 255, 199),
      elevation: 1 * px,
      margin: BubbleEdges.only(top: 8, left: 50),
      alignment: Alignment.topRight,
    );

    return Scaffold(
      appBar: AppBar(
        title: Text('${MyApp.TITLE} (pixel ratio: $pixelRatio)'),
      ),
      body: Container(
        color: Colors.yellow.withAlpha(64),
        child: ListView(
          padding: EdgeInsets.all(8),
          children: [
            Divider(height: 40, color: Colors.black),
            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!'),
            ),
            Divider(height: 40, color: Colors.black),
          ],
        ),

//        child: ListView(
//          padding: EdgeInsets.all(8),
//          children: [
//            Bubble(
//              color: Color.fromARGB(255, 212, 234, 244),
//              elevation: 1 * px,
//              margin: BubbleEdges.only(top: 8),
//              child: Text('TODAY', style: TextStyle(fontSize: 10)),
//            ),
//            Bubble(
//              style: styleSomebody,
//              child: Text('Hi Jason. Sorry to bother you. I have a queston for you.'),
//            ),
//            Bubble(
//              style: styleMe,
//              child: Text('Whats\'up?'),
//            ),
//            Bubble(
//              style: styleSomebody,
//              child: Text('I\'ve been having a problem with my computer.'),
//            ),
//            Bubble(
//              style: styleSomebody,
//              margin: BubbleEdges.only(top: 2),
//              showNip: false,
//              child: Text('Can you help me?'),
//            ),
//            Bubble(
//              style: styleMe,
//              child: Text('Ok'),
//            ),
//            Bubble(
//              style: styleMe,
//              showNip: false,
//              margin: BubbleEdges.only(top: 2),
//              child: Text('What\'s the problem?'),
//            ),
//          ],
//        ),
      ),
    );
  }
}
571
likes
0
pub points
98%
popularity

Publisher

verified publisheryet-another.dev

A Flutter widget for chat like a speech bubble in Whatsapp and others.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on bubble