Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AnimationController has lost it's vsync. #63088

Closed
tomosullivan8 opened this issue Aug 6, 2020 · 24 comments
Closed

AnimationController has lost it's vsync. #63088

tomosullivan8 opened this issue Aug 6, 2020 · 24 comments
Labels
in triage Presently being triaged by the triage team

Comments

@tomosullivan8
Copy link

The AnimationController has lost it's vsync and is now requiring TickerProvider.

Error message:

Found this candidate, but the arguments don't match.
AnimationController({
^^^^^^^^^^^^^^^^^^^

image

I've checked the location of the AnimationController file and it's missing it's '@' before the required, I presume this is the issue and why it's caused my application to crash.

image

Flutter Doctor output;

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel master, 1.21.0-6.0.pre.226, on Mac OS X 10.15.5 19F101, locale en-GB)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 11.6)
[✓] Chrome - develop for the web
[✓] Android Studio (version 3.6)
[✓] Connected device (3 available)

• No issues found!
@TahaTesser
Copy link
Member

hI @tomosullivan8
This is working on latest master

Please try this code sample

Code Sample
import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      title: 'Material App',
      theme: ThemeData.dark(),
      home: Home(),
    );
  }
}

class Home extends StatefulWidget {
  @override
  _HomeState createState() => _HomeState();
}

class _HomeState extends State<Home> with SingleTickerProviderStateMixin {
  AnimationController _animationController;

  @override
  void initState() {
    super.initState();
    _animationController =
        AnimationController(vsync: this, duration: Duration(seconds: 1))
          ..forward()
          ..repeat(reverse: true);
  }

  @override
  void dispose() {
    _animationController.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(),
      body: Container(
        child: Center(
          child: AnimatedBuilder(
            animation: _animationController,
            builder: (context, child) {
              return Container(
                decoration: ShapeDecoration(
                    shape: CircleBorder(), color: Colors.white.withOpacity(.5)),
                child: Padding(
                  padding: EdgeInsets.all(8.0 * _animationController.value),
                  child: child,
                ),
              );
            },
            child: Container(
              decoration:
                  ShapeDecoration(shape: CircleBorder(), color: Colors.white),
              child: IconButton(
                  icon: Icon(
                    Icons.flight_takeoff,
                    size: 24,
                    color: Colors.black,
                  ),
                  onPressed: () {}),
            ),
          ),
        ),
      ),
    );
  }
}

Screen Recording 2020-08-06 at 8.23.00 PM.zip

flutter doctor -v
[✓] Flutter (Channel master, 1.21.0-6.0.pre.226, on Mac OS X 10.15.6 19G73,
    locale en-GB)
    • Flutter version 1.21.0-6.0.pre.226 at /Users/taha/Code/flutter_master
    • Framework revision fa60f525f0 (3 hours ago), 2020-08-06 08:01:03 -0400
    • Engine revision 36db6cfdd1
    • Dart version 2.10.0 (build 2.10.0-3.0.dev 14a6aac97b)

 
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.1)
    • Android SDK at /Users/taha/Code/sdk
    • Platform android-30, build-tools 30.0.1
    • ANDROID_HOME = /Users/taha/Code/sdk
    • Java binary at: /Applications/Android
      Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build
      1.8.0_242-release-1644-b3-6222593)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.6)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.6, Build version 11E708
    • CocoaPods version 1.9.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.0)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 48.0.2
    • Dart plugin version 193.7361
    • Java version OpenJDK Runtime Environment (build
      1.8.0_242-release-1644-b3-6222593)

[✓] VS Code (version 1.47.3)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.13.2

[✓] Connected device (6 available)
    • SM M305F (mobile)      • 32003c30dc19668f                     •
      android-arm64  • Android 10 (API 29)
    • Taha’s iPhone (mobile) • 00008020-001059882212002E            • ios
      • iOS 13.6
    • iPhone 11 (mobile)     • 1EB615AF-5AB9-4AAA-A587-A6642BB79484 • ios
      • com.apple.CoreSimulator.SimRuntime.iOS-13-6 (simulator)
    • macOS (desktop)        • macos                                • darwin-x64
      • Mac OS X 10.15.6 19G73
    • Web Server (web)       • web-server                           •
      web-javascript • Flutter Tools
    • Chrome (web)           • chrome                               •
      web-javascript • Google Chrome 84.0.4147.105

• No issues found!

Can you please provide your flutter run --verbose and a complete reproducible minimal code sample
Thank you

@TahaTesser TahaTesser added in triage Presently being triaged by the triage team waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds labels Aug 6, 2020
@stefanodecillis
Copy link

stefanodecillis commented Aug 6, 2020

Hello @TahaTesser ,

I have the lasest version of Flutter (same as the creator of this thread) and your code (the animationController statement) does not work. Vsync is still missing and asks for tickerProvider. Even if you give it, it will fail to compile.
I attached what I (probably we) see. Instead of vsync, asks for ticketProvider.

animation

@tomosullivan8
Copy link
Author

Hi @TahaTesser.

