chat_bottom_container 0.0.2 copy "chat_bottom_container: ^0.0.2" to clipboard
chat_bottom_container: ^0.0.2 copied to clipboard

A Flutter package for managing the bottom container of the chat page

chat_bottom_container #

author author pub

Language: English | 中文

This is a Flutter package for managing the bottom container of a chat page, which can be used to implement smooth switching between the keyboard and the other panel.

Chat: Join WeChat group

☕ Support me #

ko-fi

The WeChat payment QR codes of the two core authors, thank you for your support!

LinXunFeng GitLqr

📦 Installing #

Add chat_bottom_container to your pubspec.yaml file:

dependencies:
  chat_bottom_container: latest_version

Import chat_bottom_container in files that it will be used:

import 'package:chat_bottom_container/chat_bottom_container.dart';

🚀 Usage #

Overall page layout.

@override
Widget build(BuildContext context) {
  return Scaffold(
    // Need to be set to false
    resizeToAvoidBottomInset: false,
    body: Column(
      mainAxisAlignment: MainAxisAlignment.center,
      children: [
        Expanded(
          child: ListView.builder(
            ...
          ),
        ),
        // Input box view
        _buildInputView(),
        // Bottom container
        _buildPanelContainer(),
      ],
    ),
  );
}

Bottom container.

/// Custom bottom panel type
enum PanelType {
  none,
  keyboard,
  emoji,
  tool,
}

ChatBottomPanelContainerController<PanelType> controller =
      ChatBottomPanelContainerController<PanelType>();
final FocusNode inputFocusNode = FocusNode();
PanelType currentPanelType = PanelType.none;

Widget _buildPanelContainer() {
  return ChatBottomPanelContainer<PanelType>(
    controller: controller,
    inputFocusNode: inputFocusNode,
    otherPanelWidget: (type) {
      // Return the custom panel view
      if (type == null) return const SizedBox.shrink();
      switch (type) {
        case PanelType.emoji:
          return _buildEmojiPickerPanel();
        case PanelType.tool:
          return _buildToolPanel();
        default:
          return const SizedBox.shrink();
      }
    },
    onPanelTypeChange: (panelType, data) {
      // Record the current panel type
      switch (panelType) {
        case ChatBottomPanelType.none:
          currentPanelType = PanelType.none;
          break;
        case ChatBottomPanelType.keyboard:
          currentPanelType = PanelType.keyboard;
          break;
        case ChatBottomPanelType.other:
          if (data == null) return;
          switch (data) {
            case PanelType.emoji:
              currentPanelType = PanelType.emoji;
              break;
            case PanelType.tool:
              currentPanelType = PanelType.tool;
              break;
            default:
              currentPanelType = PanelType.none;
              break;
          }
          break;
      }
    },
    panelBgColor: panelBgColor,
  );
}

Toggle bottom panel type.

controller.updatePanelType(
  // Set the current bottom panel type of ChatBottomPanelContainer
  // Can be passed to ChatBottomPanelType.keyboard | ChatBottomPanelType.other | ChatBottomPanelType.none
  ChatBottomPanelType.other,
  // Callback the PanelType value customized by developer, must be passed when ChatBottomPanelType.other
  data: PanelType.emoji, // PanelType.tool
);

🖨 About Me #

29
likes
0
pub points
85%
popularity

Publisher

verified publisherfullstackaction.com

A Flutter package for managing the bottom container of the chat page

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on chat_bottom_container