截断是否在null上被调用

截断是否在null上被调用

本文介绍了截断是否在null上被调用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我显示了一个星形图标,然后按下了RatingBar,然后在Pageviewbuilder中进行了分类.每次第一次按下我的单选按钮时,我都会看到RatingBar即时消息显示错误消息

I showing a star icon and on pressed a RatingBar and thats inside a Pageviewbuilder. Every first time when pressing the single I con star to see the RatingBar im getting an error that says


════════ Exception caught by widgets library ═══════════════════════════════════
The following NoSuchMethodError was thrown building Container:
The method 'truncate' was called on null.
Receiver: null
Tried calling: truncate()

The relevant error-causing widget was
Container
lib/taking videos/currentuservideos.dart:374
When the exception was thrown, this was the stack
#0      Object.noSuchMethod (dart:core-patch/object_patch.dart:54:5)
#1      _RatingBarIndicatorState.initState
package:flutter_rating_bar/src/rating_bar_indicator.dart:65
#2      StatefulElement._firstBuild
package:flutter/…/widgets/framework.dart:4632
#3      ComponentElement.mount
package:flutter/…/widgets/framework.dart:4469
...     Normal element mounting (7 frames)
...
════════════════════════════════════════════════════════════════════════════════

════════ Exception caught by rendering library ═════════════════════════════════
A RenderFlex overflowed by 99932 pixels on the bottom.
The relevant error-causing widget was
Column
lib/taking videos/currentuservideos.dart:302

滚动到第二页时,再次按单个图标以查看RatingBar,则错误消失了.首先在这里我称之为RatingBar这是我在小部件内标记的302行

When scrolling then to Page 2 and again press on the single icon to see the RatingBar the error is away.First here is where I call the RatingBarthis is the line 302 I marked inside the widget

 Container(
                            child: Row(
                              mainAxisAlignment: MainAxisAlignment.end,
                              children: [
                                Container(
                                  width: 240,
                                  height: 94,
                                  child: Column(hereeeeeee throwssss the errrooororooror
                                    children: [
                                      InkWell(
                                        onTap: () {
                                          setState(() {
                                            israting = true;
                                          });
                                        },
                                        child: israting
                                            ? _buildBody(videos.data()['likes'],
                                                videos.data()['id'])
                                            : Icon(
                                                Icons.star,
                                                size: 37,
                                                color: videos

第374行是我再次标记的行

The line 374 is this line I marked it again

Widget _buildBody(videoid, video) {
    if (videoid.contains(uid)) {
      FirebaseFirestore.instance
          .collection("videos")
          .doc(video)
          .collection("uservotes")
          .doc(uid)
          .get()
          .then((value) {
        votefromfirebase = value.data()["rating"];
      });
      return Container( This is the lineeeeeeeeeeeeee
          child: Stack(
        children: [
          Padding(
            padding: const EdgeInsets.fromLTRB(3, 7, 0, 0),
            child: Align(
              alignment: Alignment.topLeft,
              child: RatingBarIndicator(
                rating: votefromfirebase,
                itemBuilder: (context, index) => InkWell(
                  child: Icon(
                    Icons.star,

错误是什么意思?我该如何解决?

What does the error mean ? And how can I fix that ?

推荐答案

删除 .doc(uid),然后重试:

Widget _buildBody(videoid, video) {
    if (videoid.contains(uid)) {
      FirebaseFirestore.instance
          .collection("videos")
          .doc(video)
          .collection("uservotes")
          .doc(uid) //<--- remove this
          .get()
          .then((value) {
        votefromfirebase = value.data()["rating"];
      });
      return Container( This is the lineeeeeeeeeeeeee
          child: Stack(
        children: [
          Padding(
            padding: const EdgeInsets.fromLTRB(3, 7, 0, 0),
            child: Align(
              alignment: Alignment.topLeft,
              child: RatingBarIndicator(
                rating: votefromfirebase,
                itemBuilder: (context, index) => InkWell(
                  child: Icon(
                    Icons.star,

这篇关于截断是否在null上被调用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 12:36