SCOPS 27th
SCOPS 27th

Reputation: 33

i don't know type 'future dynamic ' type '(() = void) '

i tried to showModalBottomSheet but error code type 'future dynamic ' is not a subtype of type '(() = void) ' i don't know what is problem

I couldn't do it with the method recommended in the previous article

onTap: () => showModalBottomSheet( context: context, builder: bottomSheet), => it's not working... same error....

Widget imageProfile() {
    return Center(
      child: Stack(
        children: <Widget>[
          CircleAvatar(
              radius: 80,
              backgroundImage: _imageFile == null
                  ? AssetImage('assets/test.jpg') as ImageProvider
                  : FileImage(_imageFile!)),
          Positioned(
            bottom: 20,
            right: 20,
            child: InkWell(
              onTap: () {
                showModalBottomSheet(
                    context: context, builder: bottomSheet);
              },
              child: Icon(Icons.camera_alt, color: Colors.blue, size: 40),
            ),
          )
        ],
      ),
    );
  }

  Widget bottomSheet(BuildContext context) {
    return Container(
      height: 100,
      width: 200,
      margin: EdgeInsets.symmetric(horizontal: 20, vertical: 20),
      child: Column(children: [
        Text('사진선택',
            style: TextStyle(
              fontSize: 20,
            )),
        SizedBox(height: 20),
        Row(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: [
            TextButton.icon(
                onPressed: takePhoto(ImageSource.gallery),
                icon: Icon(Icons.camera, size: 50),
                label: Text('Camera', style: TextStyle(fontSize: 20))),
            TextButton.icon(
                onPressed: takePhoto(ImageSource.camera),
                icon: Icon(Icons.camera, size: 50),
                label: Text('Camera', style: TextStyle(fontSize: 20)))
          ],
        )
      ]),
    );
  }

Upvotes: 0

Views: 77

Answers (1)

Aditya
Aditya

Reputation: 330

You have to specify context in your modal builder

onTap: () {
            showModalBottomSheet(
                context: context, builder: (context) => bottomSheet);
          },

Upvotes: 2

Related Questions