google / charts

https://pub.dev/packages/charts_flutter
Apache License 2.0
2.81k stars 1.22k forks source link

Copying "Simple Line Chart Example" into main.dart yields error #545

Open JoeCodeswell opened 4 years ago

JoeCodeswell commented 4 years ago

Hi Folks. Thanks for the GREAT software.

I Copied the code from your [Simple Line Chart Example]() into my main.dart file and got the following error in the DEBUG CONSOLE:

Launching lib\main.dart on Chrome in debug mode...

Compiler message:
org-dartlang-app:///web_entrypoint.dart:5:3: Error: Method not found: 'main'.
  entrypoint.main();
  ^^^^
Failed to compile application.
Exited (sigterm)

What do I need to add to make this run? Thanks for the help. Love and peace, Joe Dorocak aka JoeCodeswell@gmail.com

JoeCodeswell commented 4 years ago

Hi Folks, I got this to run by putting your sample code into a file called bar_chart.dart and using the following main.dart file in the same lib folder. I suggest you publish something similar so folks don't have to fumble around to get a running example.

import 'package:flutter/material.dart';
import 'bar_chart.dart';

void main() {
  runApp(
    Center(
      child: SimpleBarChart.withSampleData(),
    ),
  );
}

Thanks again for the GREAT software. Love and peace, Joe

JoeCodeswell commented 4 years ago

Dear Google Folks,

After my troubles in actually understanding that:

  1. Your Charts Gallery would show me code, if i clicked on one of the examples. AND

  2. How to invoke one of the code examples from a main.dart,

I feel COMPELLED to say that the actual structure of the gallery and the underlying code is a BRILLIANTLY DESIGNED set of TUTORIAL EXAMPLES that shows HOW TO USE the features of your API without complicating the underlying code with unnecessary and confusing structure.

Thanks for this blessing.

Here are 2 more suggestions for the Charts Gallery page.

  1. Add something to say:"Click on a chart to reveal a code example."
  2. Add a card to show the main.dart code to invoke the examples.

ALSO, I suggest you edit the README.md of this repository to say:

Thanks again for the GREAT software. Love and peace, Joe