android – Heptic Feedback is not working with AndroidView/UiKitView flutter


I want to set up Heptic Feedback(vibration) on click of floating action button but it is not working for me when i use AndroidView/UiKitView.

I am using AndroidView/UiKitView for showing camera in flutter app.

but when i remove AndroidView/UiKitView then it works perfactly.

Please Suggest what to do.

I have provided full class you can run and check the problem.

class DemoScreen extends StatelessWidget {
  final Map<String, dynamic> creationParams = <String, dynamic>{};

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      floatingActionButton: FloatingActionButton(
        onPressed: () {
          HapticFeedback.heavyImpact();
        },
      ),
      appBar: AppBar(
        leading: GestureDetector(
          onTap: () {
            Navigator.pop(context);
          },
          child: Icon(
            Icons.add,
            color: Colors.white,
          ),
        ),
      ),
      body: Stack(
        children: [
          Platform.isAndroid
              ? AndroidView(
                  viewType: 'camera',
                  layoutDirection: TextDirection.ltr,
                  creationParams: creationParams,
                  creationParamsCodec: StandardMessageCodec(),
                  gestureRecognizers: <Factory<OneSequenceGestureRecognizer>>[
                    new Factory<OneSequenceGestureRecognizer>(
                      () => new EagerGestureRecognizer(),
                    ),
                  ].toSet(),
                )
              : UiKitView(
                  viewType: 'camera',
                  layoutDirection: TextDirection.ltr,
                  creationParams: creationParams,
                  creationParamsCodec: StandardMessageCodec(),
                  gestureRecognizers: <Factory<OneSequenceGestureRecognizer>>[
                    new Factory<OneSequenceGestureRecognizer>(
                      () => new EagerGestureRecognizer(),
                    ),
                  ].toSet(),
                ),
        ],
      ),
    );
  }
}

Latest articles

spot_imgspot_img

Related articles

Leave a reply

Please enter your comment!
Please enter your name here

spot_imgspot_img