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
1.3k views
in Technique[技术] by (71.8m points)

firebase - Flutter:How to convert Cards UI or View to Individual View Please find the HomeScreen Page code and try to convert to detailed individual view

Flutter:How to convert Cards UI or View to Individual View Please find the HomeScreen Page code and try to convert to detailed individual view

                                            import 'dart:async';

import 'package:firebase_auth/firebase_auth.dart';
import 'package:firebase_database/firebase_database.dart';
import 'package:flutter/material.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 'UploadData.dart';

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




class HomeScreen extends StatefulWidget {

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

class _HomeScreenState extends State<HomeScreen> {




  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]['wcpdfUrl'],
            values [key]['ugpdfUrl'],
            values [key]['cattegorrytype'],
            values [key]['companyname'],
            values [key]['modelname'],
            values [key]['seriesname'],
            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(() {
          //
        });
      });


    });


  }

  int selectedRadioTile;

  String get path => null;

  String get title => null;

  setSelectedRadioTile(int val) {
    setState(() {
      selectedRadioTile = val;
    });
  }


  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.lightGreen,
      //Color(0xffffffff),
      appBar: AppBar(
        centerTitle: true,
        backgroundColor: Colors.blue,
        title: new Text("Device Details", style:
        TextStyle(fontSize: 20), textAlign: TextAlign.center),

        actions: <Widget>[
          IconButton(icon: Icon(Icons.refresh, size: 36, color: Colors.white,),
            onPressed: () {
              //debugPrint("Add New Device Cattegorry");
              Navigator.push(context, MaterialPageRoute(builder: (context) {
                return ListTiles();
              }
              )
              ); //
            },
          ),
          IconButton(icon: Icon(Icons.home, size: 36, color: Colors.white,),
            onPressed: () {
              //debugPrint("Add New Device Cattegorry");
              Navigator.push(context, MaterialPageRoute(builder: (context) {
                return MyHomePage();
              }
              )
              ); //
            },
          )
        ],),

      body: dataList.length == 0
          ? Center(
          child: Text("No Data Available", style: TextStyle(fontSize: 30),))
          : ListView.builder(
          itemCount: dataList.length,
          itemBuilder: (_, index) {
            return CardUI(dataList[index].imgUrl,dataList[index].wcpdfUrl, dataList[index].cattegorrytype,
                dataList[index].companyname, dataList[index].modelname,dataList[index].seriesname,dataList[index].year,
                dataList[index].uploadid,index);
          }
      ),
    );
  }



  Widget CardUI(String imgUrl, String wcpdfUrl,String cattegorrytype, String companyname, String modelname,
      String seriesname, String year ,
      String uploadId,int index) {
    return Card(
      elevation: 7,
      margin: EdgeInsets.all(15),
      //color: Color(0xffff2fc3),
      color:Colors.blueGrey,
      child: Container(
        color: Colors.white,
        margin: EdgeInsets.all(1.5),
        padding: EdgeInsets.all(10),
        child: Column(
          children: <Widget>[
            Image.network(
              imgUrl != null
                  ? 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:- "
                             "$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:- "
                        "$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:- "
                          "$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:- "
                          "$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:- "
                          "$year",

                       style: TextStyle(color: Colors.black),


                    ),
                    ),
                  ),
                ),

              ],
            ),

         

            RaisedButton(


              shape: RoundedRectangleBorder(
                borderRadius: BorderRadius.circular(10),
              ),

              color: Colors.blue,
              child: Text("Warranty Card",
                style: TextStyle(fontSize: 18, color: Colors.white),),
            ),
            RadioListTile(
              value: 1,
              groupValue: selectedRadioTile,
              title: Text("PDF"),
              //subtitle: Text("Upload PDF File"),
              /*  onChanged: (val) {
                        filePicker(context);
                      },*/
              activeColor: Colors.red,


            ),

            Padding(padding: EdgeInsets.only(top: 15)),

          //  _buildPDF1Field(context),



            PDF.network(
              wcpdfUrl != null
                  ? wcpdfUrl
                  : '',

              width: 600,
              height: 1000,     placeHolder: Image.asset("assets/images/pdf.png",
                height: 600, width: 500),
            ),
            SizedBox(height: 24),


          ],
        ),
      ),
    );
  }

I have uploaded few text items one imageUrl and one pdf document to firebase storage and able to retrieve them in HomeScreen View (card UI or View (cards list) and List Tile View( with one image and one text, when tapped on it should show each individual view).

Please guide me How to convert to Individual Retrieving page instead of group of vertical cards list.

question from:https://stackoverflow.com/questions/65858991/flutterhow-to-convert-cards-ui-or-view-to-individual-view-please-find-the-homes

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
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

...