// ignore_for_file: library_private_types_in_public_api import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; import 'package:namer_app/globals.dart'; final globalState = _GlobalsState(); void main() { globalState.getuser();//call this way runApp( MaterialApp( debugShowCheckedModeBanner: false, title: "Taxiyee_Messaging_app", home: Container(), ), ); } class Globals extends StatefulWidget { const Globals({super.key}); @override _GlobalsState createState() => _GlobalsState(); } class _GlobalsState extends State { // int counter = 0; var jsonList = ''; @override Widget build(BuildContext context) { return Container(); } getuser() async{ try { var response = await Dio() .get('http://localhost:8080/api/v1/users', options: Options(headers: headers)); // print('Method Call'); if (response.statusCode == 200) { setState(() { // counter++; jsonList = response.data['results']; });} } on Exception catch (e) { print(e); } } }