プレイグラウンド、サンドボックス、使い捨てスクリプト置き場
0

Configure Feed

Select the types of activity you want to include in your feed.

create flutter

Kohei Watanabe (Nov 30, 2022, 10:25 PM +0900) 635c597e d50ba511

+919
+44
flutter_linux_app/.gitignore
··· 1 + # Miscellaneous 2 + *.class 3 + *.log 4 + *.pyc 5 + *.swp 6 + .DS_Store 7 + .atom/ 8 + .buildlog/ 9 + .history 10 + .svn/ 11 + migrate_working_dir/ 12 + 13 + # IntelliJ related 14 + *.iml 15 + *.ipr 16 + *.iws 17 + .idea/ 18 + 19 + # The .vscode folder contains launch configuration and tasks you configure in 20 + # VS Code which you may wish to be included in version control, so this line 21 + # is commented out by default. 22 + #.vscode/ 23 + 24 + # Flutter/Dart/Pub related 25 + **/doc/api/ 26 + **/ios/Flutter/.last_build_id 27 + .dart_tool/ 28 + .flutter-plugins 29 + .flutter-plugins-dependencies 30 + .packages 31 + .pub-cache/ 32 + .pub/ 33 + /build/ 34 + 35 + # Symbolication related 36 + app.*.symbols 37 + 38 + # Obfuscation related 39 + app.*.map.json 40 + 41 + # Android Studio will place build artifacts here 42 + /android/app/debug 43 + /android/app/profile 44 + /android/app/release
+30
flutter_linux_app/.metadata
··· 1 + # This file tracks properties of this Flutter project. 2 + # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 + # 4 + # This file should be version controlled. 5 + 6 + version: 7 + revision: 52b3dc25f6471c27b2144594abb11c741cb88f57 8 + channel: stable 9 + 10 + project_type: app 11 + 12 + # Tracks metadata for the flutter migrate command 13 + migration: 14 + platforms: 15 + - platform: root 16 + create_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57 17 + base_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57 18 + - platform: linux 19 + create_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57 20 + base_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57 21 + 22 + # User provided section 23 + 24 + # List of Local paths (relative to this file) that should be 25 + # ignored by the migrate tool. 26 + # 27 + # Files that are not part of the templates will be ignored by default. 28 + unmanaged_files: 29 + - 'lib/main.dart' 30 + - 'ios/Runner.xcodeproj/project.pbxproj'
+16
flutter_linux_app/README.md
··· 1 + # flutter_linux_app 2 + 3 + A new Flutter project. 4 + 5 + ## Getting Started 6 + 7 + This project is a starting point for a Flutter application. 8 + 9 + A few resources to get you started if this is your first Flutter project: 10 + 11 + - [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab) 12 + - [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook) 13 + 14 + For help getting started with Flutter development, view the 15 + [online documentation](https://docs.flutter.dev/), which offers tutorials, 16 + samples, guidance on mobile development, and a full API reference.
+29
flutter_linux_app/analysis_options.yaml
··· 1 + # This file configures the analyzer, which statically analyzes Dart code to 2 + # check for errors, warnings, and lints. 3 + # 4 + # The issues identified by the analyzer are surfaced in the UI of Dart-enabled 5 + # IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be 6 + # invoked from the command line by running `flutter analyze`. 7 + 8 + # The following line activates a set of recommended lints for Flutter apps, 9 + # packages, and plugins designed to encourage good coding practices. 10 + include: package:flutter_lints/flutter.yaml 11 + 12 + linter: 13 + # The lint rules applied to this project can be customized in the 14 + # section below to disable rules from the `package:flutter_lints/flutter.yaml` 15 + # included above or to enable additional rules. A list of all available lints 16 + # and their documentation is published at 17 + # https://dart-lang.github.io/linter/lints/index.html. 18 + # 19 + # Instead of disabling a lint rule for the entire project in the 20 + # section below, it can also be suppressed for a single line of code 21 + # or a specific dart file by using the `// ignore: name_of_lint` and 22 + # `// ignore_for_file: name_of_lint` syntax on the line or in the file 23 + # producing the lint. 24 + rules: 25 + # avoid_print: false # Uncomment to disable the `avoid_print` rule 26 + # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule 27 + 28 + # Additional information about this file can be found at 29 + # https://dart.dev/guides/language/analysis-options
+115
flutter_linux_app/lib/main.dart
··· 1 + import 'package:flutter/material.dart'; 2 + 3 + void main() { 4 + runApp(const MyApp()); 5 + } 6 + 7 + class MyApp extends StatelessWidget { 8 + const MyApp({super.key}); 9 + 10 + // This widget is the root of your application. 11 + @override 12 + Widget build(BuildContext context) { 13 + return MaterialApp( 14 + title: 'Flutter Demo', 15 + theme: ThemeData( 16 + // This is the theme of your application. 17 + // 18 + // Try running your application with "flutter run". You'll see the 19 + // application has a blue toolbar. Then, without quitting the app, try 20 + // changing the primarySwatch below to Colors.green and then invoke 21 + // "hot reload" (press "r" in the console where you ran "flutter run", 22 + // or simply save your changes to "hot reload" in a Flutter IDE). 23 + // Notice that the counter didn't reset back to zero; the application 24 + // is not restarted. 25 + primarySwatch: Colors.blue, 26 + ), 27 + home: const MyHomePage(title: 'Flutter Demo Home Page'), 28 + ); 29 + } 30 + } 31 + 32 + class MyHomePage extends StatefulWidget { 33 + const MyHomePage({super.key, required this.title}); 34 + 35 + // This widget is the home page of your application. It is stateful, meaning 36 + // that it has a State object (defined below) that contains fields that affect 37 + // how it looks. 38 + 39 + // This class is the configuration for the state. It holds the values (in this 40 + // case the title) provided by the parent (in this case the App widget) and 41 + // used by the build method of the State. Fields in a Widget subclass are 42 + // always marked "final". 43 + 44 + final String title; 45 + 46 + @override 47 + State<MyHomePage> createState() => _MyHomePageState(); 48 + } 49 + 50 + class _MyHomePageState extends State<MyHomePage> { 51 + int _counter = 0; 52 + 53 + void _incrementCounter() { 54 + setState(() { 55 + // This call to setState tells the Flutter framework that something has 56 + // changed in this State, which causes it to rerun the build method below 57 + // so that the display can reflect the updated values. If we changed 58 + // _counter without calling setState(), then the build method would not be 59 + // called again, and so nothing would appear to happen. 60 + _counter++; 61 + }); 62 + } 63 + 64 + @override 65 + Widget build(BuildContext context) { 66 + // This method is rerun every time setState is called, for instance as done 67 + // by the _incrementCounter method above. 68 + // 69 + // The Flutter framework has been optimized to make rerunning build methods 70 + // fast, so that you can just rebuild anything that needs updating rather 71 + // than having to individually change instances of widgets. 72 + return Scaffold( 73 + appBar: AppBar( 74 + // Here we take the value from the MyHomePage object that was created by 75 + // the App.build method, and use it to set our appbar title. 76 + title: Text(widget.title), 77 + ), 78 + body: Center( 79 + // Center is a layout widget. It takes a single child and positions it 80 + // in the middle of the parent. 81 + child: Column( 82 + // Column is also a layout widget. It takes a list of children and 83 + // arranges them vertically. By default, it sizes itself to fit its 84 + // children horizontally, and tries to be as tall as its parent. 85 + // 86 + // Invoke "debug painting" (press "p" in the console, choose the 87 + // "Toggle Debug Paint" action from the Flutter Inspector in Android 88 + // Studio, or the "Toggle Debug Paint" command in Visual Studio Code) 89 + // to see the wireframe for each widget. 90 + // 91 + // Column has various properties to control how it sizes itself and 92 + // how it positions its children. Here we use mainAxisAlignment to 93 + // center the children vertically; the main axis here is the vertical 94 + // axis because Columns are vertical (the cross axis would be 95 + // horizontal). 96 + mainAxisAlignment: MainAxisAlignment.center, 97 + children: <Widget>[ 98 + const Text( 99 + 'You have pushed the button this many times:', 100 + ), 101 + Text( 102 + '$_counter', 103 + style: Theme.of(context).textTheme.headline4, 104 + ), 105 + ], 106 + ), 107 + ), 108 + floatingActionButton: FloatingActionButton( 109 + onPressed: _incrementCounter, 110 + tooltip: 'Increment', 111 + child: const Icon(Icons.add), 112 + ), // This trailing comma makes auto-formatting nicer for build methods. 113 + ); 114 + } 115 + }
+1
flutter_linux_app/linux/.gitignore
··· 1 + flutter/ephemeral
+138
flutter_linux_app/linux/CMakeLists.txt
··· 1 + # Project-level configuration. 2 + cmake_minimum_required(VERSION 3.10) 3 + project(runner LANGUAGES CXX) 4 + 5 + # The name of the executable created for the application. Change this to change 6 + # the on-disk name of your application. 7 + set(BINARY_NAME "flutter_linux_app") 8 + # The unique GTK application identifier for this application. See: 9 + # https://wiki.gnome.org/HowDoI/ChooseApplicationID 10 + set(APPLICATION_ID "com.example.flutter_linux_app") 11 + 12 + # Explicitly opt in to modern CMake behaviors to avoid warnings with recent 13 + # versions of CMake. 14 + cmake_policy(SET CMP0063 NEW) 15 + 16 + # Load bundled libraries from the lib/ directory relative to the binary. 17 + set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") 18 + 19 + # Root filesystem for cross-building. 20 + if(FLUTTER_TARGET_PLATFORM_SYSROOT) 21 + set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT}) 22 + set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT}) 23 + set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 24 + set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) 25 + set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 26 + set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 27 + endif() 28 + 29 + # Define build configuration options. 30 + if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) 31 + set(CMAKE_BUILD_TYPE "Debug" CACHE 32 + STRING "Flutter build mode" FORCE) 33 + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS 34 + "Debug" "Profile" "Release") 35 + endif() 36 + 37 + # Compilation settings that should be applied to most targets. 38 + # 39 + # Be cautious about adding new options here, as plugins use this function by 40 + # default. In most cases, you should add new options to specific targets instead 41 + # of modifying this function. 42 + function(APPLY_STANDARD_SETTINGS TARGET) 43 + target_compile_features(${TARGET} PUBLIC cxx_std_14) 44 + target_compile_options(${TARGET} PRIVATE -Wall -Werror) 45 + target_compile_options(${TARGET} PRIVATE "$<$<NOT:$<CONFIG:Debug>>:-O3>") 46 + target_compile_definitions(${TARGET} PRIVATE "$<$<NOT:$<CONFIG:Debug>>:NDEBUG>") 47 + endfunction() 48 + 49 + # Flutter library and tool build rules. 50 + set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") 51 + add_subdirectory(${FLUTTER_MANAGED_DIR}) 52 + 53 + # System-level dependencies. 54 + find_package(PkgConfig REQUIRED) 55 + pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) 56 + 57 + add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") 58 + 59 + # Define the application target. To change its name, change BINARY_NAME above, 60 + # not the value here, or `flutter run` will no longer work. 61 + # 62 + # Any new source files that you add to the application should be added here. 63 + add_executable(${BINARY_NAME} 64 + "main.cc" 65 + "my_application.cc" 66 + "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" 67 + ) 68 + 69 + # Apply the standard set of build settings. This can be removed for applications 70 + # that need different build settings. 71 + apply_standard_settings(${BINARY_NAME}) 72 + 73 + # Add dependency libraries. Add any application-specific dependencies here. 74 + target_link_libraries(${BINARY_NAME} PRIVATE flutter) 75 + target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) 76 + 77 + # Run the Flutter tool portions of the build. This must not be removed. 78 + add_dependencies(${BINARY_NAME} flutter_assemble) 79 + 80 + # Only the install-generated bundle's copy of the executable will launch 81 + # correctly, since the resources must in the right relative locations. To avoid 82 + # people trying to run the unbundled copy, put it in a subdirectory instead of 83 + # the default top-level location. 84 + set_target_properties(${BINARY_NAME} 85 + PROPERTIES 86 + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" 87 + ) 88 + 89 + # Generated plugin build rules, which manage building the plugins and adding 90 + # them to the application. 91 + include(flutter/generated_plugins.cmake) 92 + 93 + 94 + # === Installation === 95 + # By default, "installing" just makes a relocatable bundle in the build 96 + # directory. 97 + set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") 98 + if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) 99 + set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) 100 + endif() 101 + 102 + # Start with a clean build bundle directory every time. 103 + install(CODE " 104 + file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") 105 + " COMPONENT Runtime) 106 + 107 + set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") 108 + set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") 109 + 110 + install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" 111 + COMPONENT Runtime) 112 + 113 + install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 114 + COMPONENT Runtime) 115 + 116 + install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 117 + COMPONENT Runtime) 118 + 119 + foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) 120 + install(FILES "${bundled_library}" 121 + DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 122 + COMPONENT Runtime) 123 + endforeach(bundled_library) 124 + 125 + # Fully re-copy the assets directory on each build to avoid having stale files 126 + # from a previous install. 127 + set(FLUTTER_ASSET_DIR_NAME "flutter_assets") 128 + install(CODE " 129 + file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") 130 + " COMPONENT Runtime) 131 + install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" 132 + DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) 133 + 134 + # Install the AOT library on non-Debug builds only. 135 + if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") 136 + install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 137 + COMPONENT Runtime) 138 + endif()
+88
flutter_linux_app/linux/flutter/CMakeLists.txt
··· 1 + # This file controls Flutter-level build steps. It should not be edited. 2 + cmake_minimum_required(VERSION 3.10) 3 + 4 + set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") 5 + 6 + # Configuration provided via flutter tool. 7 + include(${EPHEMERAL_DIR}/generated_config.cmake) 8 + 9 + # TODO: Move the rest of this into files in ephemeral. See 10 + # https://github.com/flutter/flutter/issues/57146. 11 + 12 + # Serves the same purpose as list(TRANSFORM ... PREPEND ...), 13 + # which isn't available in 3.10. 14 + function(list_prepend LIST_NAME PREFIX) 15 + set(NEW_LIST "") 16 + foreach(element ${${LIST_NAME}}) 17 + list(APPEND NEW_LIST "${PREFIX}${element}") 18 + endforeach(element) 19 + set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE) 20 + endfunction() 21 + 22 + # === Flutter Library === 23 + # System-level dependencies. 24 + find_package(PkgConfig REQUIRED) 25 + pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) 26 + pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) 27 + pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) 28 + 29 + set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") 30 + 31 + # Published to parent scope for install step. 32 + set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) 33 + set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) 34 + set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) 35 + set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE) 36 + 37 + list(APPEND FLUTTER_LIBRARY_HEADERS 38 + "fl_basic_message_channel.h" 39 + "fl_binary_codec.h" 40 + "fl_binary_messenger.h" 41 + "fl_dart_project.h" 42 + "fl_engine.h" 43 + "fl_json_message_codec.h" 44 + "fl_json_method_codec.h" 45 + "fl_message_codec.h" 46 + "fl_method_call.h" 47 + "fl_method_channel.h" 48 + "fl_method_codec.h" 49 + "fl_method_response.h" 50 + "fl_plugin_registrar.h" 51 + "fl_plugin_registry.h" 52 + "fl_standard_message_codec.h" 53 + "fl_standard_method_codec.h" 54 + "fl_string_codec.h" 55 + "fl_value.h" 56 + "fl_view.h" 57 + "flutter_linux.h" 58 + ) 59 + list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") 60 + add_library(flutter INTERFACE) 61 + target_include_directories(flutter INTERFACE 62 + "${EPHEMERAL_DIR}" 63 + ) 64 + target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") 65 + target_link_libraries(flutter INTERFACE 66 + PkgConfig::GTK 67 + PkgConfig::GLIB 68 + PkgConfig::GIO 69 + ) 70 + add_dependencies(flutter flutter_assemble) 71 + 72 + # === Flutter tool backend === 73 + # _phony_ is a non-existent file to force this command to run every time, 74 + # since currently there's no way to get a full input/output list from the 75 + # flutter tool. 76 + add_custom_command( 77 + OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} 78 + ${CMAKE_CURRENT_BINARY_DIR}/_phony_ 79 + COMMAND ${CMAKE_COMMAND} -E env 80 + ${FLUTTER_TOOL_ENVIRONMENT} 81 + "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh" 82 + ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE} 83 + VERBATIM 84 + ) 85 + add_custom_target(flutter_assemble DEPENDS 86 + "${FLUTTER_LIBRARY}" 87 + ${FLUTTER_LIBRARY_HEADERS} 88 + )
+11
flutter_linux_app/linux/flutter/generated_plugin_registrant.cc
··· 1 + // 2 + // Generated file. Do not edit. 3 + // 4 + 5 + // clang-format off 6 + 7 + #include "generated_plugin_registrant.h" 8 + 9 + 10 + void fl_register_plugins(FlPluginRegistry* registry) { 11 + }
+15
flutter_linux_app/linux/flutter/generated_plugin_registrant.h
··· 1 + // 2 + // Generated file. Do not edit. 3 + // 4 + 5 + // clang-format off 6 + 7 + #ifndef GENERATED_PLUGIN_REGISTRANT_ 8 + #define GENERATED_PLUGIN_REGISTRANT_ 9 + 10 + #include <flutter_linux/flutter_linux.h> 11 + 12 + // Registers Flutter plugins. 13 + void fl_register_plugins(FlPluginRegistry* registry); 14 + 15 + #endif // GENERATED_PLUGIN_REGISTRANT_
+23
flutter_linux_app/linux/flutter/generated_plugins.cmake
··· 1 + # 2 + # Generated file, do not edit. 3 + # 4 + 5 + list(APPEND FLUTTER_PLUGIN_LIST 6 + ) 7 + 8 + list(APPEND FLUTTER_FFI_PLUGIN_LIST 9 + ) 10 + 11 + set(PLUGIN_BUNDLED_LIBRARIES) 12 + 13 + foreach(plugin ${FLUTTER_PLUGIN_LIST}) 14 + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin}) 15 + target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 16 + list(APPEND PLUGIN_BUNDLED_LIBRARIES $<TARGET_FILE:${plugin}_plugin>) 17 + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 18 + endforeach(plugin) 19 + 20 + foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 21 + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin}) 22 + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 23 + endforeach(ffi_plugin)
+6
flutter_linux_app/linux/main.cc
··· 1 + #include "my_application.h" 2 + 3 + int main(int argc, char** argv) { 4 + g_autoptr(MyApplication) app = my_application_new(); 5 + return g_application_run(G_APPLICATION(app), argc, argv); 6 + }
+104
flutter_linux_app/linux/my_application.cc
··· 1 + #include "my_application.h" 2 + 3 + #include <flutter_linux/flutter_linux.h> 4 + #ifdef GDK_WINDOWING_X11 5 + #include <gdk/gdkx.h> 6 + #endif 7 + 8 + #include "flutter/generated_plugin_registrant.h" 9 + 10 + struct _MyApplication { 11 + GtkApplication parent_instance; 12 + char** dart_entrypoint_arguments; 13 + }; 14 + 15 + G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION) 16 + 17 + // Implements GApplication::activate. 18 + static void my_application_activate(GApplication* application) { 19 + MyApplication* self = MY_APPLICATION(application); 20 + GtkWindow* window = 21 + GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application))); 22 + 23 + // Use a header bar when running in GNOME as this is the common style used 24 + // by applications and is the setup most users will be using (e.g. Ubuntu 25 + // desktop). 26 + // If running on X and not using GNOME then just use a traditional title bar 27 + // in case the window manager does more exotic layout, e.g. tiling. 28 + // If running on Wayland assume the header bar will work (may need changing 29 + // if future cases occur). 30 + gboolean use_header_bar = TRUE; 31 + #ifdef GDK_WINDOWING_X11 32 + GdkScreen* screen = gtk_window_get_screen(window); 33 + if (GDK_IS_X11_SCREEN(screen)) { 34 + const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen); 35 + if (g_strcmp0(wm_name, "GNOME Shell") != 0) { 36 + use_header_bar = FALSE; 37 + } 38 + } 39 + #endif 40 + if (use_header_bar) { 41 + GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new()); 42 + gtk_widget_show(GTK_WIDGET(header_bar)); 43 + gtk_header_bar_set_title(header_bar, "flutter_linux_app"); 44 + gtk_header_bar_set_show_close_button(header_bar, TRUE); 45 + gtk_window_set_titlebar(window, GTK_WIDGET(header_bar)); 46 + } else { 47 + gtk_window_set_title(window, "flutter_linux_app"); 48 + } 49 + 50 + gtk_window_set_default_size(window, 1280, 720); 51 + gtk_widget_show(GTK_WIDGET(window)); 52 + 53 + g_autoptr(FlDartProject) project = fl_dart_project_new(); 54 + fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments); 55 + 56 + FlView* view = fl_view_new(project); 57 + gtk_widget_show(GTK_WIDGET(view)); 58 + gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view)); 59 + 60 + fl_register_plugins(FL_PLUGIN_REGISTRY(view)); 61 + 62 + gtk_widget_grab_focus(GTK_WIDGET(view)); 63 + } 64 + 65 + // Implements GApplication::local_command_line. 66 + static gboolean my_application_local_command_line(GApplication* application, gchar*** arguments, int* exit_status) { 67 + MyApplication* self = MY_APPLICATION(application); 68 + // Strip out the first argument as it is the binary name. 69 + self->dart_entrypoint_arguments = g_strdupv(*arguments + 1); 70 + 71 + g_autoptr(GError) error = nullptr; 72 + if (!g_application_register(application, nullptr, &error)) { 73 + g_warning("Failed to register: %s", error->message); 74 + *exit_status = 1; 75 + return TRUE; 76 + } 77 + 78 + g_application_activate(application); 79 + *exit_status = 0; 80 + 81 + return TRUE; 82 + } 83 + 84 + // Implements GObject::dispose. 85 + static void my_application_dispose(GObject* object) { 86 + MyApplication* self = MY_APPLICATION(object); 87 + g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev); 88 + G_OBJECT_CLASS(my_application_parent_class)->dispose(object); 89 + } 90 + 91 + static void my_application_class_init(MyApplicationClass* klass) { 92 + G_APPLICATION_CLASS(klass)->activate = my_application_activate; 93 + G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line; 94 + G_OBJECT_CLASS(klass)->dispose = my_application_dispose; 95 + } 96 + 97 + static void my_application_init(MyApplication* self) {} 98 + 99 + MyApplication* my_application_new() { 100 + return MY_APPLICATION(g_object_new(my_application_get_type(), 101 + "application-id", APPLICATION_ID, 102 + "flags", G_APPLICATION_NON_UNIQUE, 103 + nullptr)); 104 + }
+18
flutter_linux_app/linux/my_application.h
··· 1 + #ifndef FLUTTER_MY_APPLICATION_H_ 2 + #define FLUTTER_MY_APPLICATION_H_ 3 + 4 + #include <gtk/gtk.h> 5 + 6 + G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION, 7 + GtkApplication) 8 + 9 + /** 10 + * my_application_new: 11 + * 12 + * Creates a new Flutter-based application. 13 + * 14 + * Returns: a new #MyApplication. 15 + */ 16 + MyApplication* my_application_new(); 17 + 18 + #endif // FLUTTER_MY_APPLICATION_H_
+160
flutter_linux_app/pubspec.lock
··· 1 + # Generated by pub 2 + # See https://dart.dev/tools/pub/glossary#lockfile 3 + packages: 4 + async: 5 + dependency: transitive 6 + description: 7 + name: async 8 + url: "https://pub.dartlang.org" 9 + source: hosted 10 + version: "2.9.0" 11 + boolean_selector: 12 + dependency: transitive 13 + description: 14 + name: boolean_selector 15 + url: "https://pub.dartlang.org" 16 + source: hosted 17 + version: "2.1.0" 18 + characters: 19 + dependency: transitive 20 + description: 21 + name: characters 22 + url: "https://pub.dartlang.org" 23 + source: hosted 24 + version: "1.2.1" 25 + clock: 26 + dependency: transitive 27 + description: 28 + name: clock 29 + url: "https://pub.dartlang.org" 30 + source: hosted 31 + version: "1.1.1" 32 + collection: 33 + dependency: transitive 34 + description: 35 + name: collection 36 + url: "https://pub.dartlang.org" 37 + source: hosted 38 + version: "1.16.0" 39 + cupertino_icons: 40 + dependency: "direct main" 41 + description: 42 + name: cupertino_icons 43 + url: "https://pub.dartlang.org" 44 + source: hosted 45 + version: "1.0.5" 46 + fake_async: 47 + dependency: transitive 48 + description: 49 + name: fake_async 50 + url: "https://pub.dartlang.org" 51 + source: hosted 52 + version: "1.3.1" 53 + flutter: 54 + dependency: "direct main" 55 + description: flutter 56 + source: sdk 57 + version: "0.0.0" 58 + flutter_lints: 59 + dependency: "direct dev" 60 + description: 61 + name: flutter_lints 62 + url: "https://pub.dartlang.org" 63 + source: hosted 64 + version: "2.0.1" 65 + flutter_test: 66 + dependency: "direct dev" 67 + description: flutter 68 + source: sdk 69 + version: "0.0.0" 70 + lints: 71 + dependency: transitive 72 + description: 73 + name: lints 74 + url: "https://pub.dartlang.org" 75 + source: hosted 76 + version: "2.0.1" 77 + matcher: 78 + dependency: transitive 79 + description: 80 + name: matcher 81 + url: "https://pub.dartlang.org" 82 + source: hosted 83 + version: "0.12.12" 84 + material_color_utilities: 85 + dependency: transitive 86 + description: 87 + name: material_color_utilities 88 + url: "https://pub.dartlang.org" 89 + source: hosted 90 + version: "0.1.5" 91 + meta: 92 + dependency: transitive 93 + description: 94 + name: meta 95 + url: "https://pub.dartlang.org" 96 + source: hosted 97 + version: "1.8.0" 98 + path: 99 + dependency: transitive 100 + description: 101 + name: path 102 + url: "https://pub.dartlang.org" 103 + source: hosted 104 + version: "1.8.2" 105 + sky_engine: 106 + dependency: transitive 107 + description: flutter 108 + source: sdk 109 + version: "0.0.99" 110 + source_span: 111 + dependency: transitive 112 + description: 113 + name: source_span 114 + url: "https://pub.dartlang.org" 115 + source: hosted 116 + version: "1.9.0" 117 + stack_trace: 118 + dependency: transitive 119 + description: 120 + name: stack_trace 121 + url: "https://pub.dartlang.org" 122 + source: hosted 123 + version: "1.10.0" 124 + stream_channel: 125 + dependency: transitive 126 + description: 127 + name: stream_channel 128 + url: "https://pub.dartlang.org" 129 + source: hosted 130 + version: "2.1.0" 131 + string_scanner: 132 + dependency: transitive 133 + description: 134 + name: string_scanner 135 + url: "https://pub.dartlang.org" 136 + source: hosted 137 + version: "1.1.1" 138 + term_glyph: 139 + dependency: transitive 140 + description: 141 + name: term_glyph 142 + url: "https://pub.dartlang.org" 143 + source: hosted 144 + version: "1.2.1" 145 + test_api: 146 + dependency: transitive 147 + description: 148 + name: test_api 149 + url: "https://pub.dartlang.org" 150 + source: hosted 151 + version: "0.4.12" 152 + vector_math: 153 + dependency: transitive 154 + description: 155 + name: vector_math 156 + url: "https://pub.dartlang.org" 157 + source: hosted 158 + version: "2.1.2" 159 + sdks: 160 + dart: ">=2.18.4 <3.0.0"
+91
flutter_linux_app/pubspec.yaml
··· 1 + name: flutter_linux_app 2 + description: A new Flutter project. 3 + 4 + # The following line prevents the package from being accidentally published to 5 + # pub.dev using `flutter pub publish`. This is preferred for private packages. 6 + publish_to: 'none' # Remove this line if you wish to publish to pub.dev 7 + 8 + # The following defines the version and build number for your application. 9 + # A version number is three numbers separated by dots, like 1.2.43 10 + # followed by an optional build number separated by a +. 11 + # Both the version and the builder number may be overridden in flutter 12 + # build by specifying --build-name and --build-number, respectively. 13 + # In Android, build-name is used as versionName while build-number used as versionCode. 14 + # Read more about Android versioning at https://developer.android.com/studio/publish/versioning 15 + # In iOS, build-name is used as CFBundleShortVersionString while build-number is used as CFBundleVersion. 16 + # Read more about iOS versioning at 17 + # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html 18 + # In Windows, build-name is used as the major, minor, and patch parts 19 + # of the product and file versions while build-number is used as the build suffix. 20 + version: 1.0.0+1 21 + 22 + environment: 23 + sdk: '>=2.18.4 <3.0.0' 24 + 25 + # Dependencies specify other packages that your package needs in order to work. 26 + # To automatically upgrade your package dependencies to the latest versions 27 + # consider running `flutter pub upgrade --major-versions`. Alternatively, 28 + # dependencies can be manually updated by changing the version numbers below to 29 + # the latest version available on pub.dev. To see which dependencies have newer 30 + # versions available, run `flutter pub outdated`. 31 + dependencies: 32 + flutter: 33 + sdk: flutter 34 + 35 + 36 + # The following adds the Cupertino Icons font to your application. 37 + # Use with the CupertinoIcons class for iOS style icons. 38 + cupertino_icons: ^1.0.2 39 + 40 + dev_dependencies: 41 + flutter_test: 42 + sdk: flutter 43 + 44 + # The "flutter_lints" package below contains a set of recommended lints to 45 + # encourage good coding practices. The lint set provided by the package is 46 + # activated in the `analysis_options.yaml` file located at the root of your 47 + # package. See that file for information about deactivating specific lint 48 + # rules and activating additional ones. 49 + flutter_lints: ^2.0.0 50 + 51 + # For information on the generic Dart part of this file, see the 52 + # following page: https://dart.dev/tools/pub/pubspec 53 + 54 + # The following section is specific to Flutter packages. 55 + flutter: 56 + 57 + # The following line ensures that the Material Icons font is 58 + # included with your application, so that you can use the icons in 59 + # the material Icons class. 60 + uses-material-design: true 61 + 62 + # To add assets to your application, add an assets section, like this: 63 + # assets: 64 + # - images/a_dot_burr.jpeg 65 + # - images/a_dot_ham.jpeg 66 + 67 + # An image asset can refer to one or more resolution-specific "variants", see 68 + # https://flutter.dev/assets-and-images/#resolution-aware 69 + 70 + # For details regarding adding assets from package dependencies, see 71 + # https://flutter.dev/assets-and-images/#from-packages 72 + 73 + # To add custom fonts to your application, add a fonts section here, 74 + # in this "flutter" section. Each entry in this list should have a 75 + # "family" key with the font family name, and a "fonts" key with a 76 + # list giving the asset and other descriptors for the font. For 77 + # example: 78 + # fonts: 79 + # - family: Schyler 80 + # fonts: 81 + # - asset: fonts/Schyler-Regular.ttf 82 + # - asset: fonts/Schyler-Italic.ttf 83 + # style: italic 84 + # - family: Trajan Pro 85 + # fonts: 86 + # - asset: fonts/TrajanPro.ttf 87 + # - asset: fonts/TrajanPro_Bold.ttf 88 + # weight: 700 89 + # 90 + # For details regarding fonts from package dependencies, 91 + # see https://flutter.dev/custom-fonts/#from-packages
+30
flutter_linux_app/test/widget_test.dart
··· 1 + // This is a basic Flutter widget test. 2 + // 3 + // To perform an interaction with a widget in your test, use the WidgetTester 4 + // utility in the flutter_test package. For example, you can send tap and scroll 5 + // gestures. You can also use WidgetTester to find child widgets in the widget 6 + // tree, read text, and verify that the values of widget properties are correct. 7 + 8 + import 'package:flutter/material.dart'; 9 + import 'package:flutter_test/flutter_test.dart'; 10 + 11 + import 'package:flutter_linux_app/main.dart'; 12 + 13 + void main() { 14 + testWidgets('Counter increments smoke test', (WidgetTester tester) async { 15 + // Build our app and trigger a frame. 16 + await tester.pumpWidget(const MyApp()); 17 + 18 + // Verify that our counter starts at 0. 19 + expect(find.text('0'), findsOneWidget); 20 + expect(find.text('1'), findsNothing); 21 + 22 + // Tap the '+' icon and trigger a frame. 23 + await tester.tap(find.byIcon(Icons.add)); 24 + await tester.pump(); 25 + 26 + // Verify that our counter has incremented. 27 + expect(find.text('0'), findsNothing); 28 + expect(find.text('1'), findsOneWidget); 29 + }); 30 + }