vince-nyanga / flutter_bloc_authentication Goto Github PK
View Code? Open in Web Editor NEWA simple Flutter application that showcases how to use the BLoC pattern to build an authentication flow.
A simple Flutter application that showcases how to use the BLoC pattern to build an authentication flow.
i loggedin and i can see home page but i closed app and i opened app again its showing login page ,, i need to see home page , how to handle it ?
I am trying to modify services/authentication_service.dart as i am trying to use Json for authentication but my authentication returns user information null. Here is my code
` Future signIn(String email, String password) async {
WidgetsFlutterBinding.ensureInitialized();
final http.Response response = await http.post("$SERVER_IP/rest-auth/login/",
body: jsonEncode(<String, String>{
'email':email,
'password':password,
}),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
HttpHeaders.authorizationHeader: "9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b",
},
);
if (response.statusCode == 200) {
print(response.body);
return User.fromJSON(json.decode(response.body));
}
else {
throw AuthenticationException(message: 'Wrong email or password');
}
}
`
The data returns something like this
"user": { "id": "id here", "email": "[email protected]", "username": "userabc", }
The authentication is fine, i can get the data successfully but data is null when i try to decode it in User.
How can i return User() the way that it returns the JSON data?
Hi ,Could you explain why you use nested blocbuider in your project ?Is it really necessary? I mean in main.dart and login_page.dart you use
BlocBuilder<AuthenticationBloc, AuthenticationState>
. Why don't you check the state condition all in blocbuilder in main.dart ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.