flutter_hello_sdk 0.0.4 copy "flutter_hello_sdk: ^0.0.4" to clipboard
flutter_hello_sdk: ^0.0.4 copied to clipboard

discontinued
outdated

Flutter Chat Widget by MSG91

example/lib/main.dart

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

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      title: 'Flutter Hello SDK Example',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key});

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  double viewHeight = 100;
  double viewWidth = 130;
  @override
  Widget build(BuildContext context) {
    return Stack(
      children: [
        Scaffold(
          resizeToAvoidBottomInset: false,
          appBar: AppBar(
            scrolledUnderElevation: 0,
            title: const Text('Flutter Hello SDK Example'),
          ),
          body: SingleChildScrollView(
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                const Text(
                  'Sample Image',
                  style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
                ),
                const FlutterLogo(
                  size: 150,
                  style: FlutterLogoStyle.stacked,
                ),
                const Text(
                  'Sample GridView',
                  style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
                ),
                SizedBox(
                  height: MediaQuery.of(context).size.height * 0.45,
                  child: GridView.builder(
                    physics: const NeverScrollableScrollPhysics(),
                    shrinkWrap: true,
                    gridDelegate:
                        const SliverGridDelegateWithFixedCrossAxisCount(
                      crossAxisCount: 2,
                      crossAxisSpacing: 10,
                      mainAxisSpacing: 10,
                    ),
                    itemCount: 4,
                    itemBuilder: (context, index) {
                      return Container(
                        color: Colors.deepPurple[100 * (index % 9)],
                        child: Center(
                          child: Text('Item $index'),
                        ),
                      );
                    },
                  ),
                ),
                const SizedBox(height: 20),
                const Text(
                  'Sample GridView',
                  style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
                ),
                SizedBox(
                  height: MediaQuery.of(context).size.height * 0.45,
                  child: GridView.builder(
                    physics: const NeverScrollableScrollPhysics(),
                    shrinkWrap: true,
                    gridDelegate:
                        const SliverGridDelegateWithFixedCrossAxisCount(
                      crossAxisCount: 2,
                      crossAxisSpacing: 10,
                      mainAxisSpacing: 10,
                    ),
                    itemCount: 4,
                    itemBuilder: (context, index) {
                      return Container(
                        color: Colors.deepPurple[100 * (index % 9)],
                        child: Center(
                          child: Text('Item $index'),
                        ),
                      );
                    },
                  ),
                ),
              ],
            ),
          ),
        ),
        Positioned(
          bottom: 0,
          right: 0,
          child: SizedBox(
            height: viewHeight,
            width: viewWidth,
            child: Overlay(
              initialEntries: [
                OverlayEntry(
                  builder: (context) => ChatWidget(
                    button: ClipPath(
                      clipper: BirthDayCardClipper(),
                      child: Container(
                          height: 130,
                          width: 80,
                          decoration: const BoxDecoration(
                            gradient: LinearGradient(
                              begin: Alignment.topCenter,
                              end: Alignment.bottomCenter,
                              colors: [
                                Colors.red,
                                Colors.black,
                              ],
                            ),
                          ),
                          child: const Center(
                            child: Text(
                              "Chat With Me",
                              textAlign: TextAlign.center,
                              style:
                                  TextStyle(color: Colors.white, fontSize: 12),
                            ),
                          )),
                    ),
                    widgetToken: "ec5d6",
                    uniqueId: "AA_94bb_0jd",
                    name: "John Doe",
                    mail: "johndoe@example.com",
                    number: "+1234567890",
                    widgetColor: const Color.fromARGB(255, 209, 58, 12),
                    onLaunchWidget: () {
                      // set the view hight/width to full hight/width of the screen
                      setState(() {
                        viewHeight = MediaQuery.of(context).size.height;
                        viewWidth = MediaQuery.of(context).size.width;
                      });
                    },
                    onHideWidget: () {
                      // set the button hight/width on the screen
                      setState(() {
                        viewHeight = 100;
                        viewWidth = 130;
                      });
                    },
                  ),
                )
              ],
            ),
          ),
        ),
      ],
    );
  }
}

class BirthDayCardClipper extends CustomClipper<Path> {
  @override
  Path getClip(Size size) {
    var path = Path();
    double cornerRadius = 10.0;

    path.moveTo(0, 0);
    path.lineTo(0, size.height - cornerRadius);
    path.quadraticBezierTo(0, size.height, cornerRadius, size.height);
    path.lineTo(size.width / 2, size.height - cornerRadius * 2);
    path.lineTo(size.width - cornerRadius, size.height);
    path.quadraticBezierTo(
        size.width, size.height, size.width, size.height - cornerRadius);
    path.lineTo(size.width, 0);
    path.lineTo(0, 0);

    path.close();
    return path;
  }

  @override
  bool shouldReclip(CustomClipper<Path> oldClipper) => false;
}
0
likes
0
points
32
downloads

Publisher

unverified uploader

Weekly Downloads

Flutter Chat Widget by MSG91

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, flutter_inappwebview, flutter_statusbarcolor_ns, url_launcher

More

Packages that depend on flutter_hello_sdk