J
J
jallvar2018-12-20 14:00:56
Dart
jallvar, 2018-12-20 14:00:56

Dart, invalid constructor name?

Hello everyone, I'm writing a lightweight class to get data from the API I
just started to understand the dart
class

import 'package:http/http.dart' as http;

class api_model {
  
  String base_url = 'http://*/Callback/';
  String api_key = '*';

  String getCodes()
  {
    this._request('getCodes');
  }

  String _request(String method, {Map<String, String> params})
  {

    http.post(base_url+'/'+method+'/'+api_key, body: params)
        .then((response) {
      print("Response status: ${response.statusCode}");
      print("Response body: ${response.body}");
    });

  }
}

Attempt to use:
api_model apiModel = new api_model();
apiModel.getCodes();

Error:
Invalid constructor name

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question