Notes Page
Notes Page
dart';
import 'new_note.dart';
import 'note_details.dart';
import 'database_helper.dart';
@override
State<Notes> createState() => NotesState();
}
@override
void initState() {
super.initState();
// TODO: implement initState
print("initState");
}
@override
Scaffold build(BuildContext context) {
return Scaffold(
appBar: AppBar(
centerTitle: true,
backgroundColor: Colors.grey,
leading: const Icon(
Icons.book_outlined,
color: Colors.black,
size: 30,
),
title: const Text(
"All Notes",
style: TextStyle(color: Colors.black),
),
actions: [
IconButton(
onPressed: () async {
notes = await DBHelper.getDataFromDB();
if (notes != null || notes!.isNotEmpty) {
isDBEmpty = false;
} else {
isDBEmpty = true;
}
setState(() {});
},
icon: const Icon(
Icons.refresh,
color: Colors.black,
))
],
),
body: SingleChildScrollView(
child: Container(
width: double.infinity,
padding: const EdgeInsets.all(10),
color: Colors.white,
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Container(
padding: const EdgeInsets.all(10),
width: 280,
height: 50,
decoration: BoxDecoration(
color: Colors.grey[200],
borderRadius: BorderRadius.circular(50),
border: Border.all(color: Colors.grey),
),
child: const Row(
children: [
Icon(Icons.search, size: 22, color: Colors.grey),
SizedBox(width: 20),
Text("Search", style: TextStyle(color: Colors.grey)),
],
),
),
const SizedBox(
height: 40,
),
ListView.builder(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
itemCount: notes!.length,
itemBuilder: (context, index) {
isFavourite.add(false);
return noteItem(index, notes![index]);
},
)
],
),
),
),
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
floatingActionButton: Padding(
padding: const EdgeInsets.all(50.0),
child: FloatingActionButton(
onPressed: () async {
result = await Navigator.push(
context,
MaterialPageRoute(builder: (context) {
return NewNote();
}),
);
await DBHelper.insertToDB(result[0], result[1]);
},
backgroundColor: Colors.grey[200],
child: const Icon(
Icons.add,
color: Colors.grey,
size: 30,
),
),
),
);
}