Watch Full Video:
Step 1:
Create A new Dart File, Give name as RetrieveData.dart and paste code in that:
Code:
import 'package:flutter/material.dart';
import 'package:shape_of_view/shape_of_view.dart';
import 'package:sqlite_database_tutorial/ModelClass.dart';
import 'package:sticky_headers/sticky_headers/widget.dart';
import 'DatabaseHelper.dart';
class RetrieveData extends StatefulWidget {
@override
_RetrieveDataState createState() => _RetrieveDataState();
}
class _RetrieveDataState extends State {
List list=new List();
final dbHelper = DatabaseHelper.instance;
ModelClass1 model;
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.black26,
appBar: AppBar(
backgroundColor: Colors.black,
title: Text("Student Record",
style: TextStyle(
color: Colors.white,
),
),
),
body: Container(
child: gridHeader(),
decoration: new BoxDecoration(
color: Colors.black,
image: new DecorationImage(
fit: BoxFit.cover,
colorFilter: new ColorFilter.mode(Colors.grey.withOpacity(1), BlendMode.dstATop),
image: new AssetImage(
"asset/bg00.jpg"
),
),
),
),
);
}
fetch() async {
final allRows = await dbHelper.queryAllRows();
allRows.forEach((row) => {
model=ModelClass1(row["name"],row["email"],row["password"],row["_id"]),
list.add(model)
});
setState(() {
});
}
List listHeader = ['Student Record'];
Widget gridHeader(){
return list.length==0? Center(
child: Text("No Data Insert",
style: TextStyle(color: Colors.white,
fontSize: 20,
),
),
):
new ListView.builder(
itemCount: listHeader.length,
itemBuilder: (context, index) {
return new StickyHeader(
header: new Container(
height: 38.0,
color: Colors.transparent,
padding: new EdgeInsets.symmetric(horizontal: 12.0),
alignment: Alignment.centerLeft,
child: new Text(listHeader[index],
style: const TextStyle(color: Colors.white, fontSize: 20,fontWeight: FontWeight.bold),
),
),
content: Container(
child: Card(
color: Colors.transparent,
child: GridView.builder(
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
itemCount: list.length,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2,childAspectRatio: 1,),
itemBuilder: (contxt, indx){
return Card(
color: Colors.transparent,
child: ShapeOfView(
shape: BubbleShape(
position: BubblePosition.Bottom,
arrowPositionPercent: 0.5,
borderRadius: 20,
arrowHeight: 10,
arrowWidth: 10
),
child: Container(
color: Colors.blueGrey,
child: Column(
children:[
Center(
child:
Text(list[indx].name, style: TextStyle(
fontSize: 25,
fontWeight: FontWeight.bold,
fontFamily: 'DancingScript',
color: Colors.blue[900],
),
),
),
Text(list[indx].pass.toString(), style: TextStyle(
fontSize: 18,
color: Colors.white
),
),
Text(list[indx].email, style: TextStyle(
fontSize: 18,
fontFamily: 'DancingScript',
color: Colors.white
),
),
SizedBox(
height: 10,
),
ShapeOfView(
height: 40,
width: 40,
shape: StarShape(
noOfPoints: 6,
),
child: Container(
color: Colors.blue[900],
child:Center(
child: Text(list[indx].key.toString(),
style: TextStyle(
color: Colors.white,
),
),
)
)
)
],
),
),
),
);
}
),
),
),
);
}
);
}
@override
void initState() {
fetch();
}
}
OUTPUT:
Step 1:
Create A new Dart File, Give name as RetrieveData.dart and paste code in that:
Code:
import 'package:flutter/material.dart';
import 'package:shape_of_view/shape_of_view.dart';
import 'package:sqlite_database_tutorial/ModelClass.dart';
import 'package:sticky_headers/sticky_headers/widget.dart';
import 'DatabaseHelper.dart';
class RetrieveData extends StatefulWidget {
@override
_RetrieveDataState createState() => _RetrieveDataState();
}
class _RetrieveDataState extends State
List
final dbHelper = DatabaseHelper.instance;
ModelClass1 model;
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.black26,
appBar: AppBar(
backgroundColor: Colors.black,
title: Text("Student Record",
style: TextStyle(
color: Colors.white,
),
),
),
body: Container(
child: gridHeader(),
decoration: new BoxDecoration(
color: Colors.black,
image: new DecorationImage(
fit: BoxFit.cover,
colorFilter: new ColorFilter.mode(Colors.grey.withOpacity(1), BlendMode.dstATop),
image: new AssetImage(
"asset/bg00.jpg"
),
),
),
),
);
}
fetch() async {
final allRows = await dbHelper.queryAllRows();
allRows.forEach((row) => {
model=ModelClass1(row["name"],row["email"],row["password"],row["_id"]),
list.add(model)
});
setState(() {
});
}
List
Widget gridHeader(){
return list.length==0? Center(
child: Text("No Data Insert",
style: TextStyle(color: Colors.white,
fontSize: 20,
),
),
):
new ListView.builder(
itemCount: listHeader.length,
itemBuilder: (context, index) {
return new StickyHeader(
header: new Container(
height: 38.0,
color: Colors.transparent,
padding: new EdgeInsets.symmetric(horizontal: 12.0),
alignment: Alignment.centerLeft,
child: new Text(listHeader[index],
style: const TextStyle(color: Colors.white, fontSize: 20,fontWeight: FontWeight.bold),
),
),
content: Container(
child: Card(
color: Colors.transparent,
child: GridView.builder(
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
itemCount: list.length,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2,childAspectRatio: 1,),
itemBuilder: (contxt, indx){
return Card(
color: Colors.transparent,
child: ShapeOfView(
shape: BubbleShape(
position: BubblePosition.Bottom,
arrowPositionPercent: 0.5,
borderRadius: 20,
arrowHeight: 10,
arrowWidth: 10
),
child: Container(
color: Colors.blueGrey,
child: Column(
children:
Center(
child:
Text(list[indx].name, style: TextStyle(
fontSize: 25,
fontWeight: FontWeight.bold,
fontFamily: 'DancingScript',
color: Colors.blue[900],
),
),
),
Text(list[indx].pass.toString(), style: TextStyle(
fontSize: 18,
color: Colors.white
),
),
Text(list[indx].email, style: TextStyle(
fontSize: 18,
fontFamily: 'DancingScript',
color: Colors.white
),
),
SizedBox(
height: 10,
),
ShapeOfView(
height: 40,
width: 40,
shape: StarShape(
noOfPoints: 6,
),
child: Container(
color: Colors.blue[900],
child:Center(
child: Text(list[indx].key.toString(),
style: TextStyle(
color: Colors.white,
),
),
)
)
)
],
),
),
),
);
}
),
),
),
);
}
);
}
@override
void initState() {
fetch();
}
}
OUTPUT: