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

fix: wallet app example build with flutter 3.27.1 #435

Merged
merged 4 commits into from
Jan 8, 2025

Conversation

ptisserand
Copy link
Collaborator

@ptisserand ptisserand commented Jan 8, 2025

Summary by CodeRabbit

Release Notes

  • Documentation

    • Updated documentation for starknet-devnet usage instructions with improved phrasing for clarity
  • Build Configuration

    • Updated Gradle configuration for Android project
    • Upgraded Gradle wrapper from version 7.5 to 8.3
    • Modernized plugin and dependency management
  • Platform Support

    • Added Linux platform configuration for Flutter application
    • Implemented CMake build scripts for Linux deployment
  • User Interface

    • Enhanced home screen with new deploy account button
  • Maintenance

    • Added Linux-specific build and plugin registration files

Copy link

docs-page bot commented Jan 8, 2025

To view this pull requests documentation preview, visit the following URL:

docs.page/focustree/starknet.dart~435

Documentation is deployed and generated using docs.page.

@ptisserand ptisserand marked this pull request as ready for review January 8, 2025 22:56
Copy link
Contributor

coderabbitai bot commented Jan 8, 2025

Walkthrough

This pull request introduces comprehensive changes to the mobile wallet example application, focusing on the Linux platform configuration. The modifications include updates to Gradle build files, CMake configurations, and Flutter-specific Linux integration files. The changes aim to improve the project structure, update build tools, and provide a more robust Linux desktop application setup.

Changes

File Change Summary
docs/examples/mobile-wallet.mdx Minor rephrasing for clarity in documentation
examples/wallet_app/android/app/build.gradle Updated plugin configuration and removed deprecated plugin application method
examples/wallet_app/android/build.gradle Removed buildscript block with Kotlin and Gradle plugin configurations
examples/wallet_app/android/gradle/wrapper/gradle-wrapper.properties Upgraded Gradle wrapper from version 7.5 to 8.3
examples/wallet_app/android/settings.gradle Restructured plugin management and added new plugin declarations
examples/wallet_app/lib/screens/home_screen.dart Added Scaffold and DeployAccountButton to the home screen
examples/wallet_app/linux/ Added comprehensive Linux platform configuration files

Sequence Diagram

sequenceDiagram
    participant User
    participant HomeScreen
    participant Scaffold
    participant Layout2
    participant DeployAccountButton

    User->>HomeScreen: Interact with screen
    HomeScreen->>Scaffold: Wrap Layout2
    Scaffold->>Layout2: Render body
    Layout2->>DeployAccountButton: Add to Column
Loading

Possibly related PRs

Poem

🐰 A Gradle dance, a Linux embrace,
Plugins shuffled with coding grace.
Flutter spreads its wings so bright,
Wallet app takes a new flight!
Code hops forward, clean and light. 🚀

Finishing Touches

  • 📝 Generate Docstrings

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (9)
examples/wallet_app/linux/runner/my_application.cc (4)

103-107: Avoid Redundant Null Assignment

In my_application_dispose, after calling g_clear_pointer, self->dart_entrypoint_arguments is already set to NULL. Assigning NULL again is redundant.

No action needed as g_clear_pointer handles nullification. You can remove any additional assignments to self->dart_entrypoint_arguments.


30-39: Simplify Header Bar Logic for Improved Readability

The conditional logic determining the use of a header bar can be streamlined for clarity.

Consider refactoring as follows:

 gboolean use_header_bar = TRUE;
 #ifdef GDK_WINDOWING_X11
-  GdkScreen* screen = gtk_window_get_screen(window);
-  if (GDK_IS_X11_SCREEN(screen)) {
-    const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen);
-    if (g_strcmp0(wm_name, "GNOME Shell") != 0) {
-      use_header_bar = FALSE;
-    }
-  }
+  GdkDisplay* display = gdk_display_get_default();
+  if (GDK_IS_X11_DISPLAY(display)) {
+    const gchar* wm_name = gdk_x11_display_get_window_manager_name(display);
+    if (g_strcmp0(wm_name, "GNOME Shell") != 0) {
+      use_header_bar = FALSE;
+    }
+  }
 #endif

86-91: Remove Unused Variable and Comments

In my_application_startup, the variable self is declared but not used. Additionally, placeholder comments can be removed to clean up the code.

Apply this diff to remove the unused variable and comments:

