Hi -thank you for sharing
Unable create new user in appwrite from flutter
Votes
2
Replies
24
Participants
Unknown
Messages
25
@everyone
Let me take a look
@everyone
import 'package:flutter/material.dart';
import 'homepage.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Todo App',
theme: ThemeData(
// This is the theme of your application.
//
// Try running your application with "flutter run". You'll see the
// application has a blue toolbar. Then, without quitting the app, try
// changing the primarySwatch below to Colors.green and then invoke
// "hot reload" (press "r" in the console where you ran "flutter run",
// or simply save your changes to "hot reload" in a Flutter IDE).
// Notice that the counter didn't reset back to zero; the application
// is not restarted.
primarySwatch: Colors.blue,
),
home: const Homepage(),
);
}
}
Main.dart
@everyone
auth.dart
import 'package:appwrite/appwrite.dart';
Client client = Client()
.setEndpoint('http://localhost/v1')
.setProject('64392f2ec924b428ae8c')
.setSelfSigned(
status: true); // For self signed certificates, only use for development
//create an user account
Account account = Account(client);
Future createUser() async {
final user = await account.create(
userId: ID.unique(),
email: 'me@appwrite.io',
password: 'password',
name: 'My Name');
print("New User created");
}
@everyone
homepage.dart
import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:flutter/src/widgets/placeholder.dart';
import 'package:todo_app/auth.dart';
class Homepage extends StatelessWidget {
const Homepage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: TextButton(
child: const Text("Create User"),
onPressed: () {
createUser();
},
),
));
}
}
@everyone
@Steven please help
Admin
your problem is that localhost refers to the current device so your android emulator will try to connect to itself rather than your host machine where Appwrite is running. On an android emulator, instead of localhost, you can use 10.0.2.2, a special IP that refers to the host machine.
Hero
localhost wouldn't work as it would try to connect to itself rather than your computer host
you need to use this
http://{YOUR_COMUPTER_IPV4_ADDRESS}:{PORT}}/v1
@everyone
Ok thanks 🙏
@everyone
Let me check
Can we close this issue if its resolved @Jebin shaju https://github.com/appwrite/sdk-for-flutter/issues/142
@everyone
no, now no errror occur but the appwrite dashboard doesnot show user being added
Admin
There's gotta be an error...maybe you're not catching it in your code
@everyone
yes i think so
@everyone
but i have 28 request to the app write
Admin
maybe from the console or something
@everyone
http://10.0.2.2/v1 isnt this the ip i should be using
@everyone
when using an emulator
@everyone
Admin
sure...or maybe https://10.0.2.2/v1
@everyone
both are not working
@everyone
any ways thanks for your support, really like your support team
Admin
what's the error?
Admin
are you sure you're looking in the right project?