From bc1666d377371f633f554e0da891acb6fe17c2ee Mon Sep 17 00:00:00 2001 From: eriko13 Date: Sat, 22 Jul 2023 11:14:20 -0700 Subject: [PATCH 01/38] init --- packages/xdg_directories/example/.gitignore | 44 ++++++ .../example/.pluginToolsConfig.yaml | 4 + packages/xdg_directories/example/README.md | 3 + .../xdg_directories/example/lib/main.dart | 112 ++++++++++++++ .../xdg_directories/example/linux/.gitignore | 1 + .../example/linux/CMakeLists.txt | 139 ++++++++++++++++++ .../example/linux/flutter/CMakeLists.txt | 88 +++++++++++ .../linux/flutter/generated_plugins.cmake | 23 +++ .../xdg_directories/example/linux/main.cc | 6 + .../example/linux/my_application.cc | 104 +++++++++++++ .../example/linux/my_application.h | 18 +++ packages/xdg_directories/example/pubspec.yaml | 29 ++++ .../example/test/widget_test.dart | 22 +++ .../example/test_driver/integration_test.dart | 7 + 14 files changed, 600 insertions(+) create mode 100644 packages/xdg_directories/example/.gitignore create mode 100644 packages/xdg_directories/example/.pluginToolsConfig.yaml create mode 100644 packages/xdg_directories/example/README.md create mode 100644 packages/xdg_directories/example/lib/main.dart create mode 100644 packages/xdg_directories/example/linux/.gitignore create mode 100644 packages/xdg_directories/example/linux/CMakeLists.txt create mode 100644 packages/xdg_directories/example/linux/flutter/CMakeLists.txt create mode 100644 packages/xdg_directories/example/linux/flutter/generated_plugins.cmake create mode 100644 packages/xdg_directories/example/linux/main.cc create mode 100644 packages/xdg_directories/example/linux/my_application.cc create mode 100644 packages/xdg_directories/example/linux/my_application.h create mode 100644 packages/xdg_directories/example/pubspec.yaml create mode 100644 packages/xdg_directories/example/test/widget_test.dart create mode 100644 packages/xdg_directories/example/test_driver/integration_test.dart diff --git a/packages/xdg_directories/example/.gitignore b/packages/xdg_directories/example/.gitignore new file mode 100644 index 00000000000..24476c5d1eb --- /dev/null +++ b/packages/xdg_directories/example/.gitignore @@ -0,0 +1,44 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ +migrate_working_dir/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +**/doc/api/ +**/ios/Flutter/.last_build_id +.dart_tool/ +.flutter-plugins +.flutter-plugins-dependencies +.packages +.pub-cache/ +.pub/ +/build/ + +# Symbolication related +app.*.symbols + +# Obfuscation related +app.*.map.json + +# Android Studio will place build artifacts here +/android/app/debug +/android/app/profile +/android/app/release diff --git a/packages/xdg_directories/example/.pluginToolsConfig.yaml b/packages/xdg_directories/example/.pluginToolsConfig.yaml new file mode 100644 index 00000000000..3b6017b7609 --- /dev/null +++ b/packages/xdg_directories/example/.pluginToolsConfig.yaml @@ -0,0 +1,4 @@ +buildFlags: + _pluginToolsConfigGlobalKey: + - "--no-tree-shake-icons" + - "--dart-define=buildmode=testing" diff --git a/packages/xdg_directories/example/README.md b/packages/xdg_directories/example/README.md new file mode 100644 index 00000000000..6a67d5ca557 --- /dev/null +++ b/packages/xdg_directories/example/README.md @@ -0,0 +1,3 @@ +# xdg_directories_example + +Demonstrates how to use the xdg_directories_example plugin. diff --git a/packages/xdg_directories/example/lib/main.dart b/packages/xdg_directories/example/lib/main.dart new file mode 100644 index 00000000000..a86f713a398 --- /dev/null +++ b/packages/xdg_directories/example/lib/main.dart @@ -0,0 +1,112 @@ +import 'package:flutter/material.dart'; + +void main() { + runApp(const MyApp()); +} + +/// Main application widget. +class MyApp extends StatelessWidget { + /// Creates the main application widget. + const MyApp({super.key}); + + // This widget is the root of your application. + @override + Widget build(BuildContext context) { + return MaterialApp( + title: 'Flutter Demo', + theme: ThemeData( + colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple), + useMaterial3: true, + ), + home: const MyHomePage(title: 'Flutter Demo Home Page'), + ); + } +} + +class MyHomePage extends StatefulWidget { + const MyHomePage({super.key, required this.title}); + + // This widget is the home page of your application. It is stateful, meaning + // that it has a State object (defined below) that contains fields that affect + // how it looks. + + // This class is the configuration for the state. It holds the values (in this + // case the title) provided by the parent (in this case the App widget) and + // used by the build method of the State. Fields in a Widget subclass are + // always marked "final". + + final String title; + + @override + State createState() => _MyHomePageState(); +} + +class _MyHomePageState extends State { + int _counter = 0; + + void _incrementCounter() { + setState(() { + // This call to setState tells the Flutter framework that something has + // changed in this State, which causes it to rerun the build method below + // so that the display can reflect the updated values. If we changed + // _counter without calling setState(), then the build method would not be + // called again, and so nothing would appear to happen. + _counter++; + }); + } + + @override + Widget build(BuildContext context) { + // This method is rerun every time setState is called, for instance as done + // by the _incrementCounter method above. + // + // The Flutter framework has been optimized to make rerunning build methods + // fast, so that you can just rebuild anything that needs updating rather + // than having to individually change instances of widgets. + return Scaffold( + appBar: AppBar( + // TRY THIS: Try changing the color here to a specific color (to + // Colors.amber, perhaps?) and trigger a hot reload to see the AppBar + // change color while the other colors stay the same. + backgroundColor: Theme.of(context).colorScheme.inversePrimary, + // Here we take the value from the MyHomePage object that was created by + // the App.build method, and use it to set our appbar title. + title: Text(widget.title), + ), + body: Center( + // Center is a layout widget. It takes a single child and positions it + // in the middle of the parent. + child: Column( + // Column is also a layout widget. It takes a list of children and + // arranges them vertically. By default, it sizes itself to fit its + // children horizontally, and tries to be as tall as its parent. + // + // Column has various properties to control how it sizes itself and + // how it positions its children. Here we use mainAxisAlignment to + // center the children vertically; the main axis here is the vertical + // axis because Columns are vertical (the cross axis would be + // horizontal). + // + // TRY THIS: Invoke "debug painting" (choose the "Toggle Debug Paint" + // action in the IDE, or press "p" in the console), to see the + // wireframe for each widget. + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Text( + 'You have pushed the button this many times:', + ), + Text( + '$_counter', + style: Theme.of(context).textTheme.headlineMedium, + ), + ], + ), + ), + floatingActionButton: FloatingActionButton( + onPressed: _incrementCounter, + tooltip: 'Increment', + child: const Icon(Icons.add), + ), // This trailing comma makes auto-formatting nicer for build methods. + ); + } +} diff --git a/packages/xdg_directories/example/linux/.gitignore b/packages/xdg_directories/example/linux/.gitignore new file mode 100644 index 00000000000..d3896c98444 --- /dev/null +++ b/packages/xdg_directories/example/linux/.gitignore @@ -0,0 +1 @@ +flutter/ephemeral diff --git a/packages/xdg_directories/example/linux/CMakeLists.txt b/packages/xdg_directories/example/linux/CMakeLists.txt new file mode 100644 index 00000000000..d67bd4e03e2 --- /dev/null +++ b/packages/xdg_directories/example/linux/CMakeLists.txt @@ -0,0 +1,139 @@ +# Project-level configuration. +cmake_minimum_required(VERSION 3.10) +project(runner LANGUAGES CXX) + +# The name of the executable created for the application. Change this to change +# the on-disk name of your application. +set(BINARY_NAME "example") +# The unique GTK application identifier for this application. See: +# https://wiki.gnome.org/HowDoI/ChooseApplicationID +set(APPLICATION_ID "com.example.example") + +# Explicitly opt in to modern CMake behaviors to avoid warnings with recent +# versions of CMake. +cmake_policy(SET CMP0063 NEW) + +# Load bundled libraries from the lib/ directory relative to the binary. +set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") + +# Root filesystem for cross-building. +if(FLUTTER_TARGET_PLATFORM_SYSROOT) + set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT}) + set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT}) + set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) + set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) + set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) + set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +endif() + +# Define build configuration options. +if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + set(CMAKE_BUILD_TYPE "Debug" CACHE + STRING "Flutter build mode" FORCE) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS + "Debug" "Profile" "Release") +endif() + +# Compilation settings that should be applied to most targets. +# +# Be cautious about adding new options here, as plugins use this function by +# default. In most cases, you should add new options to specific targets instead +# of modifying this function. +function(APPLY_STANDARD_SETTINGS TARGET) + target_compile_features(${TARGET} PUBLIC cxx_std_14) + target_compile_options(${TARGET} PRIVATE -Wall -Werror) + target_compile_options(${TARGET} PRIVATE "$<$>:-O3>") + target_compile_definitions(${TARGET} PRIVATE "$<$>:NDEBUG>") +endfunction() + +# Flutter library and tool build rules. +set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") +add_subdirectory(${FLUTTER_MANAGED_DIR}) + +# System-level dependencies. +find_package(PkgConfig REQUIRED) +pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) + +add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") + +# Define the application target. To change its name, change BINARY_NAME above, +# not the value here, or `flutter run` will no longer work. +# +# Any new source files that you add to the application should be added here. +add_executable(${BINARY_NAME} + "main.cc" + "my_application.cc" + "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" +) + +# Apply the standard set of build settings. This can be removed for applications +# that need different build settings. +apply_standard_settings(${BINARY_NAME}) + +# Add dependency libraries. Add any application-specific dependencies here. +target_link_libraries(${BINARY_NAME} PRIVATE flutter) +target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) + +# Run the Flutter tool portions of the build. This must not be removed. +add_dependencies(${BINARY_NAME} flutter_assemble) + +# Only the install-generated bundle's copy of the executable will launch +# correctly, since the resources must in the right relative locations. To avoid +# people trying to run the unbundled copy, put it in a subdirectory instead of +# the default top-level location. +set_target_properties(${BINARY_NAME} + PROPERTIES + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" +) + + +# Generated plugin build rules, which manage building the plugins and adding +# them to the application. +include(flutter/generated_plugins.cmake) + + +# === Installation === +# By default, "installing" just makes a relocatable bundle in the build +# directory. +set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") +if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) +endif() + +# Start with a clean build bundle directory every time. +install(CODE " + file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") + " COMPONENT Runtime) + +set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") +set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") + +install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) + +foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) + install(FILES "${bundled_library}" + DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) +endforeach(bundled_library) + +# Fully re-copy the assets directory on each build to avoid having stale files +# from a previous install. +set(FLUTTER_ASSET_DIR_NAME "flutter_assets") +install(CODE " + file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") + " COMPONENT Runtime) +install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" + DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) + +# Install the AOT library on non-Debug builds only. +if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") + install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) +endif() diff --git a/packages/xdg_directories/example/linux/flutter/CMakeLists.txt b/packages/xdg_directories/example/linux/flutter/CMakeLists.txt new file mode 100644 index 00000000000..d5bd01648a9 --- /dev/null +++ b/packages/xdg_directories/example/linux/flutter/CMakeLists.txt @@ -0,0 +1,88 @@ +# This file controls Flutter-level build steps. It should not be edited. +cmake_minimum_required(VERSION 3.10) + +set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") + +# Configuration provided via flutter tool. +include(${EPHEMERAL_DIR}/generated_config.cmake) + +# TODO: Move the rest of this into files in ephemeral. See +# https://github.com/flutter/flutter/issues/57146. + +# Serves the same purpose as list(TRANSFORM ... PREPEND ...), +# which isn't available in 3.10. +function(list_prepend LIST_NAME PREFIX) + set(NEW_LIST "") + foreach(element ${${LIST_NAME}}) + list(APPEND NEW_LIST "${PREFIX}${element}") + endforeach(element) + set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE) +endfunction() + +# === Flutter Library === +# System-level dependencies. +find_package(PkgConfig REQUIRED) +pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) +pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) +pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) + +set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") + +# Published to parent scope for install step. +set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) +set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) +set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) +set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE) + +list(APPEND FLUTTER_LIBRARY_HEADERS + "fl_basic_message_channel.h" + "fl_binary_codec.h" + "fl_binary_messenger.h" + "fl_dart_project.h" + "fl_engine.h" + "fl_json_message_codec.h" + "fl_json_method_codec.h" + "fl_message_codec.h" + "fl_method_call.h" + "fl_method_channel.h" + "fl_method_codec.h" + "fl_method_response.h" + "fl_plugin_registrar.h" + "fl_plugin_registry.h" + "fl_standard_message_codec.h" + "fl_standard_method_codec.h" + "fl_string_codec.h" + "fl_value.h" + "fl_view.h" + "flutter_linux.h" +) +list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") +add_library(flutter INTERFACE) +target_include_directories(flutter INTERFACE + "${EPHEMERAL_DIR}" +) +target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") +target_link_libraries(flutter INTERFACE + PkgConfig::GTK + PkgConfig::GLIB + PkgConfig::GIO +) +add_dependencies(flutter flutter_assemble) + +# === Flutter tool backend === +# _phony_ is a non-existent file to force this command to run every time, +# since currently there's no way to get a full input/output list from the +# flutter tool. +add_custom_command( + OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} + ${CMAKE_CURRENT_BINARY_DIR}/_phony_ + COMMAND ${CMAKE_COMMAND} -E env + ${FLUTTER_TOOL_ENVIRONMENT} + "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh" + ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE} + VERBATIM +) +add_custom_target(flutter_assemble DEPENDS + "${FLUTTER_LIBRARY}" + ${FLUTTER_LIBRARY_HEADERS} +) diff --git a/packages/xdg_directories/example/linux/flutter/generated_plugins.cmake b/packages/xdg_directories/example/linux/flutter/generated_plugins.cmake new file mode 100644 index 00000000000..2e1de87a7eb --- /dev/null +++ b/packages/xdg_directories/example/linux/flutter/generated_plugins.cmake @@ -0,0 +1,23 @@ +# +# Generated file, do not edit. +# + +list(APPEND FLUTTER_PLUGIN_LIST +) + +list(APPEND FLUTTER_FFI_PLUGIN_LIST +) + +set(PLUGIN_BUNDLED_LIBRARIES) + +foreach(plugin ${FLUTTER_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin}) + target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) + list(APPEND PLUGIN_BUNDLED_LIBRARIES $) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) +endforeach(plugin) + +foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin}) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) +endforeach(ffi_plugin) diff --git a/packages/xdg_directories/example/linux/main.cc b/packages/xdg_directories/example/linux/main.cc new file mode 100644 index 00000000000..e7c5c543703 --- /dev/null +++ b/packages/xdg_directories/example/linux/main.cc @@ -0,0 +1,6 @@ +#include "my_application.h" + +int main(int argc, char** argv) { + g_autoptr(MyApplication) app = my_application_new(); + return g_application_run(G_APPLICATION(app), argc, argv); +} diff --git a/packages/xdg_directories/example/linux/my_application.cc b/packages/xdg_directories/example/linux/my_application.cc new file mode 100644 index 00000000000..0ba8f43096d --- /dev/null +++ b/packages/xdg_directories/example/linux/my_application.cc @@ -0,0 +1,104 @@ +#include "my_application.h" + +#include +#ifdef GDK_WINDOWING_X11 +#include +#endif + +#include "flutter/generated_plugin_registrant.h" + +struct _MyApplication { + GtkApplication parent_instance; + char** dart_entrypoint_arguments; +}; + +G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION) + +// Implements GApplication::activate. +static void my_application_activate(GApplication* application) { + MyApplication* self = MY_APPLICATION(application); + GtkWindow* window = + GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application))); + + // Use a header bar when running in GNOME as this is the common style used + // by applications and is the setup most users will be using (e.g. Ubuntu + // desktop). + // If running on X and not using GNOME then just use a traditional title bar + // in case the window manager does more exotic layout, e.g. tiling. + // If running on Wayland assume the header bar will work (may need changing + // if future cases occur). + 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; + } + } +#endif + if (use_header_bar) { + GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new()); + gtk_widget_show(GTK_WIDGET(header_bar)); + gtk_header_bar_set_title(header_bar, "example"); + gtk_header_bar_set_show_close_button(header_bar, TRUE); + gtk_window_set_titlebar(window, GTK_WIDGET(header_bar)); + } else { + gtk_window_set_title(window, "example"); + } + + gtk_window_set_default_size(window, 1280, 720); + gtk_widget_show(GTK_WIDGET(window)); + + g_autoptr(FlDartProject) project = fl_dart_project_new(); + fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments); + + FlView* view = fl_view_new(project); + gtk_widget_show(GTK_WIDGET(view)); + gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view)); + + fl_register_plugins(FL_PLUGIN_REGISTRY(view)); + + gtk_widget_grab_focus(GTK_WIDGET(view)); +} + +// Implements GApplication::local_command_line. +static gboolean my_application_local_command_line(GApplication* application, gchar*** arguments, int* exit_status) { + MyApplication* self = MY_APPLICATION(application); + // Strip out the first argument as it is the binary name. + self->dart_entrypoint_arguments = g_strdupv(*arguments + 1); + + g_autoptr(GError) error = nullptr; + if (!g_application_register(application, nullptr, &error)) { + g_warning("Failed to register: %s", error->message); + *exit_status = 1; + return TRUE; + } + + g_application_activate(application); + *exit_status = 0; + + return TRUE; +} + +// Implements GObject::dispose. +static void my_application_dispose(GObject* object) { + MyApplication* self = MY_APPLICATION(object); + g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev); + G_OBJECT_CLASS(my_application_parent_class)->dispose(object); +} + +static void my_application_class_init(MyApplicationClass* klass) { + G_APPLICATION_CLASS(klass)->activate = my_application_activate; + G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line; + G_OBJECT_CLASS(klass)->dispose = my_application_dispose; +} + +static void my_application_init(MyApplication* self) {} + +MyApplication* my_application_new() { + return MY_APPLICATION(g_object_new(my_application_get_type(), + "application-id", APPLICATION_ID, + "flags", G_APPLICATION_NON_UNIQUE, + nullptr)); +} diff --git a/packages/xdg_directories/example/linux/my_application.h b/packages/xdg_directories/example/linux/my_application.h new file mode 100644 index 00000000000..72271d5e417 --- /dev/null +++ b/packages/xdg_directories/example/linux/my_application.h @@ -0,0 +1,18 @@ +#ifndef FLUTTER_MY_APPLICATION_H_ +#define FLUTTER_MY_APPLICATION_H_ + +#include + +G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION, + GtkApplication) + +/** + * my_application_new: + * + * Creates a new Flutter-based application. + * + * Returns: a new #MyApplication. + */ +MyApplication* my_application_new(); + +#endif // FLUTTER_MY_APPLICATION_H_ diff --git a/packages/xdg_directories/example/pubspec.yaml b/packages/xdg_directories/example/pubspec.yaml new file mode 100644 index 00000000000..0e3569953e1 --- /dev/null +++ b/packages/xdg_directories/example/pubspec.yaml @@ -0,0 +1,29 @@ +name: xdg_directories_example +description: Demonstrates how to use the video_player plugin. +publish_to: 'none' + +environment: + sdk: '>=3.0.6 <4.0.0' + flutter: ">=3.3.0" + +dependencies: + flutter: + sdk: flutter + xdg_directories: + # When depending on this package from a real application you should use: + # xdg_directories: ^x.y.z + # See https://dart.dev/tools/pub/dependencies#version-constraints + # The example app is bundled with the plugin so we use a path dependency on + # the parent directory to use the current plugin's version. + path: ../ + +dev_dependencies: + build_runner: ^2.1.10 + flutter_test: + sdk: flutter + integration_test: + sdk: flutter + test: any + +flutter: + uses-material-design: true diff --git a/packages/xdg_directories/example/test/widget_test.dart b/packages/xdg_directories/example/test/widget_test.dart new file mode 100644 index 00000000000..b781bf56978 --- /dev/null +++ b/packages/xdg_directories/example/test/widget_test.dart @@ -0,0 +1,22 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:xdg_directories_example/main.dart'; + +void main() { + testWidgets('Counter increments smoke test', (WidgetTester tester) async { + // Build our app and trigger a frame. + await tester.pumpWidget(const MyApp()); + + // Verify that our counter starts at 0. + expect(find.text('0'), findsOneWidget); + expect(find.text('1'), findsNothing); + + // Tap the '+' icon and trigger a frame. + await tester.tap(find.byIcon(Icons.add)); + await tester.pump(); + + // Verify that our counter has incremented. + expect(find.text('0'), findsNothing); + expect(find.text('1'), findsOneWidget); + }); +} diff --git a/packages/xdg_directories/example/test_driver/integration_test.dart b/packages/xdg_directories/example/test_driver/integration_test.dart new file mode 100644 index 00000000000..4f10f2a522f --- /dev/null +++ b/packages/xdg_directories/example/test_driver/integration_test.dart @@ -0,0 +1,7 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:integration_test/integration_test_driver.dart'; + +Future main() => integrationDriver(); From f599bd2222cd947ec01e41f252160fb2961d375a Mon Sep 17 00:00:00 2001 From: eriko13 Date: Sun, 23 Jul 2023 07:20:30 +0000 Subject: [PATCH 02/38] set the app title to XDG Directories Demo --- .../xdg_directories/example/lib/main.dart | 96 +++++++------------ .../example/linux/CMakeLists.txt | 2 +- .../example/linux/my_application.cc | 4 +- 3 files changed, 35 insertions(+), 67 deletions(-) diff --git a/packages/xdg_directories/example/lib/main.dart b/packages/xdg_directories/example/lib/main.dart index a86f713a398..0248cdb3521 100644 --- a/packages/xdg_directories/example/lib/main.dart +++ b/packages/xdg_directories/example/lib/main.dart @@ -1,24 +1,24 @@ +// ignore_for_file: public_member_api_docs + import 'package:flutter/material.dart'; +import 'package:xdg_directories/xdg_directories.dart'; void main() { runApp(const MyApp()); } -/// Main application widget. class MyApp extends StatelessWidget { - /// Creates the main application widget. const MyApp({super.key}); - // This widget is the root of your application. @override Widget build(BuildContext context) { return MaterialApp( - title: 'Flutter Demo', + title: 'XDG Directories Demo', theme: ThemeData( colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple), useMaterial3: true, ), - home: const MyHomePage(title: 'Flutter Demo Home Page'), + home: const MyHomePage(title: 'XDG Directories Demo'), ); } } @@ -26,15 +26,6 @@ class MyApp extends StatelessWidget { class MyHomePage extends StatefulWidget { const MyHomePage({super.key, required this.title}); - // This widget is the home page of your application. It is stateful, meaning - // that it has a State object (defined below) that contains fields that affect - // how it looks. - - // This class is the configuration for the state. It holds the values (in this - // case the title) provided by the parent (in this case the App widget) and - // used by the build method of the State. Fields in a Widget subclass are - // always marked "final". - final String title; @override @@ -42,71 +33,48 @@ class MyHomePage extends StatefulWidget { } class _MyHomePageState extends State { - int _counter = 0; - - void _incrementCounter() { - setState(() { - // This call to setState tells the Flutter framework that something has - // changed in this State, which causes it to rerun the build method below - // so that the display can reflect the updated values. If we changed - // _counter without calling setState(), then the build method would not be - // called again, and so nothing would appear to happen. - _counter++; - }); - } - @override Widget build(BuildContext context) { - // This method is rerun every time setState is called, for instance as done - // by the _incrementCounter method above. - // - // The Flutter framework has been optimized to make rerunning build methods - // fast, so that you can just rebuild anything that needs updating rather - // than having to individually change instances of widgets. + final Set userDirectoryNames = getUserDirectoryNames(); return Scaffold( appBar: AppBar( - // TRY THIS: Try changing the color here to a specific color (to - // Colors.amber, perhaps?) and trigger a hot reload to see the AppBar - // change color while the other colors stay the same. backgroundColor: Theme.of(context).colorScheme.inversePrimary, - // Here we take the value from the MyHomePage object that was created by - // the App.build method, and use it to set our appbar title. title: Text(widget.title), ), body: Center( - // Center is a layout widget. It takes a single child and positions it - // in the middle of the parent. child: Column( - // Column is also a layout widget. It takes a list of children and - // arranges them vertically. By default, it sizes itself to fit its - // children horizontally, and tries to be as tall as its parent. - // - // Column has various properties to control how it sizes itself and - // how it positions its children. Here we use mainAxisAlignment to - // center the children vertically; the main axis here is the vertical - // axis because Columns are vertical (the cross axis would be - // horizontal). - // - // TRY THIS: Invoke "debug painting" (choose the "Toggle Debug Paint" - // action in the IDE, or press "p" in the console), to see the - // wireframe for each widget. - mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.start, children: [ - const Text( - 'You have pushed the button this many times:', + TextButton( + onPressed: () => print(getUserDirectoryNames()), + child: const Text( + 'Get User Directory', + style: TextStyle( + color: Colors.black, + ), + ), + ), + const Padding( + padding: EdgeInsets.all(8.0), + child: Text( + 'User Directory Names:', + style: TextStyle( + fontSize: 25, + ), + textAlign: TextAlign.start, + ), ), - Text( - '$_counter', - style: Theme.of(context).textTheme.headlineMedium, + ListView.builder( + shrinkWrap: true, + itemCount: userDirectoryNames.length, + itemBuilder: (BuildContext context, int index) => ListTile( + title: Text(userDirectoryNames.elementAt(index)), + visualDensity: VisualDensity.standard, + ), ), ], ), ), - floatingActionButton: FloatingActionButton( - onPressed: _incrementCounter, - tooltip: 'Increment', - child: const Icon(Icons.add), - ), // This trailing comma makes auto-formatting nicer for build methods. ); } } diff --git a/packages/xdg_directories/example/linux/CMakeLists.txt b/packages/xdg_directories/example/linux/CMakeLists.txt index d67bd4e03e2..8175d3e1c17 100644 --- a/packages/xdg_directories/example/linux/CMakeLists.txt +++ b/packages/xdg_directories/example/linux/CMakeLists.txt @@ -4,7 +4,7 @@ project(runner LANGUAGES CXX) # The name of the executable created for the application. Change this to change # the on-disk name of your application. -set(BINARY_NAME "example") +set(BINARY_NAME "xdg_directories_demo") # The unique GTK application identifier for this application. See: # https://wiki.gnome.org/HowDoI/ChooseApplicationID set(APPLICATION_ID "com.example.example") diff --git a/packages/xdg_directories/example/linux/my_application.cc b/packages/xdg_directories/example/linux/my_application.cc index 0ba8f43096d..7b22c28ecf3 100644 --- a/packages/xdg_directories/example/linux/my_application.cc +++ b/packages/xdg_directories/example/linux/my_application.cc @@ -40,11 +40,11 @@ static void my_application_activate(GApplication* application) { if (use_header_bar) { GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new()); gtk_widget_show(GTK_WIDGET(header_bar)); - gtk_header_bar_set_title(header_bar, "example"); + gtk_header_bar_set_title(header_bar, "XDG Directories Demo"); gtk_header_bar_set_show_close_button(header_bar, TRUE); gtk_window_set_titlebar(window, GTK_WIDGET(header_bar)); } else { - gtk_window_set_title(window, "example"); + gtk_window_set_title(window, "XDG Directories Demo"); } gtk_window_set_default_size(window, 1280, 720); From 5c3ba9fa2ecdcf9bb55fa1ae680df4567c76aeac Mon Sep 17 00:00:00 2001 From: eriko13 Date: Sun, 23 Jul 2023 07:41:27 +0000 Subject: [PATCH 03/38] created userDirectory list demo --- .../xdg_directories/example/lib/main.dart | 51 +++++++++++++++---- 1 file changed, 40 insertions(+), 11 deletions(-) diff --git a/packages/xdg_directories/example/lib/main.dart b/packages/xdg_directories/example/lib/main.dart index 0248cdb3521..25aa70054a9 100644 --- a/packages/xdg_directories/example/lib/main.dart +++ b/packages/xdg_directories/example/lib/main.dart @@ -33,6 +33,8 @@ class MyHomePage extends StatefulWidget { } class _MyHomePageState extends State { + String userDirectory = ''; + @override Widget build(BuildContext context) { final Set userDirectoryNames = getUserDirectoryNames(); @@ -45,20 +47,12 @@ class _MyHomePageState extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - TextButton( - onPressed: () => print(getUserDirectoryNames()), - child: const Text( - 'Get User Directory', - style: TextStyle( - color: Colors.black, - ), - ), - ), const Padding( - padding: EdgeInsets.all(8.0), + padding: EdgeInsets.all(10.0), child: Text( - 'User Directory Names:', + 'Select a user directory name:', style: TextStyle( + color: Colors.black87, fontSize: 25, ), textAlign: TextAlign.start, @@ -70,6 +64,41 @@ class _MyHomePageState extends State { itemBuilder: (BuildContext context, int index) => ListTile( title: Text(userDirectoryNames.elementAt(index)), visualDensity: VisualDensity.standard, + onTap: () => setState( + () { + userDirectory = + getUserDirectory(userDirectoryNames.elementAt(index)) + ?.path ?? + ''; + }, + ), + ), + ), + const SizedBox( + height: 20, + ), + const Padding( + padding: EdgeInsets.only(left: 10, bottom: 5), + child: Text( + 'User directory:', + style: TextStyle( + color: Colors.black87, + fontSize: 18, + ), + ), + ), + Container( + margin: const EdgeInsets.only(left: 10), + padding: const EdgeInsets.symmetric( + horizontal: 20, + vertical: 5, + ), + color: Colors.black38, + child: Text( + userDirectory, + style: const TextStyle( + color: Colors.white, + ), ), ), ], From 205817f51e438e4409958d4ee8a236f498f18e69 Mon Sep 17 00:00:00 2001 From: eriko13 Date: Sun, 23 Jul 2023 07:57:03 +0000 Subject: [PATCH 04/38] added demos for all functionalities --- .../xdg_directories/example/lib/main.dart | 181 +++++++++++++++++- 1 file changed, 177 insertions(+), 4 deletions(-) diff --git a/packages/xdg_directories/example/lib/main.dart b/packages/xdg_directories/example/lib/main.dart index 25aa70054a9..5e3c739dd54 100644 --- a/packages/xdg_directories/example/lib/main.dart +++ b/packages/xdg_directories/example/lib/main.dart @@ -44,8 +44,8 @@ class _MyHomePageState extends State { title: Text(widget.title), ), body: Center( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + child: ListView( + shrinkWrap: true, children: [ const Padding( padding: EdgeInsets.all(10.0), @@ -80,7 +80,7 @@ class _MyHomePageState extends State { const Padding( padding: EdgeInsets.only(left: 10, bottom: 5), child: Text( - 'User directory:', + 'Selected directory:', style: TextStyle( color: Colors.black87, fontSize: 18, @@ -88,7 +88,7 @@ class _MyHomePageState extends State { ), ), Container( - margin: const EdgeInsets.only(left: 10), + margin: const EdgeInsets.symmetric(horizontal: 10), padding: const EdgeInsets.symmetric( horizontal: 20, vertical: 5, @@ -101,6 +101,179 @@ class _MyHomePageState extends State { ), ), ), + const SizedBox( + height: 50, + ), + const Padding( + padding: EdgeInsets.only(left: 10, bottom: 5), + child: Text( + 'Runtime directory:', + style: TextStyle( + color: Colors.black87, + fontSize: 18, + ), + ), + ), + Container( + margin: const EdgeInsets.symmetric(horizontal: 10), + padding: const EdgeInsets.symmetric( + horizontal: 20, + vertical: 5, + ), + color: Colors.black38, + child: Text( + runtimeDir?.path ?? '', + style: const TextStyle( + color: Colors.white, + ), + ), + ), + const SizedBox( + height: 50, + ), + const Padding( + padding: EdgeInsets.only(left: 10, bottom: 5), + child: Text( + 'Cache home:', + style: TextStyle( + color: Colors.black87, + fontSize: 18, + ), + ), + ), + Container( + margin: const EdgeInsets.symmetric(horizontal: 10), + padding: const EdgeInsets.symmetric( + horizontal: 20, + vertical: 5, + ), + color: Colors.black38, + child: Text( + cacheHome.path, + style: const TextStyle( + color: Colors.white, + ), + ), + ), + const SizedBox( + height: 50, + ), + const Padding( + padding: EdgeInsets.only(left: 10, bottom: 5), + child: Text( + 'Config directories:', + style: TextStyle( + color: Colors.black87, + fontSize: 18, + ), + ), + ), + ListView.builder( + shrinkWrap: true, + itemCount: configDirs.length, + itemBuilder: (BuildContext context, int index) => Container( + margin: const EdgeInsets.symmetric(horizontal: 10, vertical: 2), + padding: const EdgeInsets.symmetric( + horizontal: 20, + vertical: 5, + ), + color: Colors.black38, + child: Text( + configDirs[index].path, + style: const TextStyle( + color: Colors.white, + ), + ), + ), + ), + const SizedBox( + height: 50, + ), + const Padding( + padding: EdgeInsets.only(left: 10, bottom: 5), + child: Text( + 'Data directories:', + style: TextStyle( + color: Colors.black87, + fontSize: 18, + ), + ), + ), + ListView.builder( + shrinkWrap: true, + itemCount: dataDirs.length, + itemBuilder: (BuildContext context, int index) => Container( + margin: const EdgeInsets.symmetric(horizontal: 10, vertical: 2), + padding: const EdgeInsets.symmetric( + horizontal: 20, + vertical: 5, + ), + color: Colors.black38, + child: Text( + dataDirs[index].path, + style: const TextStyle( + color: Colors.white, + ), + ), + ), + ), + const SizedBox( + height: 50, + ), + const Padding( + padding: EdgeInsets.only(left: 10, bottom: 5), + child: Text( + 'Config home:', + style: TextStyle( + color: Colors.black87, + fontSize: 18, + ), + ), + ), + Container( + margin: const EdgeInsets.symmetric(horizontal: 10), + padding: const EdgeInsets.symmetric( + horizontal: 20, + vertical: 5, + ), + color: Colors.black38, + child: Text( + configHome.path, + style: const TextStyle( + color: Colors.white, + ), + ), + ), + const SizedBox( + height: 50, + ), + const Padding( + padding: EdgeInsets.only(left: 10, bottom: 5), + child: Text( + 'Data home:', + style: TextStyle( + color: Colors.black87, + fontSize: 18, + ), + ), + ), + Container( + margin: const EdgeInsets.symmetric(horizontal: 10), + padding: const EdgeInsets.symmetric( + horizontal: 20, + vertical: 5, + ), + color: Colors.black38, + child: Text( + dataHome.path, + style: const TextStyle( + color: Colors.white, + ), + ), + ), + const SizedBox( + height: 100, + ), ], ), ), From 303dedf14a58301784ab3fff148a18037840d01f Mon Sep 17 00:00:00 2001 From: eriko13 Date: Sun, 23 Jul 2023 09:33:21 +0000 Subject: [PATCH 05/38] Directory Display --- .../xdg_directories/example/lib/main.dart | 153 ++++-------------- .../example/lib/widgets/DirectoryDisplay.dart | 62 +++++++ 2 files changed, 92 insertions(+), 123 deletions(-) create mode 100644 packages/xdg_directories/example/lib/widgets/DirectoryDisplay.dart diff --git a/packages/xdg_directories/example/lib/main.dart b/packages/xdg_directories/example/lib/main.dart index 5e3c739dd54..34903ddb54d 100644 --- a/packages/xdg_directories/example/lib/main.dart +++ b/packages/xdg_directories/example/lib/main.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:xdg_directories/xdg_directories.dart'; +import 'widgets/DirectoryDisplay.dart'; void main() { runApp(const MyApp()); @@ -77,83 +78,23 @@ class _MyHomePageState extends State { const SizedBox( height: 20, ), - const Padding( - padding: EdgeInsets.only(left: 10, bottom: 5), - child: Text( - 'Selected directory:', - style: TextStyle( - color: Colors.black87, - fontSize: 18, - ), - ), - ), - Container( - margin: const EdgeInsets.symmetric(horizontal: 10), - padding: const EdgeInsets.symmetric( - horizontal: 20, - vertical: 5, - ), - color: Colors.black38, - child: Text( - userDirectory, - style: const TextStyle( - color: Colors.white, - ), - ), + DirectoryDisplay( + title: 'Selected directory:', + value: userDirectory, ), const SizedBox( height: 50, ), - const Padding( - padding: EdgeInsets.only(left: 10, bottom: 5), - child: Text( - 'Runtime directory:', - style: TextStyle( - color: Colors.black87, - fontSize: 18, - ), - ), - ), - Container( - margin: const EdgeInsets.symmetric(horizontal: 10), - padding: const EdgeInsets.symmetric( - horizontal: 20, - vertical: 5, - ), - color: Colors.black38, - child: Text( - runtimeDir?.path ?? '', - style: const TextStyle( - color: Colors.white, - ), - ), + DirectoryDisplay( + title: 'Runtime directory:', + value: runtimeDir?.path, ), const SizedBox( height: 50, ), - const Padding( - padding: EdgeInsets.only(left: 10, bottom: 5), - child: Text( - 'Cache home:', - style: TextStyle( - color: Colors.black87, - fontSize: 18, - ), - ), - ), - Container( - margin: const EdgeInsets.symmetric(horizontal: 10), - padding: const EdgeInsets.symmetric( - horizontal: 20, - vertical: 5, - ), - color: Colors.black38, - child: Text( - cacheHome.path, - style: const TextStyle( - color: Colors.white, - ), - ), + DirectoryDisplay( + title: 'Cache home:', + value: cacheHome.path, ), const SizedBox( height: 50, @@ -171,19 +112,9 @@ class _MyHomePageState extends State { ListView.builder( shrinkWrap: true, itemCount: configDirs.length, - itemBuilder: (BuildContext context, int index) => Container( - margin: const EdgeInsets.symmetric(horizontal: 10, vertical: 2), - padding: const EdgeInsets.symmetric( - horizontal: 20, - vertical: 5, - ), - color: Colors.black38, - child: Text( - configDirs[index].path, - style: const TextStyle( - color: Colors.white, - ), - ), + itemBuilder: (BuildContext context, int index) => + directoryTextWidget( + configDirs[index].path, ), ), const SizedBox( @@ -202,24 +133,22 @@ class _MyHomePageState extends State { ListView.builder( shrinkWrap: true, itemCount: dataDirs.length, - itemBuilder: (BuildContext context, int index) => Container( - margin: const EdgeInsets.symmetric(horizontal: 10, vertical: 2), - padding: const EdgeInsets.symmetric( - horizontal: 20, - vertical: 5, - ), - color: Colors.black38, - child: Text( - dataDirs[index].path, - style: const TextStyle( - color: Colors.white, - ), - ), + itemBuilder: (BuildContext context, int index) => + DirectoryDisplay( + title: 'Selected directory:', + value: userDirectory, + ), + directoryTextWidget( + dataDirs[index].path, ), ), const SizedBox( height: 50, ), + DirectoryDisplay( + title: 'Selected directory:', + value: userDirectory, + ), const Padding( padding: EdgeInsets.only(left: 10, bottom: 5), child: Text( @@ -230,23 +159,14 @@ class _MyHomePageState extends State { ), ), ), - Container( - margin: const EdgeInsets.symmetric(horizontal: 10), - padding: const EdgeInsets.symmetric( - horizontal: 20, - vertical: 5, - ), - color: Colors.black38, - child: Text( - configHome.path, - style: const TextStyle( - color: Colors.white, - ), - ), - ), + directoryTextWidget(configHome.path), const SizedBox( height: 50, ), + DirectoryDisplay( + title: 'Selected directory:', + value: userDirectory, + ), const Padding( padding: EdgeInsets.only(left: 10, bottom: 5), child: Text( @@ -257,20 +177,7 @@ class _MyHomePageState extends State { ), ), ), - Container( - margin: const EdgeInsets.symmetric(horizontal: 10), - padding: const EdgeInsets.symmetric( - horizontal: 20, - vertical: 5, - ), - color: Colors.black38, - child: Text( - dataHome.path, - style: const TextStyle( - color: Colors.white, - ), - ), - ), + directoryTextWidget(dataHome.path), const SizedBox( height: 100, ), diff --git a/packages/xdg_directories/example/lib/widgets/DirectoryDisplay.dart b/packages/xdg_directories/example/lib/widgets/DirectoryDisplay.dart new file mode 100644 index 00000000000..4f6ede199e1 --- /dev/null +++ b/packages/xdg_directories/example/lib/widgets/DirectoryDisplay.dart @@ -0,0 +1,62 @@ +import 'package:flutter/material.dart'; + +/// This is a Widget that displays a title and a directory path for the XDG Directories demo. +class DirectoryDisplay extends StatelessWidget { + /// Constructor + const DirectoryDisplay({ + super.key, + this.title = '', + this.value = '', + }); + + /// + const DirectoryDisplay.listOfValues({ + super.key, + this.title = '', + this.values = const [], + }); + + /// This is the title for the DirectoryDisplay. + /// i.e.: "Selected directory:" + final String title; + + /// This is the directory value to be displayed. + /// i.e.: "/home/user/Videos" + final String? value; + + /// + final List? values; + + @override + Widget build(BuildContext context) { + return Column( + key: key, + children: [ + Container( + margin: const EdgeInsets.symmetric(horizontal: 10, vertical: 2), + padding: const EdgeInsets.symmetric( + horizontal: 20, + vertical: 5, + ), + color: Colors.black38, + child: Text( + title, + style: const TextStyle( + color: Colors.white, + ), + ), + ), + Padding( + padding: const EdgeInsets.only(left: 10, bottom: 5), + child: Text( + value ?? '', + style: const TextStyle( + color: Colors.black87, + fontSize: 18, + ), + ), + ) + ], + ); + } +} From 299779b045651b62447be877dbc49aaf63d0d0fa Mon Sep 17 00:00:00 2001 From: eriko13 Date: Sun, 23 Jul 2023 16:35:00 +0000 Subject: [PATCH 06/38] dry --- .../xdg_directories/example/lib/main.dart | 78 +++-------------- .../example/lib/widgets/DirectoryDisplay.dart | 62 -------------- .../lib/widgets/directory_display.dart | 83 +++++++++++++++++++ 3 files changed, 96 insertions(+), 127 deletions(-) delete mode 100644 packages/xdg_directories/example/lib/widgets/DirectoryDisplay.dart create mode 100644 packages/xdg_directories/example/lib/widgets/directory_display.dart diff --git a/packages/xdg_directories/example/lib/main.dart b/packages/xdg_directories/example/lib/main.dart index 34903ddb54d..552aba8de34 100644 --- a/packages/xdg_directories/example/lib/main.dart +++ b/packages/xdg_directories/example/lib/main.dart @@ -1,8 +1,10 @@ // ignore_for_file: public_member_api_docs +import 'dart:io'; + import 'package:flutter/material.dart'; import 'package:xdg_directories/xdg_directories.dart'; -import 'widgets/DirectoryDisplay.dart'; +import 'widgets/directory_display.dart'; void main() { runApp(const MyApp()); @@ -99,85 +101,31 @@ class _MyHomePageState extends State { const SizedBox( height: 50, ), - const Padding( - padding: EdgeInsets.only(left: 10, bottom: 5), - child: Text( - 'Config directories:', - style: TextStyle( - color: Colors.black87, - fontSize: 18, - ), - ), - ), - ListView.builder( - shrinkWrap: true, - itemCount: configDirs.length, - itemBuilder: (BuildContext context, int index) => - directoryTextWidget( - configDirs[index].path, - ), + DirectoryDisplay.listOfValues( + title: 'Config directories:', + values: configDirs.map((Directory d) => d.path).toList(), ), const SizedBox( height: 50, ), - const Padding( - padding: EdgeInsets.only(left: 10, bottom: 5), - child: Text( - 'Data directories:', - style: TextStyle( - color: Colors.black87, - fontSize: 18, - ), - ), - ), - ListView.builder( - shrinkWrap: true, - itemCount: dataDirs.length, - itemBuilder: (BuildContext context, int index) => - DirectoryDisplay( - title: 'Selected directory:', - value: userDirectory, - ), - directoryTextWidget( - dataDirs[index].path, - ), + DirectoryDisplay.listOfValues( + title: 'Data directories:', + values: dataDirs.map((Directory d) => d.path).toList(), ), const SizedBox( height: 50, ), DirectoryDisplay( - title: 'Selected directory:', - value: userDirectory, - ), - const Padding( - padding: EdgeInsets.only(left: 10, bottom: 5), - child: Text( - 'Config home:', - style: TextStyle( - color: Colors.black87, - fontSize: 18, - ), - ), + title: 'Config home:', + value: configHome.path, ), - directoryTextWidget(configHome.path), const SizedBox( height: 50, ), DirectoryDisplay( - title: 'Selected directory:', - value: userDirectory, - ), - const Padding( - padding: EdgeInsets.only(left: 10, bottom: 5), - child: Text( - 'Data home:', - style: TextStyle( - color: Colors.black87, - fontSize: 18, - ), - ), + title: 'Data home:', + value: dataHome.path, ), - directoryTextWidget(dataHome.path), const SizedBox( height: 100, ), diff --git a/packages/xdg_directories/example/lib/widgets/DirectoryDisplay.dart b/packages/xdg_directories/example/lib/widgets/DirectoryDisplay.dart deleted file mode 100644 index 4f6ede199e1..00000000000 --- a/packages/xdg_directories/example/lib/widgets/DirectoryDisplay.dart +++ /dev/null @@ -1,62 +0,0 @@ -import 'package:flutter/material.dart'; - -/// This is a Widget that displays a title and a directory path for the XDG Directories demo. -class DirectoryDisplay extends StatelessWidget { - /// Constructor - const DirectoryDisplay({ - super.key, - this.title = '', - this.value = '', - }); - - /// - const DirectoryDisplay.listOfValues({ - super.key, - this.title = '', - this.values = const [], - }); - - /// This is the title for the DirectoryDisplay. - /// i.e.: "Selected directory:" - final String title; - - /// This is the directory value to be displayed. - /// i.e.: "/home/user/Videos" - final String? value; - - /// - final List? values; - - @override - Widget build(BuildContext context) { - return Column( - key: key, - children: [ - Container( - margin: const EdgeInsets.symmetric(horizontal: 10, vertical: 2), - padding: const EdgeInsets.symmetric( - horizontal: 20, - vertical: 5, - ), - color: Colors.black38, - child: Text( - title, - style: const TextStyle( - color: Colors.white, - ), - ), - ), - Padding( - padding: const EdgeInsets.only(left: 10, bottom: 5), - child: Text( - value ?? '', - style: const TextStyle( - color: Colors.black87, - fontSize: 18, - ), - ), - ) - ], - ); - } -} diff --git a/packages/xdg_directories/example/lib/widgets/directory_display.dart b/packages/xdg_directories/example/lib/widgets/directory_display.dart new file mode 100644 index 00000000000..a20b4a4bb25 --- /dev/null +++ b/packages/xdg_directories/example/lib/widgets/directory_display.dart @@ -0,0 +1,83 @@ +import 'package:flutter/material.dart'; + +/// This is a Widget that displays a title and a directory path for the XDG Directories demo. +class DirectoryDisplay extends StatelessWidget { + /// Single Directory display + const DirectoryDisplay({ + super.key, + this.title = '', + String? value, + }) : child = value; + + /// List of Directories display + DirectoryDisplay.listOfValues({ + super.key, + this.title = '', + List? values, + }) : assert(values != null), + assert(values!.isNotEmpty), + child = values; + + /// This is the title for the DirectoryDisplay. + /// i.e.: "Selected directory:" + final String title; + + /// This is the directory or directories to be displayed. + final dynamic child; + + @override + Widget build(BuildContext context) { + return Column( + key: key, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: const EdgeInsets.only(left: 10, bottom: 5), + child: Text( + title, + style: const TextStyle( + color: Colors.black87, + fontSize: 18, + ), + ), + ), + if (child is String) + Container( + margin: const EdgeInsets.symmetric(horizontal: 10, vertical: 2), + width: double.infinity, + padding: const EdgeInsets.symmetric( + horizontal: 20, + vertical: 5, + ), + color: Colors.black38, + child: Text( + child as String, + style: const TextStyle( + color: Colors.white, + ), + ), + ) + else if (child is List) + ListView.builder( + shrinkWrap: true, + itemCount: (child as List).length, + itemBuilder: (BuildContext context, int index) => Container( + margin: const EdgeInsets.symmetric(horizontal: 10, vertical: 2), + width: double.infinity, + padding: const EdgeInsets.symmetric( + horizontal: 20, + vertical: 5, + ), + color: Colors.black38, + child: Text( + (child as List)[index], + style: const TextStyle( + color: Colors.white, + ), + ), + ), + ), + ], + ); + } +} From e5ffdc129872c23df99e91980255d63c349ff143 Mon Sep 17 00:00:00 2001 From: eriko13 Date: Sun, 23 Jul 2023 16:43:10 +0000 Subject: [PATCH 07/38] reorganized fields --- .../xdg_directories/example/lib/main.dart | 24 +++++++++---------- .../lib/widgets/directory_display.dart | 3 ++- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/packages/xdg_directories/example/lib/main.dart b/packages/xdg_directories/example/lib/main.dart index 552aba8de34..93abff32ba9 100644 --- a/packages/xdg_directories/example/lib/main.dart +++ b/packages/xdg_directories/example/lib/main.dart @@ -88,43 +88,43 @@ class _MyHomePageState extends State { height: 50, ), DirectoryDisplay( - title: 'Runtime directory:', - value: runtimeDir?.path, + title: 'Data home:', + value: dataHome.path, ), const SizedBox( height: 50, ), DirectoryDisplay( - title: 'Cache home:', - value: cacheHome.path, + title: 'Config home:', + value: configHome.path, ), const SizedBox( height: 50, ), DirectoryDisplay.listOfValues( - title: 'Config directories:', - values: configDirs.map((Directory d) => d.path).toList(), + title: 'Data directories:', + values: dataDirs.map((Directory d) => d.path).toList(), ), const SizedBox( height: 50, ), DirectoryDisplay.listOfValues( - title: 'Data directories:', - values: dataDirs.map((Directory d) => d.path).toList(), + title: 'Config directories:', + values: configDirs.map((Directory d) => d.path).toList(), ), const SizedBox( height: 50, ), DirectoryDisplay( - title: 'Config home:', - value: configHome.path, + title: 'Cache home:', + value: cacheHome.path, ), const SizedBox( height: 50, ), DirectoryDisplay( - title: 'Data home:', - value: dataHome.path, + title: 'Runtime directory:', + value: runtimeDir?.path, ), const SizedBox( height: 100, diff --git a/packages/xdg_directories/example/lib/widgets/directory_display.dart b/packages/xdg_directories/example/lib/widgets/directory_display.dart index a20b4a4bb25..3abaecc30bd 100644 --- a/packages/xdg_directories/example/lib/widgets/directory_display.dart +++ b/packages/xdg_directories/example/lib/widgets/directory_display.dart @@ -7,7 +7,8 @@ class DirectoryDisplay extends StatelessWidget { super.key, this.title = '', String? value, - }) : child = value; + }) : assert(value != null), + child = value; /// List of Directories display DirectoryDisplay.listOfValues({ From 5d7e22152eaebab225c0cbca6e74d0b0b0307a9b Mon Sep 17 00:00:00 2001 From: eriko13 Date: Sun, 23 Jul 2023 23:07:48 +0000 Subject: [PATCH 08/38] adding tests --- .../xdg_directories/example/lib/main.dart | 1 - .../example/test/widget_test.dart | 22 -------------- .../example/test/xdg_directories_test.dart | 29 +++++++++++++++++++ 3 files changed, 29 insertions(+), 23 deletions(-) delete mode 100644 packages/xdg_directories/example/test/widget_test.dart create mode 100644 packages/xdg_directories/example/test/xdg_directories_test.dart diff --git a/packages/xdg_directories/example/lib/main.dart b/packages/xdg_directories/example/lib/main.dart index 93abff32ba9..af173a4152c 100644 --- a/packages/xdg_directories/example/lib/main.dart +++ b/packages/xdg_directories/example/lib/main.dart @@ -1,7 +1,6 @@ // ignore_for_file: public_member_api_docs import 'dart:io'; - import 'package:flutter/material.dart'; import 'package:xdg_directories/xdg_directories.dart'; import 'widgets/directory_display.dart'; diff --git a/packages/xdg_directories/example/test/widget_test.dart b/packages/xdg_directories/example/test/widget_test.dart deleted file mode 100644 index b781bf56978..00000000000 --- a/packages/xdg_directories/example/test/widget_test.dart +++ /dev/null @@ -1,22 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter_test/flutter_test.dart'; -import 'package:xdg_directories_example/main.dart'; - -void main() { - testWidgets('Counter increments smoke test', (WidgetTester tester) async { - // Build our app and trigger a frame. - await tester.pumpWidget(const MyApp()); - - // Verify that our counter starts at 0. - expect(find.text('0'), findsOneWidget); - expect(find.text('1'), findsNothing); - - // Tap the '+' icon and trigger a frame. - await tester.tap(find.byIcon(Icons.add)); - await tester.pump(); - - // Verify that our counter has incremented. - expect(find.text('0'), findsNothing); - expect(find.text('1'), findsOneWidget); - }); -} diff --git a/packages/xdg_directories/example/test/xdg_directories_test.dart b/packages/xdg_directories/example/test/xdg_directories_test.dart new file mode 100644 index 00000000000..3c30caf1840 --- /dev/null +++ b/packages/xdg_directories/example/test/xdg_directories_test.dart @@ -0,0 +1,29 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'dart:io' show Platform; +import 'package:flutter/foundation.dart' show kIsWeb; +import 'package:integration_test/integration_test.dart'; +import 'package:xdg_directories/xdg_directories.dart'; + +void main() { + IntegrationTestWidgetsFlutterBinding.ensureInitialized(); + + testWidgets('XDG Directories', (WidgetTester _) async { + expect(getUserDirectoryNames(), Set, reason: ''); + + // Generally all devices should have some default browser. + expect(await canLaunchUrl(Uri(scheme: 'http', host: 'flutter.dev')), true); + expect(await canLaunchUrl(Uri(scheme: 'https', host: 'flutter.dev')), true); + + // SMS handling is available by default on most platforms. + if (kIsWeb || !(Platform.isLinux || Platform.isWindows)) { + expect(await canLaunchUrl(Uri(scheme: 'sms', path: '5555555555')), true); + } + + // Sanity-check legacy API. + // ignore: deprecated_member_use + expect(await canLaunch('randomstring'), false); + // Generally all devices should have some default browser. + // ignore: deprecated_member_use + expect(await canLaunch('https://flutter.dev'), true); + }); +} From 5dd8d27351869fe02891f62d915f028a75477ec5 Mon Sep 17 00:00:00 2001 From: eriko13 Date: Sun, 23 Jul 2023 16:22:34 -0700 Subject: [PATCH 09/38] created unit tests --- .../example/test/xdg_directories_test.dart | 78 +++++++++++++++---- 1 file changed, 62 insertions(+), 16 deletions(-) diff --git a/packages/xdg_directories/example/test/xdg_directories_test.dart b/packages/xdg_directories/example/test/xdg_directories_test.dart index 3c30caf1840..57fdbb0aeaf 100644 --- a/packages/xdg_directories/example/test/xdg_directories_test.dart +++ b/packages/xdg_directories/example/test/xdg_directories_test.dart @@ -1,6 +1,5 @@ +import 'dart:io' show Directory, Platform; import 'package:flutter_test/flutter_test.dart'; -import 'dart:io' show Platform; -import 'package:flutter/foundation.dart' show kIsWeb; import 'package:integration_test/integration_test.dart'; import 'package:xdg_directories/xdg_directories.dart'; @@ -8,22 +7,69 @@ void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); testWidgets('XDG Directories', (WidgetTester _) async { - expect(getUserDirectoryNames(), Set, reason: ''); + if (!Platform.isLinux) { + throw Exception('This test is only valid on Linux'); + } - // Generally all devices should have some default browser. - expect(await canLaunchUrl(Uri(scheme: 'http', host: 'flutter.dev')), true); - expect(await canLaunchUrl(Uri(scheme: 'https', host: 'flutter.dev')), true); + // Check that the XDG directories are valid. + expect(getUserDirectoryNames(), Set, + reason: 'getUserDirectoryNames() should return a Set'); - // SMS handling is available by default on most platforms. - if (kIsWeb || !(Platform.isLinux || Platform.isWindows)) { - expect(await canLaunchUrl(Uri(scheme: 'sms', path: '5555555555')), true); - } + expect( + getUserDirectoryNames().length, + isNot(0), + reason: 'getUserDirectoryNames() should return a non-empty Set', + ); + + final Set userDirectoryNames = getUserDirectoryNames(); + + expect( + getUserDirectory(userDirectoryNames.first), + Directory, + reason: 'getUserDirectory() should return a Directory', + ); + + expect( + getUserDirectory('randomString'), + null, + reason: + 'getUserDirectory() should return null if the directory does not exist', + ); + + expect( + dataHome, + Directory, + reason: 'dataHome should return a Directory', + ); + + expect( + configHome, + Directory, + reason: 'configHome should return a Directory', + ); + + expect( + cacheHome, + Directory, + reason: 'cacheHome should return a Directory', + ); + + expect( + runtimeDir, + Directory, + reason: 'runtimeDir should return a Directory', + ); + + expect( + dataDirs, + List, + reason: 'dataDirs should return a List', + ); - // Sanity-check legacy API. - // ignore: deprecated_member_use - expect(await canLaunch('randomstring'), false); - // Generally all devices should have some default browser. - // ignore: deprecated_member_use - expect(await canLaunch('https://flutter.dev'), true); + expect( + configDirs, + List, + reason: 'configDirs should return a List', + ); }); } From 6d49031b829fb8ff040d617510144afeb5573b64 Mon Sep 17 00:00:00 2001 From: eriko13 Date: Sun, 23 Jul 2023 16:24:49 -0700 Subject: [PATCH 10/38] added documentation --- .../example/test/xdg_directories_test.dart | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/xdg_directories/example/test/xdg_directories_test.dart b/packages/xdg_directories/example/test/xdg_directories_test.dart index 57fdbb0aeaf..4653da990ca 100644 --- a/packages/xdg_directories/example/test/xdg_directories_test.dart +++ b/packages/xdg_directories/example/test/xdg_directories_test.dart @@ -7,6 +7,7 @@ void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); testWidgets('XDG Directories', (WidgetTester _) async { + // Check that the test is running on Linux. if (!Platform.isLinux) { throw Exception('This test is only valid on Linux'); } @@ -15,6 +16,7 @@ void main() { expect(getUserDirectoryNames(), Set, reason: 'getUserDirectoryNames() should return a Set'); + // Check that the XDG directories are not empty. expect( getUserDirectoryNames().length, isNot(0), @@ -23,12 +25,14 @@ void main() { final Set userDirectoryNames = getUserDirectoryNames(); + // Check that getUserDirectory() returns a Directory. expect( getUserDirectory(userDirectoryNames.first), Directory, reason: 'getUserDirectory() should return a Directory', ); + // Check that getUserDirectory() returns null if the directory does not exist. expect( getUserDirectory('randomString'), null, @@ -36,36 +40,42 @@ void main() { 'getUserDirectory() should return null if the directory does not exist', ); + // Check that dataHome returns a Directory. expect( dataHome, Directory, reason: 'dataHome should return a Directory', ); + // Check that configHome returns a Directory. expect( configHome, Directory, reason: 'configHome should return a Directory', ); + // Check that cacheHome returns a Directory. expect( cacheHome, Directory, reason: 'cacheHome should return a Directory', ); + // Check that runtimeDir returns a Directory. expect( runtimeDir, Directory, reason: 'runtimeDir should return a Directory', ); + // Check that dataDirs returns a List. expect( dataDirs, List, reason: 'dataDirs should return a List', ); + // Check that configDirs returns a List. expect( configDirs, List, From 3671329710f764e89b8478cd3f0456fa1cd49164 Mon Sep 17 00:00:00 2001 From: eriko13 Date: Mon, 24 Jul 2023 00:19:01 +0000 Subject: [PATCH 11/38] fixed tests --- .../xdg_directories_test.dart | 45 ++++++------------- 1 file changed, 13 insertions(+), 32 deletions(-) rename packages/xdg_directories/example/{test => integration_test}/xdg_directories_test.dart (63%) diff --git a/packages/xdg_directories/example/test/xdg_directories_test.dart b/packages/xdg_directories/example/integration_test/xdg_directories_test.dart similarity index 63% rename from packages/xdg_directories/example/test/xdg_directories_test.dart rename to packages/xdg_directories/example/integration_test/xdg_directories_test.dart index 4653da990ca..5327c631ae0 100644 --- a/packages/xdg_directories/example/test/xdg_directories_test.dart +++ b/packages/xdg_directories/example/integration_test/xdg_directories_test.dart @@ -1,4 +1,4 @@ -import 'dart:io' show Directory, Platform; +import 'dart:io' show Platform; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; import 'package:xdg_directories/xdg_directories.dart'; @@ -12,10 +12,6 @@ void main() { throw Exception('This test is only valid on Linux'); } - // Check that the XDG directories are valid. - expect(getUserDirectoryNames(), Set, - reason: 'getUserDirectoryNames() should return a Set'); - // Check that the XDG directories are not empty. expect( getUserDirectoryNames().length, @@ -27,58 +23,43 @@ void main() { // Check that getUserDirectory() returns a Directory. expect( - getUserDirectory(userDirectoryNames.first), - Directory, + getUserDirectory(userDirectoryNames.first) != null, + true, reason: 'getUserDirectory() should return a Directory', ); - // Check that getUserDirectory() returns null if the directory does not exist. - expect( - getUserDirectory('randomString'), - null, - reason: - 'getUserDirectory() should return null if the directory does not exist', - ); - // Check that dataHome returns a Directory. expect( - dataHome, - Directory, + dataHome.path.isNotEmpty, + true, reason: 'dataHome should return a Directory', ); // Check that configHome returns a Directory. expect( - configHome, - Directory, + configHome.path.isNotEmpty, + true, reason: 'configHome should return a Directory', ); // Check that cacheHome returns a Directory. expect( - cacheHome, - Directory, + cacheHome.path.isNotEmpty, + true, reason: 'cacheHome should return a Directory', ); - // Check that runtimeDir returns a Directory. - expect( - runtimeDir, - Directory, - reason: 'runtimeDir should return a Directory', - ); - // Check that dataDirs returns a List. expect( - dataDirs, - List, + dataDirs.isNotEmpty, + true, reason: 'dataDirs should return a List', ); // Check that configDirs returns a List. expect( - configDirs, - List, + configDirs.isNotEmpty, + true, reason: 'configDirs should return a List', ); }); From aa479918df23947a78028ba88ccee9ed8802b2c5 Mon Sep 17 00:00:00 2001 From: eriko13 Date: Mon, 24 Jul 2023 00:20:35 +0000 Subject: [PATCH 12/38] cleanup --- .../xdg_directories/example/lib/main.dart | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/xdg_directories/example/lib/main.dart b/packages/xdg_directories/example/lib/main.dart index af173a4152c..911eb3ceeb5 100644 --- a/packages/xdg_directories/example/lib/main.dart +++ b/packages/xdg_directories/example/lib/main.dart @@ -35,11 +35,11 @@ class MyHomePage extends StatefulWidget { } class _MyHomePageState extends State { - String userDirectory = ''; + final Set userDirectoryNames = getUserDirectoryNames(); + String selectedUserDirectory = ''; @override Widget build(BuildContext context) { - final Set userDirectoryNames = getUserDirectoryNames(); return Scaffold( appBar: AppBar( backgroundColor: Theme.of(context).colorScheme.inversePrimary, @@ -68,7 +68,7 @@ class _MyHomePageState extends State { visualDensity: VisualDensity.standard, onTap: () => setState( () { - userDirectory = + selectedUserDirectory = getUserDirectory(userDirectoryNames.elementAt(index)) ?.path ?? ''; @@ -81,48 +81,48 @@ class _MyHomePageState extends State { ), DirectoryDisplay( title: 'Selected directory:', - value: userDirectory, + value: selectedUserDirectory, ), const SizedBox( height: 50, ), DirectoryDisplay( - title: 'Data home:', + title: 'Data Home:', value: dataHome.path, ), const SizedBox( height: 50, ), DirectoryDisplay( - title: 'Config home:', + title: 'Config Home:', value: configHome.path, ), const SizedBox( height: 50, ), DirectoryDisplay.listOfValues( - title: 'Data directories:', + title: 'Data Directories:', values: dataDirs.map((Directory d) => d.path).toList(), ), const SizedBox( height: 50, ), DirectoryDisplay.listOfValues( - title: 'Config directories:', + title: 'Config Directories:', values: configDirs.map((Directory d) => d.path).toList(), ), const SizedBox( height: 50, ), DirectoryDisplay( - title: 'Cache home:', + title: 'Cache Home:', value: cacheHome.path, ), const SizedBox( height: 50, ), DirectoryDisplay( - title: 'Runtime directory:', + title: 'Runtime Directory:', value: runtimeDir?.path, ), const SizedBox( From d73eca223ce01bb91c0c9b477a023ace392cd8ca Mon Sep 17 00:00:00 2001 From: Erik German Date: Sun, 23 Jul 2023 17:32:58 -0700 Subject: [PATCH 13/38] Update README.md --- packages/xdg_directories/example/README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/xdg_directories/example/README.md b/packages/xdg_directories/example/README.md index 6a67d5ca557..915621b4e7f 100644 --- a/packages/xdg_directories/example/README.md +++ b/packages/xdg_directories/example/README.md @@ -1,3 +1,6 @@ # xdg_directories_example Demonstrates how to use the xdg_directories_example plugin. + + +![xdg_directories_demo](https://github.com/eriko13/packages/assets/36830415/7798a4ac-ddd1-4aab-8065-40802862776f) From 6001efd32be158081e58b1ce58b57951307d3816 Mon Sep 17 00:00:00 2001 From: eriko13 Date: Sun, 23 Jul 2023 17:34:18 -0700 Subject: [PATCH 14/38] typo --- packages/xdg_directories/example/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/xdg_directories/example/README.md b/packages/xdg_directories/example/README.md index 915621b4e7f..1c5a7ff949e 100644 --- a/packages/xdg_directories/example/README.md +++ b/packages/xdg_directories/example/README.md @@ -1,6 +1,6 @@ # xdg_directories_example -Demonstrates how to use the xdg_directories_example plugin. +Demonstrates how to use the xdg_directories plugin. ![xdg_directories_demo](https://github.com/eriko13/packages/assets/36830415/7798a4ac-ddd1-4aab-8065-40802862776f) From 02a7d666e852e2ec5024ac9e31fd5494a893877d Mon Sep 17 00:00:00 2001 From: eriko13 Date: Sun, 23 Jul 2023 18:03:09 -0700 Subject: [PATCH 15/38] updated readme --- packages/xdg_directories/example/README.md | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/packages/xdg_directories/example/README.md b/packages/xdg_directories/example/README.md index 1c5a7ff949e..9c258e07def 100644 --- a/packages/xdg_directories/example/README.md +++ b/packages/xdg_directories/example/README.md @@ -1,6 +1,20 @@ -# xdg_directories_example +# XDG Directories Demo -Demonstrates how to use the xdg_directories plugin. +## Description +This is a simple demo of the XDG directories. It is a flutter app that +uses the XDG directories to read xdg directories and display them in a +list. It also has a button to create a simple text file in the xdg data directory. + +## Run + +To run the demo, run the following command: + +```bash +flutter run +``` + +## Screenshots ![xdg_directories_demo](https://github.com/eriko13/packages/assets/36830415/7798a4ac-ddd1-4aab-8065-40802862776f) + From 0e2b96ba0c0e0a74961cbb412c9c362d50db4ae3 Mon Sep 17 00:00:00 2001 From: eriko13 Date: Sun, 23 Jul 2023 18:04:15 -0700 Subject: [PATCH 16/38] update readme --- packages/xdg_directories/example/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/xdg_directories/example/README.md b/packages/xdg_directories/example/README.md index 9c258e07def..1464a48347d 100644 --- a/packages/xdg_directories/example/README.md +++ b/packages/xdg_directories/example/README.md @@ -3,7 +3,7 @@ ## Description This is a simple demo of the XDG directories. It is a flutter app that -uses the XDG directories to read xdg directories and display them in a +uses the xdg_directories dependencie to read xdg directory names and display them in a list. It also has a button to create a simple text file in the xdg data directory. ## Run From 99117f0c6dbae42e2da58806257c71a9b05550b2 Mon Sep 17 00:00:00 2001 From: eriko13 Date: Sun, 23 Jul 2023 18:11:59 -0700 Subject: [PATCH 17/38] readme --- packages/xdg_directories/example/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/xdg_directories/example/README.md b/packages/xdg_directories/example/README.md index 1464a48347d..40f019d0513 100644 --- a/packages/xdg_directories/example/README.md +++ b/packages/xdg_directories/example/README.md @@ -4,7 +4,7 @@ This is a simple demo of the XDG directories. It is a flutter app that uses the xdg_directories dependencie to read xdg directory names and display them in a -list. It also has a button to create a simple text file in the xdg data directory. +list. ## Run From 064bd39956190cb4aa6f4e64a748760bb91526b4 Mon Sep 17 00:00:00 2001 From: eriko13 Date: Sun, 23 Jul 2023 18:14:48 -0700 Subject: [PATCH 18/38] rename --- packages/xdg_directories/example/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/xdg_directories/example/README.md b/packages/xdg_directories/example/README.md index 40f019d0513..62507422dae 100644 --- a/packages/xdg_directories/example/README.md +++ b/packages/xdg_directories/example/README.md @@ -3,7 +3,7 @@ ## Description This is a simple demo of the XDG directories. It is a flutter app that -uses the xdg_directories dependencie to read xdg directory names and display them in a +uses the xdg_directories package to read xdg directory names and display them in a list. ## Run From 2494d5ab5591b67dfb9b4da0aac9b1f3e11f09ef Mon Sep 17 00:00:00 2001 From: eriko13 Date: Sun, 23 Jul 2023 21:28:54 -0700 Subject: [PATCH 19/38] bumped version and added changelog --- packages/xdg_directories/CHANGELOG.md | 3 +++ packages/xdg_directories/pubspec.yaml | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/xdg_directories/CHANGELOG.md b/packages/xdg_directories/CHANGELOG.md index ff8640df04d..aafce6e78dc 100644 --- a/packages/xdg_directories/CHANGELOG.md +++ b/packages/xdg_directories/CHANGELOG.md @@ -1,3 +1,6 @@ +## 1.0.2 +* Adds example app to demonstrate how to use the package. + ## 1.0.1 * Removes `process` dependency. diff --git a/packages/xdg_directories/pubspec.yaml b/packages/xdg_directories/pubspec.yaml index e9c46285da8..091bccd10bd 100644 --- a/packages/xdg_directories/pubspec.yaml +++ b/packages/xdg_directories/pubspec.yaml @@ -2,7 +2,7 @@ name: xdg_directories description: A Dart package for reading XDG directory configuration information on Linux. repository: https://github.com/flutter/packages/tree/main/packages/xdg_directories issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+xdg_directories%22 -version: 1.0.1 +version: 1.0.2 environment: sdk: ">=2.18.0 <4.0.0" From 8ac103a87087172a6c9d160908a96ee238ec740c Mon Sep 17 00:00:00 2001 From: eriko13 Date: Mon, 24 Jul 2023 06:30:47 +0000 Subject: [PATCH 20/38] run clang-format --- .../example/linux/my_application.cc | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/packages/xdg_directories/example/linux/my_application.cc b/packages/xdg_directories/example/linux/my_application.cc index 7b22c28ecf3..427a69a248b 100644 --- a/packages/xdg_directories/example/linux/my_application.cc +++ b/packages/xdg_directories/example/linux/my_application.cc @@ -51,7 +51,8 @@ static void my_application_activate(GApplication* application) { gtk_widget_show(GTK_WIDGET(window)); g_autoptr(FlDartProject) project = fl_dart_project_new(); - fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments); + fl_dart_project_set_dart_entrypoint_arguments( + project, self->dart_entrypoint_arguments); FlView* view = fl_view_new(project); gtk_widget_show(GTK_WIDGET(view)); @@ -63,16 +64,18 @@ static void my_application_activate(GApplication* application) { } // Implements GApplication::local_command_line. -static gboolean my_application_local_command_line(GApplication* application, gchar*** arguments, int* exit_status) { +static gboolean my_application_local_command_line(GApplication* application, + gchar*** arguments, + int* exit_status) { MyApplication* self = MY_APPLICATION(application); // Strip out the first argument as it is the binary name. self->dart_entrypoint_arguments = g_strdupv(*arguments + 1); g_autoptr(GError) error = nullptr; if (!g_application_register(application, nullptr, &error)) { - g_warning("Failed to register: %s", error->message); - *exit_status = 1; - return TRUE; + g_warning("Failed to register: %s", error->message); + *exit_status = 1; + return TRUE; } g_application_activate(application); @@ -90,7 +93,8 @@ static void my_application_dispose(GObject* object) { static void my_application_class_init(MyApplicationClass* klass) { G_APPLICATION_CLASS(klass)->activate = my_application_activate; - G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line; + G_APPLICATION_CLASS(klass)->local_command_line = + my_application_local_command_line; G_OBJECT_CLASS(klass)->dispose = my_application_dispose; } @@ -98,7 +102,6 @@ static void my_application_init(MyApplication* self) {} MyApplication* my_application_new() { return MY_APPLICATION(g_object_new(my_application_get_type(), - "application-id", APPLICATION_ID, - "flags", G_APPLICATION_NON_UNIQUE, - nullptr)); + "application-id", APPLICATION_ID, "flags", + G_APPLICATION_NON_UNIQUE, nullptr)); } From cd262fb8506314007af02aa93547b55c3323a6a1 Mon Sep 17 00:00:00 2001 From: eriko13 Date: Mon, 24 Jul 2023 06:37:45 +0000 Subject: [PATCH 21/38] specified lower dart sdk --- packages/xdg_directories/example/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/xdg_directories/example/pubspec.yaml b/packages/xdg_directories/example/pubspec.yaml index 0e3569953e1..dc0d8d29b2f 100644 --- a/packages/xdg_directories/example/pubspec.yaml +++ b/packages/xdg_directories/example/pubspec.yaml @@ -3,7 +3,7 @@ description: Demonstrates how to use the video_player plugin. publish_to: 'none' environment: - sdk: '>=3.0.6 <4.0.0' + sdk: ">=2.18.0 <4.0.0" flutter: ">=3.3.0" dependencies: From 9ced453c031f4392eaab451170c4ccba863e7405 Mon Sep 17 00:00:00 2001 From: eriko13 Date: Sun, 23 Jul 2023 23:44:56 -0700 Subject: [PATCH 22/38] added license --- .../example/integration_test/xdg_directories_test.dart | 4 ++++ packages/xdg_directories/example/lib/main.dart | 4 ++++ .../example/lib/widgets/directory_display.dart | 4 ++++ packages/xdg_directories/example/linux/main.cc | 4 ++++ packages/xdg_directories/example/linux/my_application.cc | 4 +++- packages/xdg_directories/example/linux/my_application.h | 4 ++++ 6 files changed, 23 insertions(+), 1 deletion(-) diff --git a/packages/xdg_directories/example/integration_test/xdg_directories_test.dart b/packages/xdg_directories/example/integration_test/xdg_directories_test.dart index 5327c631ae0..54d6c05f29d 100644 --- a/packages/xdg_directories/example/integration_test/xdg_directories_test.dart +++ b/packages/xdg_directories/example/integration_test/xdg_directories_test.dart @@ -1,3 +1,7 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + import 'dart:io' show Platform; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; diff --git a/packages/xdg_directories/example/lib/main.dart b/packages/xdg_directories/example/lib/main.dart index 911eb3ceeb5..7708a35ccaa 100644 --- a/packages/xdg_directories/example/lib/main.dart +++ b/packages/xdg_directories/example/lib/main.dart @@ -1,3 +1,7 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + // ignore_for_file: public_member_api_docs import 'dart:io'; diff --git a/packages/xdg_directories/example/lib/widgets/directory_display.dart b/packages/xdg_directories/example/lib/widgets/directory_display.dart index 3abaecc30bd..bfaee4932ee 100644 --- a/packages/xdg_directories/example/lib/widgets/directory_display.dart +++ b/packages/xdg_directories/example/lib/widgets/directory_display.dart @@ -1,3 +1,7 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + import 'package:flutter/material.dart'; /// This is a Widget that displays a title and a directory path for the XDG Directories demo. diff --git a/packages/xdg_directories/example/linux/main.cc b/packages/xdg_directories/example/linux/main.cc index e7c5c543703..1507d02825e 100644 --- a/packages/xdg_directories/example/linux/main.cc +++ b/packages/xdg_directories/example/linux/main.cc @@ -1,3 +1,7 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + #include "my_application.h" int main(int argc, char** argv) { diff --git a/packages/xdg_directories/example/linux/my_application.cc b/packages/xdg_directories/example/linux/my_application.cc index 427a69a248b..96703736c1b 100644 --- a/packages/xdg_directories/example/linux/my_application.cc +++ b/packages/xdg_directories/example/linux/my_application.cc @@ -1,4 +1,6 @@ -#include "my_application.h" +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file.#include "my_application.h" #include #ifdef GDK_WINDOWING_X11 diff --git a/packages/xdg_directories/example/linux/my_application.h b/packages/xdg_directories/example/linux/my_application.h index 72271d5e417..6e9f0c3ff66 100644 --- a/packages/xdg_directories/example/linux/my_application.h +++ b/packages/xdg_directories/example/linux/my_application.h @@ -1,3 +1,7 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + #ifndef FLUTTER_MY_APPLICATION_H_ #define FLUTTER_MY_APPLICATION_H_ From bce39698c107f5247bf999a1c6c855b50b6bb24f Mon Sep 17 00:00:00 2001 From: eriko13 Date: Mon, 24 Jul 2023 06:59:22 +0000 Subject: [PATCH 23/38] fixed my_application.cc --- .../example/linux/my_application.cc | 82 +++---------------- 1 file changed, 11 insertions(+), 71 deletions(-) diff --git a/packages/xdg_directories/example/linux/my_application.cc b/packages/xdg_directories/example/linux/my_application.cc index 96703736c1b..56beaa5789e 100644 --- a/packages/xdg_directories/example/linux/my_application.cc +++ b/packages/xdg_directories/example/linux/my_application.cc @@ -1,60 +1,32 @@ // Copyright 2013 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file.#include "my_application.h" +// found in the LICENSE file. + +#include "my_application.h" #include -#ifdef GDK_WINDOWING_X11 -#include -#endif #include "flutter/generated_plugin_registrant.h" struct _MyApplication { GtkApplication parent_instance; - char** dart_entrypoint_arguments; }; G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION) // Implements GApplication::activate. static void my_application_activate(GApplication* application) { - MyApplication* self = MY_APPLICATION(application); GtkWindow* window = GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application))); - - // Use a header bar when running in GNOME as this is the common style used - // by applications and is the setup most users will be using (e.g. Ubuntu - // desktop). - // If running on X and not using GNOME then just use a traditional title bar - // in case the window manager does more exotic layout, e.g. tiling. - // If running on Wayland assume the header bar will work (may need changing - // if future cases occur). - 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; - } - } -#endif - if (use_header_bar) { - GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new()); - gtk_widget_show(GTK_WIDGET(header_bar)); - gtk_header_bar_set_title(header_bar, "XDG Directories Demo"); - gtk_header_bar_set_show_close_button(header_bar, TRUE); - gtk_window_set_titlebar(window, GTK_WIDGET(header_bar)); - } else { - gtk_window_set_title(window, "XDG Directories Demo"); - } - + GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new()); + gtk_widget_show(GTK_WIDGET(header_bar)); + gtk_header_bar_set_title(header_bar, "example"); + gtk_header_bar_set_show_close_button(header_bar, TRUE); + gtk_window_set_titlebar(window, GTK_WIDGET(header_bar)); gtk_window_set_default_size(window, 1280, 720); gtk_widget_show(GTK_WIDGET(window)); g_autoptr(FlDartProject) project = fl_dart_project_new(); - fl_dart_project_set_dart_entrypoint_arguments( - project, self->dart_entrypoint_arguments); FlView* view = fl_view_new(project); gtk_widget_show(GTK_WIDGET(view)); @@ -65,45 +37,13 @@ static void my_application_activate(GApplication* application) { gtk_widget_grab_focus(GTK_WIDGET(view)); } -// Implements GApplication::local_command_line. -static gboolean my_application_local_command_line(GApplication* application, - gchar*** arguments, - int* exit_status) { - MyApplication* self = MY_APPLICATION(application); - // Strip out the first argument as it is the binary name. - self->dart_entrypoint_arguments = g_strdupv(*arguments + 1); - - g_autoptr(GError) error = nullptr; - if (!g_application_register(application, nullptr, &error)) { - g_warning("Failed to register: %s", error->message); - *exit_status = 1; - return TRUE; - } - - g_application_activate(application); - *exit_status = 0; - - return TRUE; -} - -// Implements GObject::dispose. -static void my_application_dispose(GObject* object) { - MyApplication* self = MY_APPLICATION(object); - g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev); - G_OBJECT_CLASS(my_application_parent_class)->dispose(object); -} - static void my_application_class_init(MyApplicationClass* klass) { G_APPLICATION_CLASS(klass)->activate = my_application_activate; - G_APPLICATION_CLASS(klass)->local_command_line = - my_application_local_command_line; - G_OBJECT_CLASS(klass)->dispose = my_application_dispose; } static void my_application_init(MyApplication* self) {} MyApplication* my_application_new() { - return MY_APPLICATION(g_object_new(my_application_get_type(), - "application-id", APPLICATION_ID, "flags", - G_APPLICATION_NON_UNIQUE, nullptr)); -} + return MY_APPLICATION(g_object_new( + my_application_get_type(), "application-id", APPLICATION_ID, nullptr)); +} \ No newline at end of file From 1c1efcc5645ab2558d9b3d8a7b2dbeb0aa9e6263 Mon Sep 17 00:00:00 2001 From: eriko13 Date: Mon, 24 Jul 2023 07:09:30 +0000 Subject: [PATCH 24/38] fixed tests --- .../integration_test/xdg_directories_test.dart | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/packages/xdg_directories/example/integration_test/xdg_directories_test.dart b/packages/xdg_directories/example/integration_test/xdg_directories_test.dart index 54d6c05f29d..9c19a89637e 100644 --- a/packages/xdg_directories/example/integration_test/xdg_directories_test.dart +++ b/packages/xdg_directories/example/integration_test/xdg_directories_test.dart @@ -16,18 +16,9 @@ void main() { throw Exception('This test is only valid on Linux'); } - // Check that the XDG directories are not empty. - expect( - getUserDirectoryNames().length, - isNot(0), - reason: 'getUserDirectoryNames() should return a non-empty Set', - ); - - final Set userDirectoryNames = getUserDirectoryNames(); - // Check that getUserDirectory() returns a Directory. expect( - getUserDirectory(userDirectoryNames.first) != null, + getUserDirectory('Home') != null, true, reason: 'getUserDirectory() should return a Directory', ); From 9caa17afe2ffc05645a8f877e23de75deeea30f8 Mon Sep 17 00:00:00 2001 From: eriko13 Date: Fri, 28 Jul 2023 13:48:40 -0700 Subject: [PATCH 25/38] add a blank line to changelog --- packages/xdg_directories/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/xdg_directories/CHANGELOG.md b/packages/xdg_directories/CHANGELOG.md index aafce6e78dc..5974e671b4a 100644 --- a/packages/xdg_directories/CHANGELOG.md +++ b/packages/xdg_directories/CHANGELOG.md @@ -1,4 +1,5 @@ ## 1.0.2 + * Adds example app to demonstrate how to use the package. ## 1.0.1 From ab4b79b54f20023b46ff034f86ae900cdb777d29 Mon Sep 17 00:00:00 2001 From: eriko13 Date: Fri, 28 Jul 2023 13:51:02 -0700 Subject: [PATCH 26/38] removed flutter basic commands, and screenshots from readme --- packages/xdg_directories/example/README.md | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/packages/xdg_directories/example/README.md b/packages/xdg_directories/example/README.md index 62507422dae..f1968dd8f6e 100644 --- a/packages/xdg_directories/example/README.md +++ b/packages/xdg_directories/example/README.md @@ -5,16 +5,3 @@ This is a simple demo of the XDG directories. It is a flutter app that uses the xdg_directories package to read xdg directory names and display them in a list. - -## Run - -To run the demo, run the following command: - -```bash -flutter run -``` - -## Screenshots - -![xdg_directories_demo](https://github.com/eriko13/packages/assets/36830415/7798a4ac-ddd1-4aab-8065-40802862776f) - From 7b7692626ff6910ebd6af19defbb0f4a2e6fc7db Mon Sep 17 00:00:00 2001 From: eriko13 Date: Fri, 28 Jul 2023 13:52:11 -0700 Subject: [PATCH 27/38] refactored readme --- packages/xdg_directories/example/README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/xdg_directories/example/README.md b/packages/xdg_directories/example/README.md index f1968dd8f6e..00bda81ace9 100644 --- a/packages/xdg_directories/example/README.md +++ b/packages/xdg_directories/example/README.md @@ -2,6 +2,4 @@ ## Description -This is a simple demo of the XDG directories. It is a flutter app that -uses the xdg_directories package to read xdg directory names and display them in a -list. +This is a simple demo of the xdg_directories package. From da779e314e2b7510c6bf908819c05abaa1375ca9 Mon Sep 17 00:00:00 2001 From: eriko13 Date: Fri, 28 Jul 2023 13:53:12 -0700 Subject: [PATCH 28/38] removed platform assert from tests --- .../example/integration_test/xdg_directories_test.dart | 6 ------ 1 file changed, 6 deletions(-) diff --git a/packages/xdg_directories/example/integration_test/xdg_directories_test.dart b/packages/xdg_directories/example/integration_test/xdg_directories_test.dart index 9c19a89637e..858011b7311 100644 --- a/packages/xdg_directories/example/integration_test/xdg_directories_test.dart +++ b/packages/xdg_directories/example/integration_test/xdg_directories_test.dart @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'dart:io' show Platform; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; import 'package:xdg_directories/xdg_directories.dart'; @@ -11,11 +10,6 @@ void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); testWidgets('XDG Directories', (WidgetTester _) async { - // Check that the test is running on Linux. - if (!Platform.isLinux) { - throw Exception('This test is only valid on Linux'); - } - // Check that getUserDirectory() returns a Directory. expect( getUserDirectory('Home') != null, From d0610e083206858c47b6880b88571bc3784c6b59 Mon Sep 17 00:00:00 2001 From: eriko13 Date: Fri, 28 Jul 2023 13:54:39 -0700 Subject: [PATCH 29/38] removed custom theme --- packages/xdg_directories/example/lib/main.dart | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/packages/xdg_directories/example/lib/main.dart b/packages/xdg_directories/example/lib/main.dart index 7708a35ccaa..c57e09bccba 100644 --- a/packages/xdg_directories/example/lib/main.dart +++ b/packages/xdg_directories/example/lib/main.dart @@ -18,13 +18,9 @@ class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { - return MaterialApp( + return const MaterialApp( title: 'XDG Directories Demo', - theme: ThemeData( - colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple), - useMaterial3: true, - ), - home: const MyHomePage(title: 'XDG Directories Demo'), + home: MyHomePage(title: 'XDG Directories Demo'), ); } } From 7357745bfdb25815da839f9baba075970364210c Mon Sep 17 00:00:00 2001 From: eriko13 Date: Fri, 28 Jul 2023 14:02:35 -0700 Subject: [PATCH 30/38] removed unused build_runner package --- packages/xdg_directories/example/pubspec.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/xdg_directories/example/pubspec.yaml b/packages/xdg_directories/example/pubspec.yaml index dc0d8d29b2f..ed6694deda9 100644 --- a/packages/xdg_directories/example/pubspec.yaml +++ b/packages/xdg_directories/example/pubspec.yaml @@ -18,7 +18,6 @@ dependencies: path: ../ dev_dependencies: - build_runner: ^2.1.10 flutter_test: sdk: flutter integration_test: From 3c86827290c64050d03fab681fc2b496f59d4839 Mon Sep 17 00:00:00 2001 From: eriko13 Date: Fri, 28 Jul 2023 14:03:28 -0700 Subject: [PATCH 31/38] add new line to end of file for my_application.cc --- packages/xdg_directories/example/linux/my_application.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/xdg_directories/example/linux/my_application.cc b/packages/xdg_directories/example/linux/my_application.cc index 56beaa5789e..9cb411ba475 100644 --- a/packages/xdg_directories/example/linux/my_application.cc +++ b/packages/xdg_directories/example/linux/my_application.cc @@ -46,4 +46,4 @@ static void my_application_init(MyApplication* self) {} MyApplication* my_application_new() { return MY_APPLICATION(g_object_new( my_application_get_type(), "application-id", APPLICATION_ID, nullptr)); -} \ No newline at end of file +} From b4b191a2af99bcf6940ca1407b5dafcb319e15bb Mon Sep 17 00:00:00 2001 From: eriko13 Date: Fri, 28 Jul 2023 14:06:45 -0700 Subject: [PATCH 32/38] fixed typo in pubspec description --- packages/xdg_directories/example/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/xdg_directories/example/pubspec.yaml b/packages/xdg_directories/example/pubspec.yaml index ed6694deda9..547da87c164 100644 --- a/packages/xdg_directories/example/pubspec.yaml +++ b/packages/xdg_directories/example/pubspec.yaml @@ -1,5 +1,5 @@ name: xdg_directories_example -description: Demonstrates how to use the video_player plugin. +description: Demonstrates how to use the xdg_directories package. publish_to: 'none' environment: From 020d422274afe15b09a3371e00de44d1eb734e6f Mon Sep 17 00:00:00 2001 From: eriko13 Date: Sun, 30 Jul 2023 20:45:01 -0700 Subject: [PATCH 33/38] removed widget file --- .../xdg_directories/example/lib/main.dart | 107 +++++++++++++++--- .../lib/widgets/directory_display.dart | 88 -------------- 2 files changed, 92 insertions(+), 103 deletions(-) delete mode 100644 packages/xdg_directories/example/lib/widgets/directory_display.dart diff --git a/packages/xdg_directories/example/lib/main.dart b/packages/xdg_directories/example/lib/main.dart index c57e09bccba..2d438a3b95c 100644 --- a/packages/xdg_directories/example/lib/main.dart +++ b/packages/xdg_directories/example/lib/main.dart @@ -7,7 +7,6 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:xdg_directories/xdg_directories.dart'; -import 'widgets/directory_display.dart'; void main() { runApp(const MyApp()); @@ -79,51 +78,51 @@ class _MyHomePageState extends State { const SizedBox( height: 20, ), - DirectoryDisplay( + _singleDirectoryPath( title: 'Selected directory:', - value: selectedUserDirectory, + path: selectedUserDirectory, ), const SizedBox( height: 50, ), - DirectoryDisplay( + _singleDirectoryPath( title: 'Data Home:', - value: dataHome.path, + path: dataHome.path, ), const SizedBox( height: 50, ), - DirectoryDisplay( + _singleDirectoryPath( title: 'Config Home:', - value: configHome.path, + path: configHome.path, ), const SizedBox( height: 50, ), - DirectoryDisplay.listOfValues( + _listOfDirectoryPaths( title: 'Data Directories:', - values: dataDirs.map((Directory d) => d.path).toList(), + paths: dataDirs.map((Directory d) => d.path).toList(), ), const SizedBox( height: 50, ), - DirectoryDisplay.listOfValues( + _listOfDirectoryPaths( title: 'Config Directories:', - values: configDirs.map((Directory d) => d.path).toList(), + paths: configDirs.map((Directory d) => d.path).toList(), ), const SizedBox( height: 50, ), - DirectoryDisplay( + _singleDirectoryPath( title: 'Cache Home:', - value: cacheHome.path, + path: cacheHome.path, ), const SizedBox( height: 50, ), - DirectoryDisplay( + _singleDirectoryPath( title: 'Runtime Directory:', - value: runtimeDir?.path, + path: runtimeDir?.path, ), const SizedBox( height: 100, @@ -134,3 +133,81 @@ class _MyHomePageState extends State { ); } } + +/// This is a Widget that displays a title and a directory path. +Widget _singleDirectoryPath({ + required String title, + String? path, +}) { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: const EdgeInsets.only(left: 10, bottom: 5), + child: Text( + title, + style: const TextStyle( + color: Colors.black87, + fontSize: 18, + ), + ), + ), + Container( + margin: const EdgeInsets.symmetric(horizontal: 10, vertical: 2), + width: double.infinity, + padding: const EdgeInsets.symmetric( + horizontal: 20, + vertical: 5, + ), + color: Colors.black38, + child: Text( + path ?? '', + style: const TextStyle( + color: Colors.white, + ), + ), + ), + ], + ); +} + +/// This is a Widget that displays a title and a list of directory paths. +Widget _listOfDirectoryPaths({ + required String title, + required List paths, +}) { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: const EdgeInsets.only(left: 10, bottom: 5), + child: Text( + title, + style: const TextStyle( + color: Colors.black87, + fontSize: 18, + ), + ), + ), + ListView.builder( + shrinkWrap: true, + itemCount: paths.length, + itemBuilder: (BuildContext context, int index) => Container( + margin: const EdgeInsets.symmetric(horizontal: 10, vertical: 2), + width: double.infinity, + padding: const EdgeInsets.symmetric( + horizontal: 20, + vertical: 5, + ), + color: Colors.black38, + child: Text( + paths[index], + style: const TextStyle( + color: Colors.white, + ), + ), + ), + ), + ], + ); +} diff --git a/packages/xdg_directories/example/lib/widgets/directory_display.dart b/packages/xdg_directories/example/lib/widgets/directory_display.dart deleted file mode 100644 index bfaee4932ee..00000000000 --- a/packages/xdg_directories/example/lib/widgets/directory_display.dart +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright 2013 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'package:flutter/material.dart'; - -/// This is a Widget that displays a title and a directory path for the XDG Directories demo. -class DirectoryDisplay extends StatelessWidget { - /// Single Directory display - const DirectoryDisplay({ - super.key, - this.title = '', - String? value, - }) : assert(value != null), - child = value; - - /// List of Directories display - DirectoryDisplay.listOfValues({ - super.key, - this.title = '', - List? values, - }) : assert(values != null), - assert(values!.isNotEmpty), - child = values; - - /// This is the title for the DirectoryDisplay. - /// i.e.: "Selected directory:" - final String title; - - /// This is the directory or directories to be displayed. - final dynamic child; - - @override - Widget build(BuildContext context) { - return Column( - key: key, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding( - padding: const EdgeInsets.only(left: 10, bottom: 5), - child: Text( - title, - style: const TextStyle( - color: Colors.black87, - fontSize: 18, - ), - ), - ), - if (child is String) - Container( - margin: const EdgeInsets.symmetric(horizontal: 10, vertical: 2), - width: double.infinity, - padding: const EdgeInsets.symmetric( - horizontal: 20, - vertical: 5, - ), - color: Colors.black38, - child: Text( - child as String, - style: const TextStyle( - color: Colors.white, - ), - ), - ) - else if (child is List) - ListView.builder( - shrinkWrap: true, - itemCount: (child as List).length, - itemBuilder: (BuildContext context, int index) => Container( - margin: const EdgeInsets.symmetric(horizontal: 10, vertical: 2), - width: double.infinity, - padding: const EdgeInsets.symmetric( - horizontal: 20, - vertical: 5, - ), - color: Colors.black38, - child: Text( - (child as List)[index], - style: const TextStyle( - color: Colors.white, - ), - ), - ), - ), - ], - ); - } -} From 6ca918adb361fa881cf0c6229fc46676c911e37d Mon Sep 17 00:00:00 2001 From: eriko13 Date: Mon, 31 Jul 2023 04:06:49 +0000 Subject: [PATCH 34/38] removed need to click on tiles --- .../xdg_directories/example/lib/main.dart | 31 ++++++------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/packages/xdg_directories/example/lib/main.dart b/packages/xdg_directories/example/lib/main.dart index 2d438a3b95c..265a69b42fc 100644 --- a/packages/xdg_directories/example/lib/main.dart +++ b/packages/xdg_directories/example/lib/main.dart @@ -20,6 +20,7 @@ class MyApp extends StatelessWidget { return const MaterialApp( title: 'XDG Directories Demo', home: MyHomePage(title: 'XDG Directories Demo'), + color: Colors.blue, ); } } @@ -41,38 +42,24 @@ class _MyHomePageState extends State { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - backgroundColor: Theme.of(context).colorScheme.inversePrimary, title: Text(widget.title), ), body: Center( child: ListView( shrinkWrap: true, children: [ - const Padding( - padding: EdgeInsets.all(10.0), - child: Text( - 'Select a user directory name:', - style: TextStyle( - color: Colors.black87, - fontSize: 25, - ), - textAlign: TextAlign.start, - ), + const SizedBox( + height: 20, ), ListView.builder( shrinkWrap: true, itemCount: userDirectoryNames.length, - itemBuilder: (BuildContext context, int index) => ListTile( - title: Text(userDirectoryNames.elementAt(index)), - visualDensity: VisualDensity.standard, - onTap: () => setState( - () { - selectedUserDirectory = - getUserDirectory(userDirectoryNames.elementAt(index)) - ?.path ?? - ''; - }, - ), + itemBuilder: (BuildContext context, int index) => + _singleDirectoryPath( + title: userDirectoryNames.elementAt(index), + path: getUserDirectory(userDirectoryNames.elementAt(index)) + ?.path ?? + '', ), ), const SizedBox( From 3d14b89ba9f2d5d82611a06257441dc3e8fe51ef Mon Sep 17 00:00:00 2001 From: eriko13 Date: Tue, 1 Aug 2023 17:10:36 +0000 Subject: [PATCH 35/38] made directories more simple --- .../xdg_directories_test.dart | 64 +++----- .../xdg_directories/example/lib/main.dart | 146 ++---------------- 2 files changed, 34 insertions(+), 176 deletions(-) diff --git a/packages/xdg_directories/example/integration_test/xdg_directories_test.dart b/packages/xdg_directories/example/integration_test/xdg_directories_test.dart index 858011b7311..e35533f497b 100644 --- a/packages/xdg_directories/example/integration_test/xdg_directories_test.dart +++ b/packages/xdg_directories/example/integration_test/xdg_directories_test.dart @@ -4,52 +4,30 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; -import 'package:xdg_directories/xdg_directories.dart'; +import 'package:xdg_directories_example/main.dart'; void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); - testWidgets('XDG Directories', (WidgetTester _) async { - // Check that getUserDirectory() returns a Directory. - expect( - getUserDirectory('Home') != null, - true, - reason: 'getUserDirectory() should return a Directory', - ); - - // Check that dataHome returns a Directory. - expect( - dataHome.path.isNotEmpty, - true, - reason: 'dataHome should return a Directory', - ); - - // Check that configHome returns a Directory. - expect( - configHome.path.isNotEmpty, - true, - reason: 'configHome should return a Directory', - ); - - // Check that cacheHome returns a Directory. - expect( - cacheHome.path.isNotEmpty, - true, - reason: 'cacheHome should return a Directory', - ); - - // Check that dataDirs returns a List. - expect( - dataDirs.isNotEmpty, - true, - reason: 'dataDirs should return a List', - ); - - // Check that configDirs returns a List. - expect( - configDirs.isNotEmpty, - true, - reason: 'configDirs should return a List', - ); + testWidgets('xdg_directories_demo', (WidgetTester _) async { + // Build our app and trigger a frame. + await _.pumpWidget(const MyApp()); + + // Verify that our counter starts at 0. + expect(find.text('XDG Directories Demo'), findsOneWidget); + expect(find.text('Data Home:'), findsOneWidget); + + // Tap the '+' icon and trigger a frame. + // await _.tap(find.byIcon(Icons.add)); + // await _.pump(); + + // Verify that our counter has incremented. + // expect(find.text('0'), findsNothing); + // expect(find.text('1'), findsOneWidget); + + // await _.tap(find.byIcon(Icons.add)); + // await _.pump(); + + // expect(find.text('0'), findsNothing); }); } diff --git a/packages/xdg_directories/example/lib/main.dart b/packages/xdg_directories/example/lib/main.dart index 265a69b42fc..b2007331e23 100644 --- a/packages/xdg_directories/example/lib/main.dart +++ b/packages/xdg_directories/example/lib/main.dart @@ -46,6 +46,7 @@ class _MyHomePageState extends State { ), body: Center( child: ListView( + padding: const EdgeInsets.only(left: 20), shrinkWrap: true, children: [ const SizedBox( @@ -54,63 +55,20 @@ class _MyHomePageState extends State { ListView.builder( shrinkWrap: true, itemCount: userDirectoryNames.length, - itemBuilder: (BuildContext context, int index) => - _singleDirectoryPath( - title: userDirectoryNames.elementAt(index), - path: getUserDirectory(userDirectoryNames.elementAt(index)) - ?.path ?? - '', + itemBuilder: (BuildContext context, int index) => Text( + '${userDirectoryNames.elementAt(index)}: \n${getUserDirectory(userDirectoryNames.elementAt(index))?.path}\n', ), ), - const SizedBox( - height: 20, - ), - _singleDirectoryPath( - title: 'Selected directory:', - path: selectedUserDirectory, - ), - const SizedBox( - height: 50, - ), - _singleDirectoryPath( - title: 'Data Home:', - path: dataHome.path, - ), - const SizedBox( - height: 50, - ), - _singleDirectoryPath( - title: 'Config Home:', - path: configHome.path, - ), - const SizedBox( - height: 50, - ), - _listOfDirectoryPaths( - title: 'Data Directories:', - paths: dataDirs.map((Directory d) => d.path).toList(), - ), - const SizedBox( - height: 50, - ), - _listOfDirectoryPaths( - title: 'Config Directories:', - paths: configDirs.map((Directory d) => d.path).toList(), - ), - const SizedBox( - height: 50, - ), - _singleDirectoryPath( - title: 'Cache Home:', - path: cacheHome.path, - ), - const SizedBox( - height: 50, - ), - _singleDirectoryPath( - title: 'Runtime Directory:', - path: runtimeDir?.path, - ), + Text('Data Home: \n${dataHome.path}\n'), + Text('Config Home: \n${configHome.path}\n'), + Text( + 'Data Directories: \n${dataDirs.map((Directory directory) => directory.path).toList().join('\n')}\n'), + Text( + 'Config Directories: \n${configDirs.map((Directory directory) => directory.path).toList().join('\n')}\n'), + Text('Cache Home: \n${cacheHome.path}\n'), + Text('Runtime Directory: \n${runtimeDir?.path}\n'), + Text('Cache Home: \n${cacheHome.path}\n'), + Text('Cache Home: \n${cacheHome.path}\n'), const SizedBox( height: 100, ), @@ -120,81 +78,3 @@ class _MyHomePageState extends State { ); } } - -/// This is a Widget that displays a title and a directory path. -Widget _singleDirectoryPath({ - required String title, - String? path, -}) { - return Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding( - padding: const EdgeInsets.only(left: 10, bottom: 5), - child: Text( - title, - style: const TextStyle( - color: Colors.black87, - fontSize: 18, - ), - ), - ), - Container( - margin: const EdgeInsets.symmetric(horizontal: 10, vertical: 2), - width: double.infinity, - padding: const EdgeInsets.symmetric( - horizontal: 20, - vertical: 5, - ), - color: Colors.black38, - child: Text( - path ?? '', - style: const TextStyle( - color: Colors.white, - ), - ), - ), - ], - ); -} - -/// This is a Widget that displays a title and a list of directory paths. -Widget _listOfDirectoryPaths({ - required String title, - required List paths, -}) { - return Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding( - padding: const EdgeInsets.only(left: 10, bottom: 5), - child: Text( - title, - style: const TextStyle( - color: Colors.black87, - fontSize: 18, - ), - ), - ), - ListView.builder( - shrinkWrap: true, - itemCount: paths.length, - itemBuilder: (BuildContext context, int index) => Container( - margin: const EdgeInsets.symmetric(horizontal: 10, vertical: 2), - width: double.infinity, - padding: const EdgeInsets.symmetric( - horizontal: 20, - vertical: 5, - ), - color: Colors.black38, - child: Text( - paths[index], - style: const TextStyle( - color: Colors.white, - ), - ), - ), - ), - ], - ); -} From bf396d10a7d24d474369b0feec139ae39d33fcc2 Mon Sep 17 00:00:00 2001 From: eriko13 Date: Tue, 1 Aug 2023 11:14:23 -0700 Subject: [PATCH 36/38] updated tests --- .../xdg_directories_test.dart | 26 +++++++++---------- .../xdg_directories/example/lib/main.dart | 2 -- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/packages/xdg_directories/example/integration_test/xdg_directories_test.dart b/packages/xdg_directories/example/integration_test/xdg_directories_test.dart index e35533f497b..8e434d6e3f5 100644 --- a/packages/xdg_directories/example/integration_test/xdg_directories_test.dart +++ b/packages/xdg_directories/example/integration_test/xdg_directories_test.dart @@ -4,6 +4,7 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; +import 'package:xdg_directories/xdg_directories.dart'; import 'package:xdg_directories_example/main.dart'; void main() { @@ -13,21 +14,20 @@ void main() { // Build our app and trigger a frame. await _.pumpWidget(const MyApp()); - // Verify that our counter starts at 0. - expect(find.text('XDG Directories Demo'), findsOneWidget); - expect(find.text('Data Home:'), findsOneWidget); + expect(find.textContaining(dataHome.path), findsOneWidget); + expect(find.textContaining(configHome.path), findsOneWidget); + expect(find.textContaining(dataDirs.join('\n')), findsOneWidget); + expect(find.textContaining(configDirs.join('\n')), findsOneWidget); + expect(find.textContaining(cacheHome.path), findsOneWidget); + expect(find.textContaining(runtimeDir?.path ?? ''), findsOneWidget); - // Tap the '+' icon and trigger a frame. - // await _.tap(find.byIcon(Icons.add)); - // await _.pump(); + final Set userDirectoryNames = getUserDirectoryNames(); - // Verify that our counter has incremented. - // expect(find.text('0'), findsNothing); - // expect(find.text('1'), findsOneWidget); + for (final String userDirectoryName in userDirectoryNames) { + final String userDirectoryPath = + getUserDirectory(userDirectoryName)?.path ?? ''; - // await _.tap(find.byIcon(Icons.add)); - // await _.pump(); - - // expect(find.text('0'), findsNothing); + expect(find.textContaining(userDirectoryPath), findsOneWidget); + } }); } diff --git a/packages/xdg_directories/example/lib/main.dart b/packages/xdg_directories/example/lib/main.dart index b2007331e23..fb3695d6243 100644 --- a/packages/xdg_directories/example/lib/main.dart +++ b/packages/xdg_directories/example/lib/main.dart @@ -67,8 +67,6 @@ class _MyHomePageState extends State { 'Config Directories: \n${configDirs.map((Directory directory) => directory.path).toList().join('\n')}\n'), Text('Cache Home: \n${cacheHome.path}\n'), Text('Runtime Directory: \n${runtimeDir?.path}\n'), - Text('Cache Home: \n${cacheHome.path}\n'), - Text('Cache Home: \n${cacheHome.path}\n'), const SizedBox( height: 100, ), From e13a2eb04f2b3381d2833b3918f9e02918582922 Mon Sep 17 00:00:00 2001 From: eriko13 Date: Tue, 1 Aug 2023 18:44:52 +0000 Subject: [PATCH 37/38] fixed tests --- .../xdg_directories_test.dart | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/packages/xdg_directories/example/integration_test/xdg_directories_test.dart b/packages/xdg_directories/example/integration_test/xdg_directories_test.dart index 8e434d6e3f5..42473160508 100644 --- a/packages/xdg_directories/example/integration_test/xdg_directories_test.dart +++ b/packages/xdg_directories/example/integration_test/xdg_directories_test.dart @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import 'dart:io'; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; import 'package:xdg_directories/xdg_directories.dart'; @@ -16,18 +17,21 @@ void main() { expect(find.textContaining(dataHome.path), findsOneWidget); expect(find.textContaining(configHome.path), findsOneWidget); - expect(find.textContaining(dataDirs.join('\n')), findsOneWidget); - expect(find.textContaining(configDirs.join('\n')), findsOneWidget); - expect(find.textContaining(cacheHome.path), findsOneWidget); - expect(find.textContaining(runtimeDir?.path ?? ''), findsOneWidget); + expect( + find.textContaining( + dataDirs.map((Directory directory) => directory.path).join('\n')), + findsOneWidget); + expect( + find.textContaining( + configDirs.map((Directory directory) => directory.path).join('\n')), + findsOneWidget); - final Set userDirectoryNames = getUserDirectoryNames(); + expect( + find.textContaining(cacheHome.path, skipOffstage: false), + findsOneWidget, + ); - for (final String userDirectoryName in userDirectoryNames) { - final String userDirectoryPath = - getUserDirectory(userDirectoryName)?.path ?? ''; - - expect(find.textContaining(userDirectoryPath), findsOneWidget); - } + expect(find.textContaining(runtimeDir?.path ?? '', skipOffstage: false), + findsOneWidget); }); } From c85dbab6cbde6ed7432a970cdd2fb3ac3c3ea5de Mon Sep 17 00:00:00 2001 From: eriko13 Date: Wed, 2 Aug 2023 02:19:19 +0000 Subject: [PATCH 38/38] changed findsOneWidget to findsWidgets --- .../integration_test/xdg_directories_test.dart | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/xdg_directories/example/integration_test/xdg_directories_test.dart b/packages/xdg_directories/example/integration_test/xdg_directories_test.dart index 42473160508..8628394cf1c 100644 --- a/packages/xdg_directories/example/integration_test/xdg_directories_test.dart +++ b/packages/xdg_directories/example/integration_test/xdg_directories_test.dart @@ -15,23 +15,23 @@ void main() { // Build our app and trigger a frame. await _.pumpWidget(const MyApp()); - expect(find.textContaining(dataHome.path), findsOneWidget); - expect(find.textContaining(configHome.path), findsOneWidget); + expect(find.textContaining(dataHome.path), findsWidgets); + expect(find.textContaining(configHome.path), findsWidgets); expect( find.textContaining( dataDirs.map((Directory directory) => directory.path).join('\n')), - findsOneWidget); + findsWidgets); expect( find.textContaining( configDirs.map((Directory directory) => directory.path).join('\n')), - findsOneWidget); + findsWidgets); expect( find.textContaining(cacheHome.path, skipOffstage: false), - findsOneWidget, + findsWidgets, ); expect(find.textContaining(runtimeDir?.path ?? '', skipOffstage: false), - findsOneWidget); + findsWidgets); }); }