On a page, I have a button. I am using the OnTap to display a bottom sheet. But the widget does not display on the screen. I don't know why. I have tried different option and even tried using other widget to check if they were displaying properly. It was working. But it is not with the bottom sheet. If you can explain to me what I am missing, it would be appreciated. Thank you.

I have tried also this, see code below, but it is not working properly because I can not use setstate.

ERROR : lost connection. It is killing the simulator.

import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter_sound/flutter_sound.dart';
import 'package:permission_handler/permission_handler.dart';

class Voice_Recording extends StatefulWidget {
  const Voice_Recording({Key key}) : super(key: key);

  @override
  _Voice_RecordingState createState() => _Voice_RecordingState();
}

class _Voice_RecordingState extends State<Voice_Recording> {
  final recorder = FlutterSoundRecorder();

  @override
  void initState(){
    super.initState();
    initRecorder();
  }

  @override
  void dispose(){
    recorder.closeRecorder();
    super.dispose();
  }

  Future initRecorder() async{
    final status = await Permission.microphone.request();

    if(status != PermissionStatus.granted){
      throw 'Microphone permission not granted!';
    }

    await recorder.openRecorder();
    recorder.setSubscriptionDuration(Duration(milliseconds: 500 ));
  }

  Future record() async{
    await recorder.startRecorder(toFile:'audio');
  }

  Future stop() async{
    final path = await recorder.stopRecorder();
    final audioFile = File(path);

    print('recorded audio File :$audioFile');
  }

  @override
  Widget build(BuildContext context) {
    return BottomSheet(
      builder: (context){
      return Column(
        children: [
          StreamBuilder<RecordingDisposition>(

            stream: recorder.onProgress,
            builder: (context,snapshot){
              final duration=snapshot.hasData?
                  snapshot.data.duration: Duration.zero;

              String twoDigits(int n) => n.toString().padLeft(60);
              final twoDigitsMinutes= twoDigits(duration.inMinutes.remainder(60));
              final twoDigitsSeconds = twoDigits(duration.inSeconds.remainder(60));

              return Text('$twoDigitsMinutes:$twoDigitsSeconds',
              style: TextStyle(
                fontSize: 80,
                fontWeight: FontWeight.bold,
              ),);
            },
          ),

          Center(child:
           ElevatedButton(child:Icon(recorder.isRecording? Icons.stop:Icons.mic,size:80),
            onPressed: () async{
            if(recorder.isRecording){
              await stop();
            }else{
              await record();
            }

            setState(() {

            });

          },)
          ),
        ]);
      });
  }
}

New code. not working perfectly due to lost of SetState()

showDialogVoiceRecording(BuildContext context, {String myText = 'Record and speak !'}) {
  showModalBottomSheet<void>(
      context: context,
      isDismissible: false,
      builder: (BuildContext context) {
        context = context;
        return Column(
          children: [
            StreamBuilder<RecordingDisposition>(

              stream: recorder.onProgress,
              builder: (context,snapshot){
                final duration=snapshot.hasData?
                snapshot.data.duration: Duration.zero;

                String twoDigits(int n) => n.toString().padLeft(60);
                final twoDigitsMinutes= twoDigits(duration.inMinutes.remainder(60));
                final twoDigitsSeconds = twoDigits(duration.inSeconds.remainder(60));

                return Text('$twoDigitsMinutes:$twoDigitsSeconds',
                  style: TextStyle(
                    fontSize: 80,
                    fontWeight: FontWeight.bold,
                  ),);
              },
            ),

            Center(child:
             ElevatedButton(child:Icon(recorder.isRecording? Icons.stop:Icons.mic,size:80),
              onPressed: () async{
                if(recorder.isRecording){
                  await stop();
                }else{
                  await record();
                }
               /* setState(() {

                });*/

              },)
            ),
          ],
        );
      }
  );
}