Skip to content

Instantly share code, notes, and snippets.

@raushankrjha
Created October 2, 2019 20:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raushankrjha/0c7dfd717d5193ba2b39dda7eea1c461 to your computer and use it in GitHub Desktop.
Save raushankrjha/0c7dfd717d5193ba2b39dda7eea1c461 to your computer and use it in GitHub Desktop.
import 'dart:async';
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
void main() => runApp(new MyApp());
String username='';
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Flutter App with MYSQL',
home: new MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
TextEditingController name=new TextEditingController();
TextEditingController email=new TextEditingController();
TextEditingController mobile=new TextEditingController();
Future<List> senddata() async {
final response = await http.post("http://raushanjha.in/insertdata.php", body: {
"name": name.text,
"email": email.text,
"mobile":mobile.text,
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text("Register"),),
body: Container(
child: Center(
child: Column(
children: <Widget>[
Text("Username",style: TextStyle(fontSize: 18.0),),
TextField(
controller: name,
decoration: InputDecoration(
hintText: 'name'
),
),
Text("Email",style: TextStyle(fontSize: 18.0),),
TextField(
controller: email,
decoration: InputDecoration(
hintText: 'Email'
),
),
Text("Mobile",style: TextStyle(fontSize: 18.0),),
TextField(
controller: mobile,
decoration: InputDecoration(
hintText: 'Mobile'
),
),
RaisedButton(
child: Text("Register"),
onPressed: (){
senddata;
},
),
],
),
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment