Esse é o terminal do server
Não está registrando no db.json
Estou usando o Android Studio, isso muda algo?
vou enviar meus codigos
main.dart:
import 'package:flutter/material.dart';
import 'package:flutter_webapi_first_course/services/journal_service.dart';
import 'package:google_fonts/google_fonts.dart';
import 'screens/home_screen/home_screen.dart';
void main() {
runApp(const MyApp());
JournalService service = JournalService();
service.register("Salve");
service.get();
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Simple Journal',
debugShowCheckedModeBanner: false,
theme: ThemeData(
primarySwatch: Colors.grey,
appBarTheme: const AppBarTheme(
elevation: 0,
backgroundColor: Colors.black,
titleTextStyle: TextStyle(
color: Colors.white,
),
),
textTheme: GoogleFonts.bitterTextTheme()
),
darkTheme: ThemeData.dark(),
themeMode: ThemeMode.light,
initialRoute: "home",
routes: {
"home": (context) => const HomeScreen(),
},
);
}
}
journal_service.dart
import 'package:flutter_webapi_first_course/services/http_interceptors.dart';
import 'package:http/http.dart' as http;
import 'package:http_interceptor/http/intercepted_client.dart';
class JournalService {
static const String url = "http://192.168.15.51:3000/";
static const String resource = "learnhttp/";
http.Client client =
InterceptedClient.build(interceptors: [LoggingInterceptor()]);
String getURI() {
return "$url$resource";
}
void register(String content) {
client.post(Uri.parse(getURI()), body: {'content': content});
}
void get() async {
http.Response response = await client.get(Uri.parse(getURI()));
print(response.body);
}
}
http_interceptors.dart
import 'package:http_interceptor/http_interceptor.dart';
class LoggingInterceptor implements InterceptorContract {
@override
Future<RequestData> interceptRequest({required RequestData data}) async {
print(data.toString());
return data;
}
@override
Future<ResponseData> interceptResponse({required ResponseData data}) async {
print(data.toString());
return data;
}
}
db.json
{
"learnhttp": {
}
}
Eu estou re assinstindo a aula para ver se pulei algo mas não encontrei