Giter Site home page Giter Site logo

Comments (5)

udcode avatar udcode commented on August 10, 2024 1

Ok
(BTW, huge thanks for this incredible package)

from dash-chat-2.

udcode avatar udcode commented on August 10, 2024

update!
i was able to reproduce the bug in the example project
as you can see in the attached video

Screen.Recording.2022-09-17.at.21.34.43.mov

the following is the add video button

`
[
IconButton(
icon: Icon(Icons.attach_file),
onPressed: () async {
FilePickerResult? result = await FilePicker.platform.pickFiles(
allowedExtensions: [
'jpg',
'png',
'jpeg',
'mov',
'mp4',
],
allowMultiple: true,
allowCompression: true,
withData: true,
withReadStream: true,
type: FileType.custom,
);

            if (result != null) {
              List<ChatMessage> newMessages = result.files.map((file) {
                return ChatMessage(
                  user: user,
                  text: file.name,
                  medias: [
                    ChatMedia(
                      fileName: file.name,
                      type:
                          file.extension == 'mov' || file.extension == 'mp4'
                              ? MediaType.video
                              : MediaType.image,
                      url: file.path!,
                    ),
                  ],
                  createdAt: DateTime.now(),
                );
              }).toList();

              setState(() {
                messages.insertAll(0, newMessages);
              });
            }
          },
        ),
]

`

from dash-chat-2.

SebastienBtr avatar SebastienBtr commented on August 10, 2024

update! i was able to reproduce the bug in the example project as you can see in the attached video

Screen.Recording.2022-09-17.at.21.34.43.mov
the following is the add video button

` [ IconButton( icon: Icon(Icons.attach_file), onPressed: () async { FilePickerResult? result = await FilePicker.platform.pickFiles( allowedExtensions: [ 'jpg', 'png', 'jpeg', 'mov', 'mp4', ], allowMultiple: true, allowCompression: true, withData: true, withReadStream: true, type: FileType.custom, );

            if (result != null) {
              List<ChatMessage> newMessages = result.files.map((file) {
                return ChatMessage(
                  user: user,
                  text: file.name,
                  medias: [
                    ChatMedia(
                      fileName: file.name,
                      type:
                          file.extension == 'mov' || file.extension == 'mp4'
                              ? MediaType.video
                              : MediaType.image,
                      url: file.path!,
                    ),
                  ],
                  createdAt: DateTime.now(),
                );
              }).toList();

              setState(() {
                messages.insertAll(0, newMessages);
              });
            }
          },
        ),
]

`

Can you give me the full code of media.dart that you're using please?

from dash-chat-2.

udcode avatar udcode commented on August 10, 2024

import 'package:dash_chat_2/dash_chat_2.dart';
import 'package:examples/data.dart';
import 'package:file_picker/file_picker.dart';
import 'package:flutter/material.dart';

class Media extends StatefulWidget {
  @override
  _MediaState createState() => _MediaState();
}


class _MediaState extends State<Media> {
  List<ChatMessage> messages = media;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Media example'),
      ),
      body: DashChat(
        currentUser: user,
        inputOptions: InputOptions(
          leading: [
            IconButton(
              icon: Icon(Icons.camera_alt),
              onPressed: () {},
            ),
            IconButton(
              icon: Icon(Icons.attach_file),
              onPressed: () async {
                FilePickerResult? result = await FilePicker.platform.pickFiles(
                  allowedExtensions: [
                    'jpg',
                    'png',
                    'jpeg',
                    'mov',
                    'mp4',
                  ],
                  allowMultiple: true,
                  allowCompression: true,
                  withData: true,
                  withReadStream: true,
                  type: FileType.custom,
                );

                if (result != null) {
                  List<ChatMessage> newMessages = result.files.map((file) {
                    return ChatMessage(
                      user: user,
                      text: file.name,
                      medias: [
                        ChatMedia(
                          fileName: file.name,
                          type:
                              file.extension == 'mov' || file.extension == 'mp4'
                                  ? MediaType.video
                                  : MediaType.image,
                          url: file.path!,
                        ),
                      ],
                      createdAt: DateTime.now(),
                    );
                  }).toList();

                  setState(() {
                    messages.insertAll(0, newMessages);
                  });
                }
              },
            ),
          ],
          sendOnEnter: true,
        ),
        onSend: (ChatMessage m) {
          setState(() {
            messages.insert(0, m);
          });
        },
        messages: messages,
      ),
    );
  }
}

from dash-chat-2.

SebastienBtr avatar SebastienBtr commented on August 10, 2024

I was able to reproduce it and it should be fixed, I'll publish a new version

from dash-chat-2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.