rxdart usage in Flutter not being recognized

1,459

You have to keep the indents :

  dependencies:
    flutter:
      sdk: flutter
    cupertino_icons: ^0.1.2
    rxdart: ^0.18.0
Share:
1,459
Muhammad Touseef
Author by

Muhammad Touseef

Microsoft Student Partner and passionate uwp and mobile developer.

Updated on December 06, 2022

Comments

  • Muhammad Touseef
    Muhammad Touseef over 1 year

    I am trying to use rxdart package for the first time in my Flutter app and I have added the package in yaml file, then I saved it and vscode automatically ran flutter packages get on project after that complete I tried to import the package with following line

    import 'package:rxdart/rxdart.dart';
    

    but the compiler doesn't recognize rxdart within the packages. which is causing the error in the app.

    The following are my dependencies of pubspec.yaml

    dependencies:
      flutter:
        sdk: flutter
    
    
      cupertino_icons: ^0.1.2
    
      rxdart: ^0.18.0
    
    dev_dependencies:
      flutter_test:
        sdk: flutter
    

    Update

    Here is the repo for the project I am working on: https://www.github.com/touseefbsb/LoginStateful

    You have to open the folder login_stateful_bloc and the error is in bloc.dart file where I am trying to import it.

    • diegoveloper
      diegoveloper over 5 years
      do you have any error after execute 'flutter packages get' ?
    • ibhavikmakwana
      ibhavikmakwana over 5 years
      what's the error?
    • Muhammad Touseef
      Muhammad Touseef over 5 years
      @diegoveloper no I did not get any error after "flutter packages get" I got exit code 0, which I guess means it ran succesfully. error is get is "target of URI doesnt exist 'package:rxdart/rxdart.dart'".
    • Dinesh Balasubramanian
      Dinesh Balasubramanian over 5 years
      I cloned your repo and imported 'package:rxdart/rxdart.dart' and it is working fine. What is the version of flutter/dart ?
    • Muhammad Touseef
      Muhammad Touseef over 5 years
      0.5.1 flutter and 2.0 dart
  • Rémi Rousselet
    Rémi Rousselet over 5 years
    a few seconds more and I would have said the same. :p
  • diegoveloper
    diegoveloper over 5 years
    haha but it's weird because if you don't you use indents you get an error on the console
  • Muhammad Touseef
    Muhammad Touseef over 5 years
    sorry the indents in my questions were misleading I have corrected them now. indents are alright in my file and that is why flutter packages get is running fine.
  • diegoveloper
    diegoveloper over 5 years
    maybe you could attach a screenshot with the error message and the class where you are using it
  • Muhammad Touseef
    Muhammad Touseef over 5 years
    please see the update part of the question. @diegoveloper
  • diegoveloper
    diegoveloper over 5 years
    you are using an old version : rxdart: ^0.16.7
  • Muhammad Touseef
    Muhammad Touseef over 5 years
    also tried the latest version 0.18.1 still got the same error
  • diegoveloper
    diegoveloper over 5 years
    could you add a screenshot , put the mouse over the error line and take screenshot?
  • Muhammad Touseef
    Muhammad Touseef over 5 years
    guyx thanks for all the help but I just restarted the IDE and that solved the problem for me strangely. and I accepted the answer because indentation can also cause this problem so it may help somebody else as well :)
  • Thira
    Thira over 2 years
    This does not really answer the question. If you have a different question, you can ask it by clicking Ask Question. To get notified when this question gets new answers, you can follow this question. Once you have enough reputation, you can also add a bounty to draw more attention to this question. - From Review