This file contains hidden or 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
dependencies: | |
flutter: | |
sdk: flutter | |
flutter_bloc: ^3.2.0 | |
meta: ^1.1.6 | |
equatable: ^1.1.0 | |
http: ^0.12.0+4 | |
sqflite: ^1.3.0 | |
path_provider: ^1.6.5 | |
# The following adds the Cupertino Icons font to your application. |
This file contains hidden or 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:async'; | |
import 'dart:io'; | |
import 'package:path/path.dart'; | |
import 'package:path_provider/path_provider.dart'; | |
import 'package:sqflite/sqflite.dart'; | |
final userTable = 'userTable'; | |
class DatabaseProvider { |
This file contains hidden or 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
class User { | |
int id; | |
String username; | |
String token; | |
User( | |
{this.id, | |
this.username, | |
this.token}); |
This file contains hidden or 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:async'; | |
import 'dart:convert'; | |
import 'package:http/http.dart' as http; | |
import 'package:bloc_login/model/api_model.dart'; | |
final _base = "https://home-hub-app.herokuapp.com"; | |
final _tokenEndpoint = "/api-token-auth/"; | |
final _tokenURL = _base + _tokenEndpoint; | |
Future<Token> getToken(UserLogin userLogin) async { |
This file contains hidden or 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
class UserLogin { | |
String username; | |
String password; | |
UserLogin({this.username, this.password}); | |
Map <String, dynamic> toDatabaseJson() => { | |
"username": this.username, | |
"password": this.password | |
}; |
This file contains hidden or 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 'package:bloc_login/database/user_database.dart'; | |
import 'package:bloc_login/model/user_model.dart'; | |
class UserDao { | |
final dbProvider = DatabaseProvider.dbProvider; | |
Future<int> createUser(User user) async { | |
final db = await dbProvider.database; | |
var result = db.insert(userTable, user.toDatabaseJson()); |
This file contains hidden or 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
part of 'authentication_bloc.dart'; | |
abstract class AuthenticationState extends Equatable { | |
@override | |
List<Object> get props => []; | |
} | |
class AuthenticationUnintialized extends AuthenticationState {} | |
class AuthenticationAuthenticated extends AuthenticationState {} |
This file contains hidden or 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
part of 'authentication_bloc.dart'; | |
abstract class AuthenticationEvent extends Equatable { | |
const AuthenticationEvent(); | |
@override | |
List<Object> get props => []; | |
} | |
class AppStarted extends AuthenticationEvent {} |
This file contains hidden or 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:async'; | |
import 'package:bloc/bloc.dart'; | |
import 'package:meta/meta.dart'; | |
import 'package:equatable/equatable.dart'; | |
import 'package:bloc_login/repository/user_repository.dart'; | |
import 'package:bloc_login/model/user_model.dart'; | |
part 'authentication_event.dart'; |
This file contains hidden or 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 'package:flutter/material.dart'; | |
class SplashPage extends StatelessWidget { | |
@override | |
Widget build (BuildContext context) { | |
return Scaffold( | |
body: Center( | |
child: Text('Splash Screen'), | |
), | |
); |
OlderNewer