how to fix error DevFS synchronization failed when installing flutter SVG package?

Issue

I got this flutter_SVG package

updated pubspec.yaml as below

    dependencies:
  flutter:
    sdk: flutter

  cupertino_icons: ^0.1.3
  flutter_svg: ^0.17.4

clicked the pub get button and done properly

I confirmed that my SVG file is properly put in under assets in the pubspec.yaml

then in Home.dart where I want, I imported the package normally, and below is the code where the svg should work as per package readme instructions

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';

class HomeState extends State<Home> {
  TextEditingController _foo = new TextEditingController();


  Widget build(BuildContext context) {

    const pyramidsYellowIcon = 'my_assets/icons/pyramids_yellow.svg';
    const followIconOffIcon = 'my_assets/icons/follow_icon_off.svg';

    return Stack(

          children: <Widget>[

            Container(                                   
              child: SvgPicture.asset(followIconOffIcon, semanticsLabel: 'follow',),
            ),
            
          ],
          
        ),
    
  }
}

then a hot reload error shows DevFS synchronization failed

and below logcat shows

2020-07-02 12:43:21.375 3019-3019/? E/GmsClientSupervisor: Timeout waiting for ServiceConnection callback com.google.android.gms.clearcut.service.START
java.lang.Exception
    at tlk.handleMessage(PG:6)
    at android.os.Handler.dispatchMessage(Handler.java:98)
    at tzg.a(PG:5)
    at tzg.dispatchMessage(PG:4)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6119)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)

any, of course, the emulator refuses to reload, when I delete all changes mentioned above, everything is fixed and normal

Solution

After you add a package or an asset the hot reload doesn’t work. You have to restart the app.

Answered By – Niteesh

Answer Checked By – David Marino (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published.