-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update Flutter sample to align closer with downstream DartPad version #77
Update Flutter sample to align closer with downstream DartPad version #77
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@johnpryan - can you review this? (cc @natebosch for FYI)
/// | ||
/// To learn how to generate and specify this key, | ||
/// check out the README file of this sample. | ||
const String _apiKey = String.fromEnvironment('API_KEY'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could make this nullable, instead of the empty string, as:
const String? _apiKey = bool.hasEnvironment('API_KEY') ? String.fromEnvironment('API_KEY') : null;`
or
const String _envApiKey = String.fromEnvironment('API_KEY');
const String? _apiKey = _envApiKey == "" ? null : _envApiKey;
/// To learn how to generate and specify this key, | ||
/// check out the README file of this sample. | ||
const String _apiKey = String.fromEnvironment('API_KEY'); | ||
|
||
void main() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider providing the API key as a command line argument instead.
onst String _envApiKey = String.fromEnvironment('API_KEY');
final String? _apiKey = _envApiKey == "" ? null : _envApiKey;
void main(List<String> args) {
String? apiKey = _apiKey;
if (args.isNotEmpty) {
apiKey = args.first;
}
if (apiKey == null) {
stderr.writeln("No API key specified");
exit(1);
}
// use it
ChatWidget
to accept an API key, since we use a different method of specifying it, and users might want to as well._chat.history
iterable then runningtoList
for each item inListView.builder