Joseph Arriaza
Joseph Arriaza

Reputation: 13784

Static members from supertypes must be qualified by the name of the defining type

I am creating some classes and I am getting this issue: Static members from supertypes must be qualified by the name of the defining type. post(Documnet document) ->Future

My clases are these:

UserApi

import '../api-helper.dart';
import '../../graphql/documents/login.dart';
import 'dart:async';

class UserAPI extends APIHelper {

  static Future<dynamic> login(account) async {
    return await post(new Login('name', 'email', 'token', 'refreshToken', 'createdAt', 'expiresAt', false));
  }

}

APIHelper

import 'package:graphql_flutter/graphql_flutter.dart' show Client, InMemoryCache;
import '../graphql/document.dart';
import '../graphql/graphql-helper.dart';
import 'dart:async';

class APIHelper {

  static const GRAPHQL_URL = 'https://heat-map-api.herokuapp.com/graphql';
  static final _client = Client(
      endPoint: GRAPHQL_URL,
      cache: new InMemoryCache(),
    );

  static Future<dynamic> post(Document document) async {
    return await _client.query(query: GraphQLHelper.getBodyMutation(document), variables: GraphQLHelper.getVariables(document));
  }

}

What should I do in order to fix this? I don't have compiled the project yet, but it scares me.

Upvotes: 1

Views: 1546

Answers (1)

Alexandre Ardhuin
Alexandre Ardhuin

Reputation: 76353

Static members can only be used (outside of their class) by prefixing with the class name.

A better design for helper like that is to use top-level members. See AVOID defining a class that contains only static members rule from the Effective Dart .

Upvotes: 3

Related Questions