chat_bubble 0.1.1+3

  • Readme
  • Changelog
  • Example
  • Installing
  • 70

chat_bubble #

A chat bubble widget, similar to WeChat, You can customize the orientation and the size of the rounded corners, as well as the rounded corners and position of the triangle..

类似微信一样的聊天气泡,可以用作文字、图片等等

Usage #

import 'package:chat_bubble/chat_bubble.dart';


ChatBubble(
  shadows: <Shadow>[
    Shadow(
      color: Colors.grey,
      offset: Offset(-1.0, -1.0),
      blurRadius: 0.1,
    ),
    Shadow(
      color: Colors.grey,
      offset: Offset(1.0, 1.0),
      blurRadius: 0.4,
    )
  ],
  direction: reverse ? ChatBubbleNipDirection.RIGHT:  ChatBubbleNipDirection.LEFT,
  child: Container(
    color: Colors.grey,
    child: img,
  ),
)

Screenshots #

截图

说明

[0.1.1+3] #

[0.1.1+2] #

[0.1.1+1] #

项目说明

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:chat_bubble/chat_bubble.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 StatelessWidget {
  final String title;
  MyHomePage({Key key, this.title}) : super(key: key);

  @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.
    bool reverse = true;
    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(title),
      ),
      body: Center(
        // Center is a layout widget. It takes a single child and positions it
        // in the middle of the parent.
        child: SingleChildScrollView(
          child: Padding(
            padding: const EdgeInsets.all(8.0),
            child: Column(
              // Column is also a layout widget. It takes a list of children and
              // arranges them vertically. By default, it sizes itself to fit its
              // children horizontally, and tries to be as tall as its parent.
              //
              // Invoke "debug painting" (press "p" in the console, choose the
              // "Toggle Debug Paint" action from the Flutter Inspector in Android
              // Studio, or the "Toggle Debug Paint" command in Visual Studio Code)
              // to see the wireframe for each widget.
              //
              // Column has various properties to control how it sizes itself and
              // how it positions its children. Here we use mainAxisAlignment to
              // center the children vertically; the main axis here is the vertical
              // axis because Columns are vertical (the cross axis would be
              // horizontal).
              mainAxisAlignment: MainAxisAlignment.center,
              children: <Widget>[
                ChatBubble(
                  direction: ChatBubbleNipDirection.LEFT,
                  child: Container(
                    height: 45,
                    color: Color(0xffdddddd),
                    child: Center(
                      child: Text('收到文本'),
                    ),
                  ),
                ),
                SizedBox(
                  height: 30,
                ),
                ChatBubble(
                  direction: ChatBubbleNipDirection.RIGHT,
                  child: Container(
                    width: 230,
                    height: 45,
                    color: Color(0xffa5ed7e),
                    child: Center(
                      child: Text('发送文本'),
                    ),
                  ),
                ),
                SizedBox(
                  height: 30,
                ),
                Align(
                  alignment: Alignment.bottomRight,
                  child: ChatBubble(
                    shadows: <Shadow>[
                      Shadow(
                        color: Colors.red,
                        offset: Offset(0, 0),
                        blurRadius: 5,
                      ),
                    ],
                    direction: ChatBubbleNipDirection.RIGHT,
                    child: Container(
                      width: 230,
                      height: 45,
                      color: Color(0xffa5ed7e),
                      child: Center(
                        child: Text('单个阴影'),
                      ),
                    ),
                  ),
                ),
                SizedBox(
                  height: 30,
                ),
                ChatBubble(
                  shadows: <Shadow>[
                    Shadow(
                      color: Colors.red,
                      offset: Offset(-5, -5),
                      blurRadius: 5,
                    ),
                    Shadow(
                      color: Colors.blue,
                      offset: Offset(5, 5),
                      blurRadius: 5,
                    )
                  ],
                  direction: ChatBubbleNipDirection.RIGHT,
                  child: Container(
                    width: 230,
                    height: 45,
                    color: Color(0xffa5ed7e),
                    child: Center(
                      child: Text('多个阴影'),
                    ),
                  ),
                ),
                SizedBox(
                  height: 30,
                ),
                ChatBubble(
                  shadows: <Shadow>[
                    Shadow(
                      color: Colors.red,
                      offset: Offset(0, 0),
                      blurRadius: 5,
                    )
                  ],
                  direction: reverse
                      ? ChatBubbleNipDirection.RIGHT
                      : ChatBubbleNipDirection.LEFT,
                  child: Container(
                    width: 300,
                    color: Colors.grey.withOpacity(0.8),
                    child: Image.network(
                      'https://pics7.baidu.com/feed/b21c8701a18b87d6627be358ca93ae3e1e30fdda.jpeg?token=a6434449ed9bc79aa3c414a52e4a4e1b',
                    ),
                  ),
                ),
                SizedBox(
                  height: 30,
                ),
                ChatBubble(
                  nipLength: 30.0,
                  nipRadius: 10.0,
                  nipTop: 80.0,
                  shadows: <Shadow>[
                    Shadow(
                      color: Colors.red,
                      offset: Offset(0, 0),
                      blurRadius: 5,
                    )
                  ],
                  direction: reverse
                      ? ChatBubbleNipDirection.RIGHT
                      : ChatBubbleNipDirection.LEFT,
                  child: Container(
                    width: 300,
                    color: Colors.grey.withOpacity(0.8),
                    child: Image.network(
                      'https://pics7.baidu.com/feed/b21c8701a18b87d6627be358ca93ae3e1e30fdda.jpeg?token=a6434449ed9bc79aa3c414a52e4a4e1b',
                    ),
                  ),
                ),
                SizedBox(
                  height: 30,
                ),
                ChatBubble(
                  shadows: <Shadow>[
                    Shadow(
                      color: Colors.grey.withOpacity(0.8),
                      offset: Offset(-1.0, -1.0),
                      blurRadius: 0.1,
                    ),
                    Shadow(
                      color: Colors.grey.withOpacity(0.8),
                      offset: Offset(1.0, 1.0),
                      blurRadius: 0.4,
                    )
                  ],
                  direction: ChatBubbleNipDirection.LEFT,
                  child: Container(
                    width: 200,
                    color: Colors.grey.withOpacity(0.8),
                    child: Image.network(
                      'https://pics7.baidu.com/feed/b21c8701a18b87d6627be358ca93ae3e1e30fdda.jpeg?token=a6434449ed9bc79aa3c414a52e4a4e1b',
                    ),
                  ),
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  chat_bubble: ^0.1.1+3

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:chat_bubble/chat_bubble.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
44
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
70
Learn more about scoring.

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

  • Dart: 2.8.4
  • pana: 0.13.13
  • Flutter: 1.17.5

Analysis suggestions

Package not compatible with SDK dart

because of import path [chat_bubble] that is in a package requiring null.

Maintenance issues and suggestions

Make sure dartdoc successfully runs on your package's source files. (-10 points)

exitCode: 255 stdout: Documenting chat_bubble... Initialized dartdoc with 512 libraries in 87.1 seconds Generating docs for library chat_bubble from package:chat_bubble/chat_bubble.dart... Generating docs for library chat_bubble from package:chat_bubble/bubble.dart... Generating docs for library clipShadowPath from package:chat_bubble/clipShadowPath.dart... Validating docs... Documented 3 public libraries in 15.4 seconds stderr: warning: chat_bubble has no library level documentation comments, from chat_bubble: (file:///tmp/pub-dartlang-dartdocZZDKEC/pkg/lib/chat_bubble.dart:1:9) warning: chat_bubble has no library level documentation comments, from chat_bubble: (file:///tmp/pub-dartlang-dartdocZZDKEC/pkg/lib/bubble.dart:1:9) error: failed to write file at: chat_bubble/chat_bubble-library.html for symbol chat_bubble: (file:///tmp/pub-dartlang-dartdocZZDKEC/pkg/lib/bubble.dart:1:9) conflicting with file already generated by chat_bubble: (file:///tmp/pub-dartlang-dartdocZZDKEC/pkg/lib/chat_bubble.dart:1:9) Dartdoc generates a path and filename to write to for each symbol. chat_bubble conflicts with another symbol in the generated path, and therefore can not be written out. Changing the name, library name, or class name (if appropriate) of one of the conflicting items can resolve the conflict. Alternatively, use the @nodoc tag in one symbol's documentation comments to hide it. warning: dartdoc generated a broken link to: chat_bubble/ChatBubble-class.html (from index.json) warning: dartdoc generated a broken link to: chat_bubble/ChatBubble/ChatBubble.html (from index.json) warning: dartdoc generated a broken link to: chat_bubble/ChatBubble/build.html (from index.json) warning: dartdoc generated a broken link to: chat_bubble/ChatBubble/child.html (from index.json) warning: dartdoc generated a broken link to: chat_bubble/ChatBubble/direction.html (from index.json) warning: dartdoc generated a broken link to: chat_bubble/ChatBubble/nipLength.html (from index.json) warning: dartdoc generated a broken link to: chat_bubble/ChatBubble/nipRadius.html (from index.json) warning: dartdoc generated a broken link to: chat_bubble/ChatBubble/nipTop.html (from index.json) warning: dartdoc generated a broken link to: chat_bubble/ChatBubble/radius.html (from index.json) warning: dartdoc generated a broken link to: chat_bubble/ChatBubble/shadows.html (from index.json) warning: dartdoc generated a broken link to: chat_bubble/ChatBubbleNipDirection-class.html (from index.json) warning: dartdoc generated a broken link to: chat_bubble/ChatBubbleNipDirection/toString.html (from index.json) found 14 warnings and 1 error Unhandled exception: dartdoc encountered 1 errors while processing. #0 Dartdoc.generateDocs (package:dartdoc/dartdoc.dart:225:9)

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 1.14.13
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8
Dev dependencies
flutter_test