Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
680 views
in Technique[技术] by (71.8m points)

firebase - Flutter Error: Another exception was thrown: Instance of 'DiagnosticsProperty<void>' .It is showing a blank screen when redirected to that page

Flutter Error: Another exception was thrown: Instance of 'DiagnosticsProperty' .It is showing a blank screen when redirected to that page.

I have successfully uploaded the text items , one image and one pdf to the firebase database and able to retrieve all of them in cards Widget view and List Tiles View Now I am trying to get individual view when clicked on List Items from List view.

Please check my code , I am seeing a blank screen when tried to redirect to the required Retrievepage.

                                  RetrievePage.dart


                                     
import 'dart:async';
import 'dart:io';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:firebase_database/firebase_database.dart';
import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:gadjet_inventory/Form/ListTileFeed.dart';
import 'package:gadjet_inventory/Form/ListTiles.dart';
import 'package:gadjet_inventory/main.dart';
import 'package:intl/intl.dart';
import 'package:gadjet_inventory/Form/Data.dart';


import 'package:gadjet_inventory/Form/UploadData.dart';

import 'package:pdf_flutter/pdf_flutter.dart';
// ignore: must_be_immutable
import 'package:url_launcher/url_launcher.dart';

import 'Data.dart';

class RetrievePage extends StatefulWidget {

//  String currentEmail;

  //RetrievePage(this.currentEmail);

  @override
  _RetrievePageState createState() => _RetrievePageState();
}

class _RetrievePageState extends State<RetrievePage> {
  List<Data> dataList = [];
  List<bool> favList = [];
  bool searchState = false;
  FirebaseAuth auth = FirebaseAuth.instance;





  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    DatabaseReference referenceData = FirebaseDatabase.instance.reference().child("Data");
    referenceData.once().then((DataSnapshot dataSnapShot) {
      dataList.clear();
      favList.clear();

      var keys = dataSnapShot.value.keys;
      var values = dataSnapShot.value;

      for (var key in keys) {

        Data data = new Data(
            values [key]['imgUrl'],
          
            values [key]['cattegorrytype'],
            values [key]['companyname'],
            values [key]['modelname'],
            values [key]['seriesname'],
            values [key]['serielnumber'],
            values [key]['year'],
            

            key
          //key is the uploadid
        );
        dataList.add(data);
        auth.currentUser().then((value) {
          DatabaseReference reference = FirebaseDatabase.instance.reference().child("Data").child(key).child("Fav")
              .child(value.uid).child("state");
          reference.once().then((DataSnapshot snapShot){
            if(snapShot.value!=null){
              if(snapShot.value=="true"){
                favList.add(true);
              }else{
                favList.add(false);
              }
            }else{
              favList.add(false);
            }
          });
        });

      }


      Timer(Duration(seconds: 1),(){
        setState(() {
          //
        });
      });


    });


  }


  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(
          "List View",
        ),
        actions: <Widget>[
          // action button

        ],
      ),
      body: Center(

        child: Container(
         child: ListView.separated(
        itemBuilder: (BuildContext context, int index) {
        Column(
            children: <Widget>[
              Image.network(
                dataList[index].imgUrl != null
                    ? dataList[index].imgUrl
                    : '',
                width: 500,
                height: 500,

              ),

              Row(
                mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                children: <Widget>[
                  Expanded(
                    flex: 1,
                    child: Padding(
                      padding: const EdgeInsets.all(8.0),

                          child: Text(  "Cattegorry Type:- "
                          "$dataList[index].cattegorrytype",

                           style: TextStyle(color: Colors.black),

 
                      ),


                    ),
                  ),
                ],
              ),


              Row(
                mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                children: <Widget>[
                  Expanded(
                    flex: 1,
                    child: Padding(
                      padding: const EdgeInsets.all(8.0),
                      child: Theme(
                        data: ThemeData(
                          hintColor: Colors.blue,
                        ),

                        child: Text(  "Company Name:- "
                            "$dataList[index].companyname",
   
                          style: TextStyle(color: Colors.black),

                            ),
                      ),
                    ),
                  ),
  

                  Expanded(
                    flex: 1,
                    child: Padding(
                      padding: const EdgeInsets.all(8.0),
                      child: Theme(
                        data: ThemeData(
                          hintColor: Colors.blue,
                        ),

                        child: Text(  "Model Name:- "
                            "$dataList[index].modelname",

                             style: TextStyle(color: Colors.black),
   
                        ),
                      ),
                    ),
                  ),

                ],
              ),

              Row(
                mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                children: <Widget>[
                  Expanded(
                    flex: 1,
                    child: Padding(
                      padding: const EdgeInsets.all(8.0),
                      child: Theme(
                        data: ThemeData(
                          hintColor: Colors.blue,
                        ),

                        child: Text(  "Series Name:- "
                            "$dataList[index].seriesname",

                             style: TextStyle(color: Colors.black),

  
                        ),
                    ),
                    ),
                  ),
   
                  Expanded(
                    flex: 1,
                    child: Padding(
                      padding: const EdgeInsets.all(8.0),
                      child: Theme(
                        data: ThemeData(
                          hintColor: Colors.blue,
                        ),

                        child: Text(  "Year Of MFG:- "
                            "$dataList[index].year",
  

                          style: TextStyle(color: Colors.black),

   
                        ),
                      ),
                    ),
                  ),

                ],
              ),

               
            ],
        );
        },
       ),
        ),


      ),





    );
  }
    
  }

Please fix my issue why I am seeing a blank screen with the error "Another exception was thrown: Instance of 'DiagnosticsProperty'"

question from:https://stackoverflow.com/questions/65883681/flutter-error-another-exception-was-thrown-instance-of-diagnosticspropertyvo

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...