1. main.dart에서 database instance 만들어서 사용
- final database = LocalDataBase();
2. 만드었던 함수 사용
- insert 시, Value()로 감싸서 넣어줘야 함
const DEFAULT_COLORS = [
'F44336',
'FF9800',
'FFEB3B',
];
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await initializeDateFormatting();
final database = LocalDataBase();
final colors = await database.getCategoryColors();
if (colors.isEmpty) {
for (String hexCode in DEFAULT_COLORS) {
await database.createCategoryColor(
CategoryColorsCompanion(
hexCode: Value(hexCode),
),
);
}
}
print(await database.getCategoryColors());
runApp(MaterialApp(
home: HomeScreen(),
));
}