Tutorial and code of Chat Bubble in Flutter. Copy and paste the below code as per your requirements.
chat_bubbles: ^0.7.1+6
import 'package:flutter/material.dart';
import 'package:chat_bubbles/chat_bubbles.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Chat Bubble',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const MyHomePage(title: 'Chat Bubble'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({Key? key, required this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Center(child: Text(widget.title),)
),
body: Center(
child: SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
BubbleNormal(
text: 'bubble normal with tail',
isSender: false,
color: const Color(0xAF52FF8C),
tail: true,
),
BubbleNormal(
text: 'bubble normal with tail',
isSender: true,
color: const Color(0xAF6AD0F5),
tail: true,
),
BubbleNormal(
text: 'bubble normal without tail',
isSender: false,
color: const Color(0xAF52FF8C),
tail: false,
),
BubbleNormal(
text: 'bubble normal without tail',
color: const Color(0xAF6AD0F5),
tail: false,
),
const BubbleSpecialOne(
text: 'bubble special one with tail',
isSender: false,
color: Color(0xAF52FF8C),
),
const BubbleSpecialOne(
text: 'bubble special one without tail',
color: Color(0xAF6AD0F5),
),
const BubbleSpecialOne(
text: 'bubble special one with tail',
isSender: false,
tail: false,
color: Color(0xAF52FF8C),
),
const BubbleSpecialOne(
text: 'bubble special one without tail',
tail: false,
color: Color(0xAF6AD0F5),
),
const BubbleSpecialTwo(
text: 'bubble special tow with tail',
isSender: false,
color: Color(0xAF52FF8C),
),
const BubbleSpecialTwo(
text: 'bubble special tow with tail',
isSender: true,
color: Color(0xAF6AD0F5),
),
const BubbleSpecialTwo(
text: 'bubble special tow without tail',
isSender: false,
tail: false,
),
const BubbleSpecialTwo(
text: 'bubble special tow without tail',
tail: false,
color: Color(0xAF6AD0F5),
),
],
),
),
),
);
}
}