import 'package:flutter/material.dart';
import 'package:notes/db/database_provider.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
initialRoute: "/",
routes: {
"/":(context)=>HomeScreen()
},
);
}
}
class HomeScreen extends StatefulWidget {
const HomeScreen({Key? key}) : super(key: key);
@override
State<HomeScreen> createState() => _HomeScreenState();
}
class _HomeScreenState extends State<HomeScreen> {
getNotes()async{
final notes = await DatabaseProvider.db.getNotes();
return notes;
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Notes"),
),
body: FutureBuilder(
future: getNotes(),
builder: (context,noteData){
switch(noteData.connectionState){
case ConnectionState.waiting:
{
return Center(child: CircularProgressIndicator(),);
}
case ConnectionState.done:
{
if(noteData.data !=null){
return Padding(
padding: const EdgeInsets.all(8.0),
child: ListView.builder(
itemCount:noteData.data!.length,
itemBuilder: (context,index){
String title=noteData.data[index]['title'];
},
),
);
}
else {
return Center(
child: Text("You don't have any notes yet,create one?"),
);
}
}
}
},
),
);
}
}
So, I am making a notes app using SQF lite taking guidance from DocorCode on youtube, i wrote the same code but its showing some errors related to null checks and i am unable to bypass them not matter what.
no matter what I do add null checks or anything it always shows error , is there anyway to switch off the null check , Please tell me how to fix the problem.