Skip to content

Instantly share code, notes, and snippets.

@ailabs-software
Created August 7, 2022 02:13
Show Gist options
  • Save ailabs-software/238e9d53183bb053773621ac82917111 to your computer and use it in GitHub Desktop.
Save ailabs-software/238e9d53183bb053773621ac82917111 to your computer and use it in GitHub Desktop.
On line 15, how to break out of scope and reference dart String type?
enum DataType
{
None(false, BASE_OPERATOR_TITLE_MAP), // Null or nil is this language.
Boolean(false, BASE_OPERATOR_TITLE_MAP),
Number(false, BASE_OPERATOR_TITLE_MAP),
String(false, BASE_OPERATOR_TITLE_MAP),
Date(false, BASE_OPERATOR_TITLE_MAP),
StringArray(true, BASE_OPERATOR_TITLE_MAP), // An array of strings
Object(false, BASE_OPERATOR_TITLE_MAP), // A catch-all type for objects types.
DateTime(false, BASE_OPERATOR_TITLE_MAP),
Anniversary(false, BASE_OPERATOR_TITLE_MAP);
final bool isArray;
final Map<OperatorType, String> operatorTitleMap;
const DataType(bool this.isArray, Map<OperatorType, String> this.operatorTitleMap);
}
@RandalSchwartz
Copy link

Why are you creating names that deliberately shadow names that already have significance?

@simolus3
Copy link

simolus3 commented Aug 7, 2022

The real crime here is not naming enum members in lowerCamelCase :D

That said, you can do this:

import 'dart:core' as core;

enum DataType
{
  /* ... */;

  final Map<OperatorType, core.String> operatorTitleMap;

  const DataType(bool this.isArray, Map<OperatorType, String> this.operatorTitleMap);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment