Home > Mobile >  'vsync' is deprecated and shouldn't be used
'vsync' is deprecated and shouldn't be used

Time:07-02

After updating to flutter version 3.0.3 I'm getting this warning while trying to use AnimatedSize widget:

'vsync' is deprecated and shouldn't be used. This field is now ignored. This feature was deprecated after v2.2.0-10.1.pre..
Try replacing the use of the deprecated member with the replacement.

child: AnimatedSize(
   vsync: this,
   curve: Curves.easeIn,
   duration: Duration(seconds: 1),
   child: Text("test"),
),

so what is the replacement?

CodePudding user response:

double _size = 50.0;
  bool _large = false;

  void _updateSize() {
    setState(() {
      _size = _large ? 250.0 : 100.0;
      _large = !_large;
    });
  }

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: () => _updateSize(),
      child: Container(
        color: Colors.amberAccent,
        child: AnimatedSize(
          curve: Curves.easeIn,
          duration: const Duration(seconds: 1),
          child: FlutterLogo(size: _size),
        ),
      ),
    );
  }

More information AnimatedSize

CodePudding user response:

Just remove the field, doesn't need it anymore,

the updated docs example also removed it AnimatedSize class

  • Related