-static void my_application_startup(GApplication* application) {
-  // MyApplication* self = MY_APPLICATION(application);
-
-  // Perform any actions required at application startup.
+static void my_application_startup(GApplication* application) {
   G_APPLICATION_CLASS(my_application_parent_class)->startup(application);
 }

94-100: Clean Up my_application_shutdown Function

Similarly, in my_application_shutdown, the unused variable self and placeholder comments can be removed.

Apply this diff:

-static void my_application_shutdown(GApplication* application) {
-  // MyApplication* self = MY_APPLICATION(application);
-
-  // Perform any actions required at application shutdown.
+static void my_application_shutdown(GApplication* application) {
   G_APPLICATION_CLASS(my_application_parent_class)->shutdown(application);
 }
examples/wallet_app/linux/runner/main.cc (1)

3-6: Simplify Memory Management with g_autoptr

Using g_autoptr for MyApplication is appropriate here as it ensures automatic cleanup. However, since g_application_run manages the lifecycle, using g_autoptr might be unnecessary.

Consider simplifying the code:

 int main(int argc, char** argv) {
-  g_autoptr(MyApplication) app = my_application_new();
+  MyApplication* app = my_application_new();
   return g_application_run(G_APPLICATION(app), argc, argv);
 }

Ensure that not using g_autoptr does not introduce memory leaks.

🧰 Tools
🪛 cppcheck (2.10-2)

[error] 6-6: There is an unknown macro here somewhere. Configuration is required. If G_DECLARE_FINAL_TYPE is a macro then please configure it.

(unknownMacro)

examples/wallet_app/linux/runner/CMakeLists.txt (1)

1-26: LGTM! Well-structured CMake configuration.

The configuration properly sets up the Linux runner with all necessary dependencies and build settings.

Consider adding brief comments explaining the purpose of each library in the target_link_libraries section for better maintainability.

 # Add dependency libraries. Add any application-specific dependencies here.
 target_link_libraries(${BINARY_NAME} PRIVATE flutter)
-target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK)
+# GTK: Required for Linux desktop window management and native UI integration
+target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK)
examples/wallet_app/linux/flutter/CMakeLists.txt (1)

37-58: Consider using a more maintainable approach for header list

The long list of Flutter library headers could be moved to a separate file for better maintainability.

Consider creating a separate flutter_headers.cmake file and including it:

-list(APPEND FLUTTER_LIBRARY_HEADERS
-  "fl_basic_message_channel.h"
-  ...
-  "flutter_linux.h"
-)
+include(flutter_headers.cmake)
examples/wallet_app/linux/CMakeLists.txt (2)

7-10: Review application identifier

The application ID uses a generic example domain. Consider updating it to match your organization's domain structure.

-set(APPLICATION_ID "com.example.wallet_app")
+set(APPLICATION_ID "com.coderabbit.wallet_app")

42-47: Consider enhancing compiler settings

The standard settings function could be improved:

  1. C++14 is relatively old
  2. Missing important compiler flags

Consider updating the compiler settings:

 function(APPLY_STANDARD_SETTINGS TARGET)
-  target_compile_features(${TARGET} PUBLIC cxx_std_14)
-  target_compile_options(${TARGET} PRIVATE -Wall -Werror)
+  target_compile_features(${TARGET} PUBLIC cxx_std_17)
+  target_compile_options(${TARGET} PRIVATE
+    -Wall
+    -Werror
+    -Wextra
+    -Wpedantic
+    -Wno-unused-parameter
+  )
   target_compile_options(${TARGET} PRIVATE "$<$<NOT:$<CONFIG:Debug>>:-O3>")
   target_compile_definitions(${TARGET} PRIVATE "$<$<NOT:$<CONFIG:Debug>>:NDEBUG>")
 endfunction()
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7414256 and 5066c6f.

📒 Files selected for processing (16)
  • docs/examples/mobile-wallet.mdx (1 hunks)
  • examples/wallet_app/android/app/build.gradle (1 hunks)
  • examples/wallet_app/android/build.gradle (0 hunks)
  • examples/wallet_app/android/gradle/wrapper/gradle-wrapper.properties (1 hunks)
  • examples/wallet_app/android/settings.gradle (1 hunks)
  • examples/wallet_app/lib/screens/home_screen.dart (1 hunks)
  • examples/wallet_app/linux/.gitignore (1 hunks)
  • examples/wallet_app/linux/CMakeLists.txt (1 hunks)
  • examples/wallet_app/linux/flutter/CMakeLists.txt (1 hunks)
  • examples/wallet_app/linux/flutter/generated_plugin_registrant.cc (1 hunks)
  • examples/wallet_app/linux/flutter/generated_plugin_registrant.h (1 hunks)
  • examples/wallet_app/linux/flutter/generated_plugins.cmake (1 hunks)
  • examples/wallet_app/linux/runner/CMakeLists.txt (1 hunks)
  • examples/wallet_app/linux/runner/main.cc (1 hunks)
  • examples/wallet_app/linux/runner/my_application.cc (1 hunks)
  • examples/wallet_app/linux/runner/my_application.h (1 hunks)
💤 Files with no reviewable changes (1)
  • examples/wallet_app/android/build.gradle
✅ Files skipped from review due to trivial changes (6)
  • examples/wallet_app/linux/flutter/generated_plugin_registrant.cc
  • examples/wallet_app/linux/flutter/generated_plugin_registrant.h
  • examples/wallet_app/linux/.gitignore
  • examples/wallet_app/android/gradle/wrapper/gradle-wrapper.properties
  • docs/examples/mobile-wallet.mdx
  • examples/wallet_app/linux/flutter/generated_plugins.cmake
🧰 Additional context used
🪛 cppcheck (2.10-2)
examples/wallet_app/linux/runner/main.cc

[error] 6-6: There is an unknown macro here somewhere. Configuration is required. If G_DECLARE_FINAL_TYPE is a macro then please configure it.

(unknownMacro)

examples/wallet_app/linux/runner/my_application.cc

[error] 6-6: There is an unknown macro here somewhere. Configuration is required. If G_DECLARE_FINAL_TYPE is a macro then please configure it.

(unknownMacro)

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: analyze
  • GitHub Check: test-integration
🔇 Additional comments (10)
examples/wallet_app/linux/runner/main.cc (1)

1-1: Ensure Build Configuration Includes Header Files

The inclusion of "my_application.h" requires that the build system correctly locates this header file. Verify that the build configuration includes the appropriate include paths.

If you encounter compilation issues, adjust the include directories in your build system to reference the runner directory.

examples/wallet_app/linux/runner/my_application.h (1)

4-4: ⚠️ Potential issue

Include <glib-object.h> for Macro Definitions

The macro G_DECLARE_FINAL_TYPE requires <glib-object.h> to be included. Currently, only <gtk/gtk.h> is included, which may not define this macro.

Apply this diff to include the necessary header:

 #include <gtk/gtk.h>
+#include <glib-object.h>

 G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION,
                      GtkApplication)

This ensures that G_DECLARE_FINAL_TYPE is properly defined, resolving any issues with unknown macros.

Likely invalid or redundant comment.

examples/wallet_app/lib/screens/home_screen.dart (1)

10-27: LGTM! Good improvements to the widget structure.

The changes improve the widget hierarchy by:

  • Adding a proper Material Design Scaffold
  • Better organizing the layout with proper alignment properties
  • Including the DeployAccountButton for account deployment functionality
examples/wallet_app/android/settings.gradle (1)

1-23: LGTM! Good modernization of Gradle configuration.

The changes follow modern Gradle best practices with proper plugin management and explicit version declarations.

Let's verify the plugin versions are the latest stable ones compatible with Flutter 3.27.1:

examples/wallet_app/android/app/build.gradle (2)

1-5: LGTM! Good adoption of modern Gradle plugins DSL.

The change to use the plugins block is a good modernization of the build configuration.


Line range hint 45-46: Address TODO comments in the configuration.

There are two TODO items that should be addressed:

  1. Application ID should be specified properly for production
  2. Release signing configuration needs to be set up

Would you like me to help create a GitHub issue to track these TODOs?

Also applies to: 56-59

examples/wallet_app/linux/flutter/CMakeLists.txt (3)

24-27: LGTM: System dependencies are properly configured

The required system packages (GTK, GLIB, GIO) are correctly specified using pkg_check_modules.


2-2: Verify CMake version compatibility with Flutter 3.27.1

The minimum CMake version is set to 3.10, which is quite old. While this works, newer Flutter versions might benefit from newer CMake features.

✅ Verification successful

CMake version 3.10 requirement is correct for Linux Flutter builds

The CMake version requirement of 3.10 is consistent across all Linux Flutter builds in the codebase, while Windows builds use 3.14. This platform-specific difference is intentional and follows Flutter's build system requirements.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check CMake version requirements in Flutter documentation
gh api repos/flutter/flutter/contents/packages/flutter_tools/templates/app/linux.tmpl/CMakeLists.txt | jq -r '.content' | base64 -d | grep -A 2 'cmake_minimum_required'

Length of output: 288


Script:

#!/bin/bash
# Find all CMakeLists.txt files and their cmake_minimum_required versions
fd CMakeLists.txt --type f --exec grep -l "cmake_minimum_required" {} \; | while read -r file; do
  echo "=== $file ==="
  grep -A 1 "cmake_minimum_required" "$file"
done

# Look for Flutter version specification
fd . --type f -e yaml -e md | xargs grep -l "flutter" | while read -r file; do
  echo "=== $file ==="
  grep -i "flutter.*version\|version.*flutter" "$file"
done

Length of output: 10246


72-84: Verify the Flutter tool backend path

The script assumes a specific Flutter root structure. Ensure this path is compatible with Flutter 3.27.1.

✅ Verification successful

The Flutter tool backend path is correctly structured

The path ${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh follows Flutter's standard SDK structure, as evidenced by its consistent usage across multiple Flutter projects and platforms in the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if the tool_backend.sh exists in the specified location
rg -l "tool_backend.sh" | grep "flutter_tools"

Length of output: 44


Script:

#!/bin/bash
# Search for FLUTTER_ROOT variable definitions and usage
rg "FLUTTER_ROOT" -A 2 -B 2

# Look for any Flutter SDK path configurations
fd -t f ".*\.txt$" -X rg "flutter.*sdk|sdk.*flutter" -i

Length of output: 19474

examples/wallet_app/linux/CMakeLists.txt (1)

124-128: LGTM: Conditional AOT library installation

The AOT library installation is correctly configured to exclude Debug builds.

@ptisserand ptisserand merged commit cf98696 into focustree:main Jan 8, 2025
9 checks passed
@ptisserand ptisserand deleted the fix/wallet_app_example branch January 8, 2025 23:04
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.

1 participant