Databases are used extremely often in app and they are used to store data. For example usernames and passwords. Or things like posts, or articles that users write on your app.
Today we will be covering four topics: I will be showing you how to make TextFormFields, what voids are, what maps are, and how to build a basic database that works using flutter.
First start out by importing material.dart and creating a class called Login with an app bar that says “Login”:
import 'package:flutter/material.dart';
class Login extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text("Login"))
);
}
}
Then add two Strings to store the username and password:
import 'package:flutter/material.dart';
class Login extends StatelessWidget {
String username;
String password;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text("Login"))
);
}
}
The reason why I didn’t put anything in the variables is because we are going to put in the username and password later.
After that we need to add something that will help validate the username and password you enter in.
Now, this is the complicated part. We need to write out the code that makes sure you put in the right username and password. So we are going to make a void.
Now we have everything we need to start building the UI of our Login page! What we are going to build is a ListView that has an image, two TextFormFields and one button you click when you are done filling out your username and password inside a Form widget. First let’s add the image. Assuming you have everything settled with making the images folder and setting things up in Pubspec.yaml, add this code: