Created .env file for environment variables and added corresponding package (flutter_dotenv)

This commit is contained in:
2024-01-15 16:08:16 +03:00
parent d530b6b409
commit b3a49c85a2
7 changed files with 14 additions and 11 deletions

View File

@@ -7,6 +7,7 @@ import 'package:validators/validators.dart';
import 'package:eatvio_app/widgets/next_step_button.dart';
import 'package:eatvio_app/widgets/custom_text_form_field.dart';
import 'package:flutter/material.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'dart:convert';
import 'package:hive/hive.dart';
import 'package:http/http.dart' as http;
@@ -83,8 +84,7 @@ class AuthScreen extends StatelessWidget {
'password': state.passwordController!.text,
};
final response = await http.post(
Uri.parse(
'https://emaibo4wahye-dev3.eatvio.ru/api/login'),
Uri.parse(dotenv.env['SERVER_ROOT']! + '/login'),
headers: {'Content-Type': 'application/json'},
body: json.encode(credentials),
encoding: utf8);
@@ -103,7 +103,7 @@ class AuthScreen extends StatelessWidget {
builder: (context) => AlertDialog(
title: Text('Ошибка'),
content:
Text(jsonDecode(jsonEncode(response.body))),
Text(dotenv.env['SERVER_ROOT']! + '/login'),
actions: [
TextButton(
onPressed: () {