簡體   English   中英

Flutter - 類型“BoxDecoration”不是類型“小部件”的子類型

[英]Flutter - type 'BoxDecoration' is not a subtype of type 'Widget'

 FutureBuilder(
    //UserData from DB
    future: getUserData(),
    builder: (BuildContext context, AsyncSnapshot<FirebaseUser> snapshot) {
      if (snapshot.hasData) {
        return new Column(
          children: <Widget>[
            Container(
              height: 200.0,
              decoration: BoxDecoration(
                gradient: LinearGradient(
                  begin: Alignment.topCenter,
                  end: Alignment.bottomCenter,
                  colors: [Color(0xFF051622), Color(0xFF1BA098)],
                ),
                borderRadius: BorderRadius.only(
                  bottomLeft: Radius.circular(15.0),
                  bottomRight: Radius.circular(15.0),
                ),
              ),
              child: Column(
                mainAxisSize: MainAxisSize.min,
                crossAxisAlignment: CrossAxisAlignment.start,
                children: <Widget>[
                  Row(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: <Widget>[
                      Padding(
                        padding:
                            const EdgeInsets.only(top: 18.0, left: 12.0),
                        child: GestureDetector(
                          child: CircleAvatar(
                            radius: 30.0,
                            backgroundColor: Colors.white,
                            child: (_imageFile != null)
                                ? BoxDecoration(///This is where error happens
                                    shape: BoxShape.circle,
                                    image: DecorationImage(
                                        image: FileImage(_imageFile),
                                        fit: BoxFit.fill),
                                  )
                                : Icon(Icons.add_a_photo),//Replace with Image From DB
                          ),
                          onTap: () {
                            _getImage();
                          },
                        ),
                      ),
                      Expanded(
                        child: Padding(
                          padding: const EdgeInsets.only(
                              left: 20.0, right: 75.0, top: 20.0),
                          child: TextField(
                            decoration: InputDecoration(
                              enabledBorder: UnderlineInputBorder(
                                borderSide: BorderSide(
                                  color: Color(0xFF1BA098),
                                ),
                              ),
                              focusedBorder: UnderlineInputBorder(
                                borderSide: BorderSide(
                                  color: Color(0xFFDEB992),
                                ),
                              ),
                              hintText:
                                  "${snapshot.data.displayName}", //Name comes from db as displayName
                              hintStyle: TextStyle(
                                  color: Colors.white, fontSize: 18.0),
                            ),
                            style: TextStyle(
                                color: Colors.white, fontSize: 18.0),
                            controller: newName,
                          ),
                        ),
                      ),
                    ],
                  ),
                  Padding(
                    padding: const EdgeInsets.only(top: 12.0, left: 20.0),
                    child: Text(
                      "${snapshot.data.email}", //Email from DB as email
                      style: TextStyle(
                          color: Colors.white,
                          fontSize: 16.0,
                          fontWeight: FontWeight.bold),
                    ),
                  ),
                  Padding(
                    padding: const EdgeInsets.only(top: 7.0, left: 18.0),
                    child: Text(
                      "${snapshot.data.phoneNumber}", //Number from DB as phoneNumber
                      style: TextStyle(
                          color: Colors.white,
                          fontSize: 16.0,
                          fontWeight: FontWeight.bold),
                    ),
                  ),
                  Row(
                    children: <Widget>[
                      Padding(
                        padding:
                            const EdgeInsets.only(top: 10.0, left: 18.0),
                        child: Icon(
                          Icons.star_border,
                          size: 30.0,
                          color: Colors.amber,
                        ),
                      ),
                      Padding(
                        padding:
                            const EdgeInsets.only(top: 15.0, left: 2.0),
                        child: Text(
                          "0.0", //Rating from db for user
                          style: TextStyle(
                              color: Colors.white,
                              fontSize: 15.0,
                              fontWeight: FontWeight.bold,
                              fontStyle: FontStyle.italic),
                        ),
                      ),
                      Padding(
                        padding: const EdgeInsets.only(
                            top: 8.0,
                            left:
                                200.0), 
                       child: ArgonTimerButton(
                          borderRadius: 50.0,
                          color: Colors.greenAccent,
                          height: 35.0,
                          width: 100.0,
                          child: Text(
                            "Update",
                            style: TextStyle(
                              fontSize: 15.0,
                              fontWeight: FontWeight.w700,
                              color: Colors.black,
                            ),
                          ),
                          loader: (time) {
                            return Container(
                              padding: EdgeInsets.all(10.0),
                              child: SpinKitRing(
                                color: Color(0xFF1BA098),
                                lineWidth: 3.0,
                                size: 20.0,
                              ),
                            );
                          },
                          onTap: (startTimer, btnState) {
                            startTimer(6);
                            verifyDetails();
                          },
                        ),
                      ),
                    ],
                  ),
                ],
              ),
            ),
          ],
        );
      }
    },
  ),

整個身體在FutureBuilder (從 Firebase 獲取數據到 snapShot 中)

錯誤是

════════ 小部件庫捕獲的異常═════════════════════════════␕══

'BoxDecoration' 類型不是 'Widget' 類型的子類型 相關的導致錯誤的小部件是 FutureBuilder lib\mainScreens\Profile.dart:37 ════════════╕══␐════════════════════ ══════════════════════════════════════════════════ ══════

Pranavan BoxDecoration不是由Container包裝的小部件,如下所示:

Container(
   decoration: BoxDecoration( ///This is where error happens
   shape: BoxShape.circle,
   image: DecorationImage(
          image: FileImage("_imageFile"), fit: BoxFit.fill),
       ),
),

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM