Skip to content

Instantly share code, notes, and snippets.

View ericgrandt's full-sized avatar

Eric ericgrandt

View GitHub Profile
newUser(User user) async {
final db = await database;
var res = await db.insert('user', user.toJson());
return res;
}
getUser(int id) async {
final db = await database;
var res = await db.query('user', where: 'id = ?', whereArgs: [id]);
import 'dart:convert';
User userFromJson(String str) {
final jsonData = json.decode(str);
return User.fromJson(jsonData);
}
String userToJson(User data) {
final dyn = data.toJson();
return json.encode(dyn);
import 'dart:io';
import 'package:sqflite/sqflite.dart';
import 'package:path_provider/path_provider.dart';
import 'package:path/path.dart';
class DBProvider {
DBProvider._();
static final DBProvider db = DBProvider._();
Database _database;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(
widget.title,
),
backgroundColor: Theme.of(context).accentColor,
textTheme: Theme.of(context).accentTextTheme,
centerTitle: true,
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
centerTitle: true,
elevation: 0,
),
body: Column(
children: [
ThemeData(
brightness: Brightness.light,
backgroundColor: Colors.blueGrey[50],
primarySwatch: Colors.blueGrey,
primaryColor: Colors.blueGrey[50],
primaryColorDark: Colors.grey[900],
accentColor: Colors.grey[900],
fontFamily: 'Poppins',
primaryTextTheme: Typography.blackCupertino,
accentTextTheme: Typography.whiteCupertino,