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

type '() => Null' is not a subtype of type '(() => StoryItem)?' of 'orElse' #20

Closed
blacknight9 opened this issue Apr 26, 2023 · 13 comments

Comments

@blacknight9
Copy link

blacknight9 commented Apr 26, 2023

when opening the story i get this error

type '() => Null' is not a subtype of type '(() => StoryItem)?' of 'orElse'
can you help

@awaik
Copy link
Owner

awaik commented Apr 26, 2023

Probably you have the wrong name in one of the fields in the database.

@blacknight9
Copy link
Author

Probably you have the wrong name in one of the fields in the database.

here is screenshot

Screenshot 2023-04-26 at 7 35 03 PM

@awaik
Copy link
Owner

awaik commented Apr 27, 2023

Please check the data types, I will add it to the docs.

Screenshot 2023-04-27 at 09 56 32

@blacknight9
Copy link
Author

Please check the data types, I will add it to the docs.

Screenshot 2023-04-27 at 09 56 32

exactly the same

@awaik
Copy link
Owner

awaik commented Apr 28, 2023

Can you send me the code, I'll check it.
Please double-check that you have Maps - in the case of Array instead of map you will have this error.

@blacknight9
Copy link
Author

i copied your code and i was just testing

class Stories extends StatelessWidget {
   Stories({Key? key}) : super(key: key);

 static const String collectionDbName = 'stories';

final controller = Get.put(ProfilePageScreenController());

  final CollectionReference dbInstance =
  FirebaseFirestore.instance.collection(collectionDbName);

  @override
  Widget build(BuildContext context) {


    return FlutterInstagramStories(
      collectionDbName: collectionDbName,
      showTitleOnIcon:true,
      backFromStories: () {
        controller.backFromStoriesAlert(context);
      },
      iconTextStyle: const TextStyle(
        fontSize: 14.0,
        color: Colors.white,
      ),
      iconImageBorderRadius: BorderRadius.circular(15.0),
      iconBoxDecoration: const BoxDecoration(
        borderRadius: BorderRadius.all(Radius.circular(15.0)),
        color: Color(0xFFffffff),
        boxShadow: [
          BoxShadow(
            color: Color(0xff333333),
            blurRadius: 10.0,
            offset: Offset(
              0.0,
              4.0,
            ),
          ),
        ],
      ),
      iconWidth: 150.0,
      iconHeight: 150.0,
      textInIconPadding:
      const EdgeInsets.only(left: 8.0, right: 8.0, bottom: 12.0),
      //how long story lasts in seconds
      imageStoryDuration: 7,
      progressPosition: ProgressPosition.top,
      repeat: true,
      inline: false,
      languageCode: 'en',
      backgroundColorBetweenStories: Colors.black,
      closeButtonIcon: const Icon(
        Icons.close,
        color: Colors.white,
        size: 28.0,
      ),
      closeButtonBackgroundColor: const Color(0x11000000),
      sortingOrderDesc: true,
      lastIconHighlight: true,
      lastIconHighlightColor: myPrimaryAccent,
      lastIconHighlightRadius: const Radius.circular(15.0),
      captionTextStyle: const TextStyle(
        fontSize: 22,
        color: Colors.white,
      ),
      captionMargin: const EdgeInsets.only(
        bottom: 50,
      ),
      captionPadding: const EdgeInsets.symmetric(
        horizontal: 24,
        vertical: 8,
      ),
    );


  }
}

@awaik
Copy link
Owner

awaik commented Apr 29, 2023

This is definetaly the data structure.
Please check maps, arrays one more time.
I've updated example - it works, so the reason is in the database.

@Ozgur-Abi
Copy link

Did you have any success solving the issue? I have the same database schema but although i can see previews, when i try to view stories I get this error

@awaik
Copy link
Owner

awaik commented Jun 16, 2023

Please check arrays and maps as on the screenshots upwards.

@Ozgur-Abi
Copy link

Please check arrays and maps as on the screenshots upwards.

I fixed it with this suggestion,
#16
And created a fork of it https://github.com/Ozgur-Abi/flutter_instagram_stories_fixed.

However, video stories still don't work, on both your version and my fork. I tried it with both on my database and your database and example code. Video shows as loading but never loads.

@awaik
Copy link
Owner

awaik commented Jun 16, 2023

Can you please make a video with database - when you point a mouse it displays field type.
In this case I will know for sure that the data structure is ok and help to fix it.

@danbeyene
Copy link

Please check arrays and maps as on the screenshots upwards.

I fixed it with this suggestion, #16 And created a fork of it https://github.com/Ozgur-Abi/flutter_instagram_stories_fixed.

However, video stories still don't work, on both your version and my fork. I tried it with both on my database and your database and example code. Video shows as loading but never loads.

uncomment setstate() - inside story_video.dart - code snippet --- playerController!.initialize().then((v) {
setState(() {});
widget.storyController!.play();
});

@awaik awaik closed this as completed Mar 7, 2024
@azappz
Copy link

azappz commented Apr 28, 2024

the package not work, the story cover show but when i click on it u got null error, i tried all the solutions and didn't work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants