Skip to content
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

converted the example folder into a fully working flutter project #6

Merged
merged 3 commits into from
Dec 4, 2020

Conversation

technolion
Copy link
Contributor

This allows for building the plugin code (including the native C++ code) when running the example.
This fixes #5

This allows for building the plugin code (including the native C++ code)
when running the example.
@technolion technolion changed the title converted the example folder in a fully working flutter project converted the example folder into a fully working flutter project Dec 3, 2020
@technolion
Copy link
Contributor Author

technolion commented Dec 4, 2020

You might wonder, where all those new files come from. Here is what I did:

I created a new blank flutter plugin, choosing the same name as your package:
flutter create -t plugin --platforms windows bitsdojo_window

This creates a blank plugin project including an example code folder.

I then copied the files main.dart and switch.dart from your original project into the new example folder below lib.
Then I moved this new, flutter-standard example folder to your original project, replacing the old example folder.

The advantage now: You can load the whole project into Visual Studio Code und run the example there. This then also compiles the C++ code of the corresponding plugin code.

Then I added the lines to the example runner's main.cpp:

#include <bitsdojo_window/bitsdojo_window_plugin.h>
auto bdw = bitsdojo_window_configure(BDW_CUSTOM_FRAME | BDW_HIDE_ON_STARTUP);

This way the example can be run without the need to modify anything, showing the awesome new window header.

I would appreciate this to be merged, because this also helps to contribute to your project.

@bitsdojo
Copy link
Owner

bitsdojo commented Dec 4, 2020

There are two different examples there: main.dart and switch.dart

If we want to make it easy for people to run the example apps then maybe we should find a way that works for both examples.

Do you have anything in mind that would work for both? I believe the current structure in this PR only works for main.dart

The current examples folder structure mimics the one in the win32 package.

Just to be clear, I like your proposal, just looking for a way to make it work for multiple examples.

@technolion
Copy link
Contributor Author

The win32 package is a library (not a flutter plugin). The example folder there obviously only serves as documentation.

Here you can see the difference when creating a package versus a plugin:

Flutter Package:

PS C:\Users\tv\Development> flutter create -t package testpackage
Creating project testpackage...
  testpackage\.gitignore (created)
  testpackage\.idea\libraries\Dart_SDK.xml (created)
  testpackage\.idea\modules.xml (created)
  testpackage\.idea\workspace.xml (created)
  testpackage\.metadata (created)
  testpackage\CHANGELOG.md (created)
  testpackage\lib\testpackage.dart (created)
  testpackage\LICENSE (created)
  testpackage\testpackage.iml (created)
  testpackage\pubspec.yaml (created)
  testpackage\README.md (created)
  testpackage\test\testpackage_test.dart (created)
Running "flutter pub get" in testpackage...                      1,400ms
Wrote 12 files.

All done!
Your package code is in testpackage\lib\testpackage.dart
PS C:\Users\tv\Development>

Flutter Plugin:

PS C:\Users\tv\Development> flutter create -t plugin --platforms windows testplugin
Creating project testplugin...
  testplugin\.gitignore (created)
  testplugin\.idea\libraries\Dart_SDK.xml (created)
  testplugin\.idea\modules.xml (created)
  testplugin\.idea\runConfigurations\example_lib_main_dart.xml (created)
  testplugin\.idea\workspace.xml (created)
  testplugin\.metadata (created)
  testplugin\CHANGELOG.md (created)
  testplugin\lib\testplugin.dart (created)
  testplugin\LICENSE (created)
  testplugin\testplugin.iml (created)
  testplugin\pubspec.yaml (created)
  testplugin\README.md (created)
  testplugin\test\testplugin_test.dart (created)
  testplugin\windows\.gitignore (created)
  testplugin\windows\CMakeLists.txt (created)
  testplugin\windows\include\testplugin\testplugin_plugin.h (created)
  testplugin\windows\testplugin_plugin.cpp (created)
Running "flutter pub get" in testplugin...                       1,352ms
  testplugin\example\.gitignore (created)
  testplugin\example\.idea\libraries\Dart_SDK.xml (created)
  testplugin\example\.idea\libraries\KotlinJavaRuntime.xml (created)
  testplugin\example\.idea\modules.xml (created)
  testplugin\example\.idea\runConfigurations\main_dart.xml (created)
  testplugin\example\.idea\workspace.xml (created)
  testplugin\example\.metadata (created)
  testplugin\example\integration_test\app_test.dart (created)
  testplugin\example\integration_test\driver.dart (created)
  testplugin\example\lib\main.dart (created)
  testplugin\example\testplugin_example.iml (created)
  testplugin\example\pubspec.yaml (created)
  testplugin\example\README.md (created)
  testplugin\example\test\widget_test.dart (created)
  testplugin\example\windows\.gitignore (created)
  testplugin\example\windows\CMakeLists.txt (created)
  testplugin\example\windows\flutter\CMakeLists.txt (created)
  testplugin\example\windows\runner\CMakeLists.txt (created)
  testplugin\example\windows\runner\flutter_window.cpp (created)
  testplugin\example\windows\runner\flutter_window.h (created)
  testplugin\example\windows\runner\main.cpp (created)
  testplugin\example\windows\runner\resource.h (created)
  testplugin\example\windows\runner\resources\app_icon.ico (created)
  testplugin\example\windows\runner\runner.exe.manifest (created)
  testplugin\example\windows\runner\Runner.rc (created)
  testplugin\example\windows\runner\run_loop.cpp (created)
  testplugin\example\windows\runner\run_loop.h (created)
  testplugin\example\windows\runner\utils.cpp (created)
  testplugin\example\windows\runner\utils.h (created)
  testplugin\example\windows\runner\win32_window.cpp (created)
  testplugin\example\windows\runner\win32_window.h (created)
Running "flutter pub get" in example...                             3.2s
Wrote 48 files.

All done!

Your plugin code is in testplugin\lib\testplugin.dart.

You example app code is in testplugin\example\lib\main.dart.


Host platform code is in the windows directories under testplugin.
To edit platform code in an IDE see https://flutter.dev/developing-packages/#edit-plugin-package.


PS C:\Users\tv\Development>

@technolion
Copy link
Contributor Author

There are two different examples there: main.dart and switch.dart

If we want to make it easy for people to run the example apps then maybe we should find a way that works for both examples.

Do you have anything in mind that would work for both? I believe the current structure in this PR only works for main.dart

The current examples folder structure mimics the one in the win32 package.

Just to be clear, I like your proposal, just looking for a way to make it work for multiple examples.

I'll check out, whether we can offer both examples via launch configurations...

This allows the user to choose which exaple to run
@technolion
Copy link
Contributor Author

I added the file launch.json to the example folder. It is now possible to choose which example to run:

Bildschirmfoto 2020-12-04 um 10 56 24

@bitsdojo bitsdojo merged commit 5ef50dc into bitsdojo:master Dec 4, 2020
@technolion
Copy link
Contributor Author

Thank you!

@technolion technolion deleted the playground branch December 4, 2020 12:53
@bitsdojo
Copy link
Owner

bitsdojo commented Dec 4, 2020

Thank you for contributing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The plugin code cannot be complied and run from the example
2 participants