12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- // 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<Globals> {
- // 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);
- }
- }
- }
|