I've tried upgrading to the latest master version again, but as @stefanodecillis mentioned it's a definite error as the vsync has been removed. I do believe the issue lies with the code missing the @ before the required, and as you can see in my screenshot the vsync is not an option.

If you have any other suggestions then let me know!

Thanks

Tom

@no-response no-response bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Aug 6, 2020
@tomosullivan8
Copy link
Author

Also, just to confirm, if I included the sample code I get the error message!

image

@stefanodecillis
Copy link

I would also add that I tried to modify the @required in the class and so get the vsync attribute. The problem is that results not to be a good candidate. Give the error mentioned in my thread. From it, you can probably find the commits where the error was made by mistake since it was written for null safety purpose

@tomosullivan8
Copy link
Author

@stefanodecillis if you switch to beta channel and then revert back to the master it seems to fix the problem! That's what I did and bingo the vsync is alive. If this fixes it for you please can you close this after.

@stefanodecillis
Copy link

Agree, the solution worked. Thank you!

@ghost
Copy link

ghost commented Aug 7, 2020

This happened to me as well (im using flutter beta channel). I fixed it by updating dart. Now im using Dart SDK version: 2.10.0-4.0.dev (dev)

@Zfinix
Copy link

Zfinix commented Aug 19, 2020

@stefanodecillis if you switch to beta channel and then revert back to the master it seems to fix the problem! That's what I did and bingo the vsync is alive. If this fixes it for you please can you close this after.

Switching to beta solves this issue

@nibo
Copy link

nibo commented Aug 21, 2020

change minimum sdk to 2.8
run flutter upgrade
run flutter pub get
run flutter clean
restart IDE

@Zfinix
Copy link

Zfinix commented Aug 23, 2020

change minimum sdk to 2.8
run flutter upgrade
run flutter pub get
run flutter clean
restart IDE

This worked

@rodgav
Copy link

rodgav commented Aug 30, 2020

change minimum sdk to 2.8
run flutter upgrade
run flutter pub get
run flutter clean
restart IDE

not working for me.

solution for me stable and beta whit minimum sdk to 2.8
run:

  • flutter version 1.20.2
  • flutter upgrade
  • flutter pub upgrade

good lucky

@Baluds
Copy link

Baluds commented Oct 8, 2020

change minimum sdk to 2.8
run flutter upgrade
run flutter pub get
run flutter clean
restart IDE

Worked for me

@bgmf
Copy link

bgmf commented Oct 9, 2020

The important part seems to be to use the minimum SDK 2.8. The rest, apart from restarting Android Studio, was not that important to me.

@sudeshkumara
Copy link

This error occurred after I updated the stable channel. But none of these solutions worked for me. anyone can help me.

Flutter is already up to date on channel stable
Flutter 1.22.1 • channel stable • https://github.com/flutter/flutter.git
Framework • revision f30b7f4 (2 days ago) • 2020-10-08 10:06:30 -0700
Engine • revision 75bef9f
Tools • Dart 2.10.1


Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 1.22.1, on Microsoft Windows [Version 10.0.17763.1457], locale en-US)

[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[√] Chrome - develop for the web
[√] Android Studio (version 4.0)
[√] VS Code (version 1.49.1)
[√] Connected device (3 available)

• No issues found!

@sudeshkumara
Copy link

If none of these work, check after restarting the PC. I've tried above mentioned all solutions even invalidate cache and restart option in android studio. But did not work. The issue has been resolved after the PC restarted.

@Yogi09
Copy link

Yogi09 commented Nov 3, 2020

It's late I think but if someone get this issue in future so can refere below solution.

class _onCreate extends State with TickerProviderStateMixin{

}

just add with TickerProviderStateMixin this line and it will work.

@it-one-mm
Copy link

Delete .idea folder and reopen project and this should work with Android Studio.

@wuwz98
Copy link

wuwz98 commented Feb 3, 2021

JUST RESTART YOUR COMPUTER
got the same problem using Dart 2.10.3 and Flutter 1.22.3.
there's nothing wrong with the code, yet I got an red underline just belwo vsync, thisproblem is solved after restaring the computer.

@bgmf
Copy link

bgmf commented Feb 5, 2021

JUST RESTART YOUR COMPUTER
got the same problem using Dart 2.10.3 and Flutter 1.22.3.
there's nothing wrong with the code, yet I got an red underline just belwo vsync, thisproblem is solved after restaring the computer.

Are you from the IT Crowd? 😂
No, restarting the computer is, in contrary to popular belief, mystically resolve all of your problems... 😉

@RedCuckoo
Copy link

What you call "restart a computer" simply do an "Invalidate cache and restart" in Android Studio (it's under File).

@huynguyennovem
Copy link

just do Invalid caches and restart Android Studio

@HeCorr
Copy link

HeCorr commented Jun 27, 2021

Here we are, about a year later. With null-safety enabled this issue appeared again...

sdk >= 2.8.0 gives an error
flutter clean doesn't fix it
flutter upgrade doesn't fix it either...

I guess I'm just not doing animations then.

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 31, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
in triage Presently being triaged by the triage team
Projects
None yet
Development

No branches or pull requests