This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar( | |
title: Text(widget.title), | |
centerTitle: true, | |
elevation: 0, | |
), | |
body: Column( | |
children: [ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, |