serenader2014 / flutter_carousel_slider

A flutter carousel widget, support infinite scroll, and custom child widget.
https://pub.dev/packages/carousel_slider
MIT License
1.6k stars 585 forks source link

I can't change slides using mouse click and drag in windows #331

Open insinfo opened 2 years ago

insinfo commented 2 years ago

I can't change slides using mouse click and drag on windows, ideally it had the same behavior as android or buttons were displayed in the corners to be able to change slides

https://www.youtube.com/watch?v=DIgNatqp2m8

https://user-images.githubusercontent.com/12227024/148993000-62c4816a-9061-494b-aacf-34f23d509987.mp4

https://user-images.githubusercontent.com/12227024/148991977-8e59e076-5990-4447-abde-a69d2585f98e.mp4

 return CarouselSlider.builder(
                options: CarouselOptions(
                    height: 250.0,
                    autoPlay: false,
                    enlargeCenterPage: false,
                    viewportFraction: 1,
                    aspectRatio: 2.0, //
                    initialPage: 0,
                    onPageChanged: (index, reason) {
                      controller.onCarouselPageChanged(index);
                    }),
                itemCount: list.length,
                itemBuilder: (_, index, pageViewIndex) {
                  Post model = list[index];
                  return Builder(
                    builder: (BuildContext context) {
                      return GestureDetector(
                        onTap: () {
                          Modular.to
                              .pushNamed('/posts/detalhe', arguments: model);
                        },
                        child: Container(
                          width: screenSize.width,
                          height: 250,
                          child: EssentialImage(model.image),
                        ),
                      );
                    },
                  );
                },
              );
name: riodasostrasapp
description: App Oficial da Prefeitura de Rio das Ostras
version: 1.2.6+6
publish_to: none
environment:
  sdk: ">=2.12.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  flutter_localizations:
    sdk: flutter
  #para o Quiz
  font_awesome_flutter: ^9.2.0 #Null safety full
  flutter_custom_clippers: ^2.0.0 #Null safety full
  html_unescape: ^2.0.0 #Null safety full
  auto_size_text: ^3.0.0 #Null safety full
  connectivity_plus: ^2.1.0 #Null safety full
  url_launcher: ^6.0.17 #Null safety full
  share_plus: ^3.0.4 #Null safety share_plus
  map_launcher: ^2.1.1 #Null safety 
  platform_device_id: ^1.0.1 #Null safety full
  #location_permissions: ^4.0.1  # foi substituído pelo permission_handler 8.3.0  #Null safety
  location: ^4.3.0 #Null safety
  flutter_inappwebview: ^5.3.2 #Null safety  
  firebase_messaging: ^11.2.4 #Null safety  
  shared_preferences: ^2.0.11 #Null safety full
  sqflite: ^2.0.1 #Null safety 
  path_provider: ^2.0.8 #Null safety
  flutter_advanced_networkimage_2: ^2.0.0 #Null safety full
  cached_network_image: ^3.2.0 #Null safety 
  webview_flutter: ^3.0.0 #Null safety 
  flutter_map: ^0.14.0 #Null safety full
  latlong2: ^0.8.1 #Null safety full
 # queries: ^0.1.15 
  collection: ^1.15.0 #Null safety
  intl: ^0.17.0 #Null safety full
  http: ^0.13.4 #Null safety full
  dio: ^4.0.4 #Null safety full  
  universal_html: ^2.0.8 #Null safety full

  #wideget para infinit scroll
  incrementally_loading_listview: ^1.0.0 #Null safety
  mobx: any
  flutter_mobx: any 
  provider: ^6.0.1 #Null safety full  
  flutter_modular: ^4.3.0  #Null safety full
  equatable: ^2.0.3 #Null safety full
  carousel_slider: ^4.0.0 #Null safety full
  #para armazenar o token  
  flutter_secure_storage: ^5.0.2 #Null safety full
  #gerar codigo qr
  qr_flutter: ^4.0.0  #Null safety full
  barcode_scan2: ^4.2.0 #Null safety full
  jaguar_jwt: ^3.0.0 #Null safety

  riodasostrasapp_core:
    path: ../riodasostrasapp_core
   # hosted:
   #   name: riodasostrasapp_core
   #   url: http://pub.riodasostras.rj.gov.br:4000
   # version: ^1.0.39

dependency_overrides:
  rxdart: ^0.27.3 #Null safety full

dev_dependencies:
#  flutter_test:
#    sdk: flutter
#  mockito: ^4.1.1
  build_runner: ^2.1.7 #Null safety
  mobx_codegen: ^2.0.4 #Null safety
  slidy: ^3.2.2+2 #Null safety full

flutter:
  uses-material-design: true

  assets:
    - assets/images/

  fonts:
    - family: Poppins
      fonts:
        - asset: assets/fonts/Poppins/Poppins-Regular.ttf
        - asset: assets/fonts/Poppins/Poppins-Medium.ttf
          weight: 600
        - asset: assets/fonts/Poppins/Poppins-Bold.ttf
          weight: 700
    - family: Montserrat
      fonts:
        - asset: assets/fonts/Montserrat/Montserrat-Regular.ttf
        - asset: assets/fonts/Montserrat/Montserrat-Medium.ttf
          weight: 600
        - asset: assets/fonts/Montserrat/Montserrat-Bold.ttf
          weight: 700      
    - family: pmro_app
      fonts:
        - asset: assets/fonts/pmro.ttf         

scripts:
  mobx: flutter pub run build_runner watch --delete-conflicting-outputs
insinfo commented 2 years ago

I believe that it would be enough for you to change your code involving the ListView with the ScrollConfiguration to solve the problem if you are using LisView.

ScrollConfiguration(
                        behavior: ScrollConfiguration.of(context).copyWith(
                          dragDevices: {
                            PointerDeviceKind.touch,
                            PointerDeviceKind.mouse,
                          },
                        ),
                        child: ListView.builder( ....
Ashish8460 commented 2 years ago

Place your carousal slider into below child then it's working.

ScrollConfiguration( behavior: ScrollConfiguration.of(context).copyWith( dragDevices: { PointerDeviceKind.touch, PointerDeviceKind.mouse, }, ), child : // Your slider Widget

)

Silfalion commented 2 years ago

This fixed the problem for me, on web: https://stackoverflow.com/a/69202112/8568263