2 Commity b5c79b54a3 ... 088e067260

Autor SHA1 Wiadomość Data
  Anand Ayyappan 088e067260 Merge branch 'dev' of http://git.665463.xyz:8443/anand/kprovider into dev 1 rok temu
  Anand Ayyappan 37cdd01b89 Registration Screen Added 1 rok temu
3 zmienionych plików z 108 dodań i 0 usunięć
  1. 79 0
      lib/views/registration_screen.dart
  2. 28 0
      pubspec.lock
  3. 1 0
      pubspec.yaml

+ 79 - 0
lib/views/registration_screen.dart

@@ -0,0 +1,79 @@
+// ignore_for_file: library_private_types_in_public_api
+
+import 'dart:convert';
+import 'package:flutter/material.dart';
+import 'package:http/http.dart' as http;
+
+class RegistrationScreen extends StatefulWidget {
+  static const routeName = 'registrationScreen';
+
+  const RegistrationScreen({super.key});
+  @override
+  _RegistrationScreenState createState() => _RegistrationScreenState();
+}
+
+class _RegistrationScreenState extends State<RegistrationScreen> {
+  final TextEditingController _usernameController = TextEditingController();
+  final TextEditingController _emailController = TextEditingController();
+  final TextEditingController _passwordController = TextEditingController();
+
+  Future<void> _registerUser() async {
+    const String apiUrl = 'YOUR_API_ENDPOINT'; // Replace with your API endpoint
+
+    final response = await http.post(
+      Uri.parse(apiUrl),
+      headers: {'Content-Type': 'application/json'},
+      body: jsonEncode({
+        'username': _usernameController.text.trim(),
+        'email': _emailController.text.trim(),
+        'password': _passwordController.text.trim(),
+      }),
+    );
+
+    if (response.statusCode == 201) {
+      // User registration successful
+      print('User registered successfully');
+    } else {
+      // Handle registration errors
+      print('Error during registration: ${response.statusCode}');
+      print('Response body: ${response.body}');
+    }
+  }
+
+  @override
+  Widget build(BuildContext context) {
+    return Scaffold(
+      appBar: AppBar(
+        title: const Text('User Registration'),
+      ),
+      body: Padding(
+        padding: const EdgeInsets.all(16.0),
+        child: Column(
+          mainAxisAlignment: MainAxisAlignment.center,
+          children: [
+            TextField(
+              controller: _usernameController,
+              decoration: const InputDecoration(labelText: 'Username'),
+            ),
+            const SizedBox(height: 16.0),
+            TextField(
+              controller: _emailController,
+              decoration: const InputDecoration(labelText: 'Email'),
+            ),
+            const SizedBox(height: 16.0),
+            TextField(
+              controller: _passwordController,
+              decoration: const InputDecoration(labelText: 'Password'),
+              obscureText: true,
+            ),
+            const SizedBox(height: 24.0),
+            ElevatedButton(
+              onPressed: _registerUser,
+              child: const Text('Register'),
+            ),
+          ],
+        ),
+      ),
+    );
+  }
+}

+ 28 - 0
pubspec.lock

@@ -109,6 +109,22 @@ packages:
     description: flutter
     source: sdk
     version: "0.0.0"
+  http:
+    dependency: "direct main"
+    description:
+      name: http
+      sha256: "759d1a329847dd0f39226c688d3e06a6b8679668e350e2891a6474f8b4bb8525"
+      url: "https://pub.dev"
+    source: hosted
+    version: "1.1.0"
+  http_parser:
+    dependency: transitive
+    description:
+      name: http_parser
+      sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b"
+      url: "https://pub.dev"
+    source: hosted
+    version: "4.0.2"
   intl:
     dependency: "direct main"
     description:
@@ -321,7 +337,19 @@ packages:
       sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b"
       url: "https://pub.dev"
     source: hosted
+<<<<<<< HEAD
+    version: "0.6.0"
+  typed_data:
+    dependency: transitive
+    description:
+      name: typed_data
+      sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c
+      url: "https://pub.dev"
+    source: hosted
+    version: "1.3.2"
+=======
     version: "0.6.1"
+>>>>>>> b5c79b54a3cdbee825d05b3ea43276bfeef16159
   vector_math:
     dependency: transitive
     description:

+ 1 - 0
pubspec.yaml

@@ -41,6 +41,7 @@ dependencies:
   flutter_localizations:
     sdk: flutter
   intl: any
+  http: ^1.1.0
 dev_dependencies:
   flutter_test:
     sdk: flutter