How can I flip my card and at the same time I can click the picture to produce sounds?

John Ryle Singh

I am new to flutter and I am creating a flashcard that when I long-press the picture, will produce sounds. I did that. My problem is how can I use a flip since it is a flashcard, it has a front and it has a back picture. each picture has its distinct sound. I also used a carousel in Pub dev ( carousel, flip card). I used a button, but it didn't work. I got an error. It says that the global key is used multiple times. So it's a failed plan. I also thought of creating a button to scroll pictures but it did not work. How can I flip a card and produce sound? This is my code if you have questions, please ask I will answer just to solve this. Thank You

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:carousel_slider/carousel_slider.dart';
import 'package:assets_audio_player/assets_audio_player.dart';
import 'package:baybay_app/FlashCards/FlashcardsList.dart';
import 'package:flip_card/flip_card.dart';

class Flashcards extends StatefulWidget {
  final List<FlashcardsList> _flashCardsList = flashcardsList;
  @override
  _FlashcardsState createState() => _FlashcardsState();
}

class _FlashcardsState extends State<Flashcards> {
  CarouselController buttonCarouselController = CarouselController();
  List<FlashcardsList> flashCardsList;
  @override
  void initState() {
    super.initState();
    flashCardsList = widget._flashCardsList;
  }

  Widget build(BuildContext context) => Scaffold(
    appBar: AppBar(title:Text('Sample Carousel')),
    body: Column(
        children: <Widget>[

          CarouselSlider.builder(
            itemBuilder:(context, index){

              return
                Card(
                  child:FlipCard(
                    front: ListTile(

                      title: Image(
                          image: AssetImage(
                              widget._flashCardsList[index].pictures1)
                      ),
                  ),



                    back: ListTile(

                      title: Image(
                          image: AssetImage(
                              widget._flashCardsList[index].pictures2)
                      ),
                    ),
                  ),


                );



            },
            itemCount: widget._flashCardsList.length,
            options: CarouselOptions(

              autoPlay: false,
              enlargeCenterPage: true,
              viewportFraction: 0.9,
              aspectRatio: 2.0,
              initialPage: 2,
            ),

          ),
        ]

    ),

      );
      void onPlayAudio(index) async{
        AssetsAudioPlayer assetsAudioPlayer = AssetsAudioPlayer();
        assetsAudioPlayer.open(
            Audio(widget._flashCardsList[index].sound1)
        );
      }
      void PlayAudio(index) async{
        AssetsAudioPlayer assetsAudioPlayer = AssetsAudioPlayer();
        assetsAudioPlayer.open(
            Audio(widget._flashCardsList[index].sound2)
        );
      }
    }

'''

I also have a list of pictures to put on the flashcard.

Akif

You can wrap your Card with the InkWell widget. And you can handle long press on the Card. It will look like this:

 Widget build(BuildContext context) => Scaffold(
        appBar: AppBar(title: Text('Sample Carousel')),
        body: Column(children: <Widget>[
          CarouselSlider.builder(
            itemBuilder: (context, index) {
              return InkWell(
                onLongPress: () {
                  onPlayAudio(index);
                },
                child: Card(
                  child: FlipCard(
                    front: ListTile(
                      title: Image(
                          image: AssetImage(
                              widget._flashCardsList[index].pictures1)),
                    ),
                    back: ListTile(
                      title: Image(
                          image: AssetImage(
                              widget._flashCardsList[index].pictures2)),
                    ),
                  ),
                ),
              );
            },
            itemCount: widget._flashCardsList.length,
            options: CarouselOptions(
              autoPlay: false,
              enlargeCenterPage: true,
              viewportFraction: 0.9,
              aspectRatio: 2.0,
              initialPage: 2,
            ),
          ),
        ]),
      );

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How can I play multiple sounds at the same time in pygame?

How can i upload a video and a picture at the same time to a server using php and my sql

how can I flip an android dialog on click?

How can I play different sounds each time I startup?

(How) Can I get a stream of all sounds recorded from the microphone that my computer did not produce? (using PulseAudio or something else)

how can I reflect/flip a picture around when loading

How can I fix this css card flip transition?

How can I rotate element with javascript like flip card

How can I show a picture in design time in MFC picture control?

How can I change the color of my card when I click mycheckbox?

Can I use both my on-board display adapter and a graphics card at the same time?

CSS flip card: How can I activate the flip via tab, so it is keyboard accessible?

How do I record sounds directly from my sound card?

How can I disable the event sounds in Kubuntu?

How can I change some of the system sounds?

How can I resolve my problem about flip cards in javascript?

How can I make a click listener for every Item I have in my card view inside my Recycler View

How can i make a subroutine click a picture box?

How can i drag and drop multiple widgets at the same time i can drag my labels but want to drag them at the same time

Django 1.11 - How can I ensure TruncYear to produce Zulu time

How can I remove the checkboxes on the front face when I flip the card

How Can I Flip the cards in (David walsh CSS flip trick) on click?

Flip Card HTML: Wont flip or stay flip when I click

How can I correct my code to produce a nested dictionary?

How can I produce this hover effect onto my carousel?

How Can I Click a card with protractor using class name

In ggplot, how can I plot time series data like this picture?

How can I make my picture display on a half of the screen?

How can I add *my own* desktop picture to 19.04?