diff --git a/.dart_tool/package_config.json b/.dart_tool/package_config.json new file mode 100644 index 0000000..32191a0 --- /dev/null +++ b/.dart_tool/package_config.json @@ -0,0 +1,248 @@ +{ + "configVersion": 2, + "packages": [ + { + "name": "ansi_styles", + "rootUri": "file:///home/krtirtho/.pub-cache/hosted/pub.dev/ansi_styles-0.3.2+1", + "packageUri": "lib/", + "languageVersion": "2.12" + }, + { + "name": "args", + "rootUri": "file:///home/krtirtho/.pub-cache/hosted/pub.dev/args-2.4.1", + "packageUri": "lib/", + "languageVersion": "2.18" + }, + { + "name": "async", + "rootUri": "file:///home/krtirtho/.pub-cache/hosted/pub.dev/async-2.11.0", + "packageUri": "lib/", + "languageVersion": "2.18" + }, + { + "name": "boolean_selector", + "rootUri": "file:///home/krtirtho/.pub-cache/hosted/pub.dev/boolean_selector-2.1.1", + "packageUri": "lib/", + "languageVersion": "2.17" + }, + { + "name": "charcode", + "rootUri": "file:///home/krtirtho/.pub-cache/hosted/pub.dev/charcode-1.3.1", + "packageUri": "lib/", + "languageVersion": "2.12" + }, + { + "name": "cli_launcher", + "rootUri": "file:///home/krtirtho/.pub-cache/hosted/pub.dev/cli_launcher-0.3.1", + "packageUri": "lib/", + "languageVersion": "2.18" + }, + { + "name": "cli_util", + "rootUri": "file:///home/krtirtho/.pub-cache/hosted/pub.dev/cli_util-0.4.0", + "packageUri": "lib/", + "languageVersion": "2.19" + }, + { + "name": "collection", + "rootUri": "file:///home/krtirtho/.pub-cache/hosted/pub.dev/collection-1.17.2", + "packageUri": "lib/", + "languageVersion": "2.18" + }, + { + "name": "conventional_commit", + "rootUri": "file:///home/krtirtho/.pub-cache/hosted/pub.dev/conventional_commit-0.6.0+1", + "packageUri": "lib/", + "languageVersion": "2.18" + }, + { + "name": "file", + "rootUri": "file:///home/krtirtho/.pub-cache/hosted/pub.dev/file-6.1.4", + "packageUri": "lib/", + "languageVersion": "2.12" + }, + { + "name": "glob", + "rootUri": "file:///home/krtirtho/.pub-cache/hosted/pub.dev/glob-2.1.2", + "packageUri": "lib/", + "languageVersion": "2.19" + }, + { + "name": "graphs", + "rootUri": "file:///home/krtirtho/.pub-cache/hosted/pub.dev/graphs-2.3.1", + "packageUri": "lib/", + "languageVersion": "2.18" + }, + { + "name": "http", + "rootUri": "file:///home/krtirtho/.pub-cache/hosted/pub.dev/http-0.13.6", + "packageUri": "lib/", + "languageVersion": "2.19" + }, + { + "name": "http_parser", + "rootUri": "file:///home/krtirtho/.pub-cache/hosted/pub.dev/http_parser-4.0.2", + "packageUri": "lib/", + "languageVersion": "2.12" + }, + { + "name": "io", + "rootUri": "file:///home/krtirtho/.pub-cache/hosted/pub.dev/io-1.0.4", + "packageUri": "lib/", + "languageVersion": "2.12" + }, + { + "name": "json_annotation", + "rootUri": "file:///home/krtirtho/.pub-cache/hosted/pub.dev/json_annotation-4.8.1", + "packageUri": "lib/", + "languageVersion": "2.19" + }, + { + "name": "matcher", + "rootUri": "file:///home/krtirtho/.pub-cache/hosted/pub.dev/matcher-0.12.16", + "packageUri": "lib/", + "languageVersion": "2.18" + }, + { + "name": "melos", + "rootUri": "file:///home/krtirtho/.pub-cache/hosted/pub.dev/melos-3.1.0", + "packageUri": "lib/", + "languageVersion": "2.18" + }, + { + "name": "meta", + "rootUri": "file:///home/krtirtho/.pub-cache/hosted/pub.dev/meta-1.9.1", + "packageUri": "lib/", + "languageVersion": "2.12" + }, + { + "name": "mustache_template", + "rootUri": "file:///home/krtirtho/.pub-cache/hosted/pub.dev/mustache_template-2.0.0", + "packageUri": "lib/", + "languageVersion": "2.12" + }, + { + "name": "path", + "rootUri": "file:///home/krtirtho/.pub-cache/hosted/pub.dev/path-1.8.3", + "packageUri": "lib/", + "languageVersion": "2.12" + }, + { + "name": "platform", + "rootUri": "file:///home/krtirtho/.pub-cache/hosted/pub.dev/platform-3.1.0", + "packageUri": "lib/", + "languageVersion": "2.12" + }, + { + "name": "pool", + "rootUri": "file:///home/krtirtho/.pub-cache/hosted/pub.dev/pool-1.5.1", + "packageUri": "lib/", + "languageVersion": "2.12" + }, + { + "name": "process", + "rootUri": "file:///home/krtirtho/.pub-cache/hosted/pub.dev/process-4.2.4", + "packageUri": "lib/", + "languageVersion": "2.14" + }, + { + "name": "prompts", + "rootUri": "file:///home/krtirtho/.pub-cache/hosted/pub.dev/prompts-2.0.0", + "packageUri": "lib/", + "languageVersion": "2.12" + }, + { + "name": "pub_semver", + "rootUri": "file:///home/krtirtho/.pub-cache/hosted/pub.dev/pub_semver-2.1.4", + "packageUri": "lib/", + "languageVersion": "2.17" + }, + { + "name": "pub_updater", + "rootUri": "file:///home/krtirtho/.pub-cache/hosted/pub.dev/pub_updater-0.2.4", + "packageUri": "lib/", + "languageVersion": "2.12" + }, + { + "name": "pubspec", + "rootUri": "file:///home/krtirtho/.pub-cache/hosted/pub.dev/pubspec-2.3.0", + "packageUri": "lib/", + "languageVersion": "2.12" + }, + { + "name": "quiver", + "rootUri": "file:///home/krtirtho/.pub-cache/hosted/pub.dev/quiver-3.2.1", + "packageUri": "lib/", + "languageVersion": "2.17" + }, + { + "name": "source_span", + "rootUri": "file:///home/krtirtho/.pub-cache/hosted/pub.dev/source_span-1.10.0", + "packageUri": "lib/", + "languageVersion": "2.18" + }, + { + "name": "stack_trace", + "rootUri": "file:///home/krtirtho/.pub-cache/hosted/pub.dev/stack_trace-1.11.0", + "packageUri": "lib/", + "languageVersion": "2.18" + }, + { + "name": "stream_channel", + "rootUri": "file:///home/krtirtho/.pub-cache/hosted/pub.dev/stream_channel-2.1.1", + "packageUri": "lib/", + "languageVersion": "2.14" + }, + { + "name": "string_scanner", + "rootUri": "file:///home/krtirtho/.pub-cache/hosted/pub.dev/string_scanner-1.2.0", + "packageUri": "lib/", + "languageVersion": "2.18" + }, + { + "name": "term_glyph", + "rootUri": "file:///home/krtirtho/.pub-cache/hosted/pub.dev/term_glyph-1.2.1", + "packageUri": "lib/", + "languageVersion": "2.12" + }, + { + "name": "test_api", + "rootUri": "file:///home/krtirtho/.pub-cache/hosted/pub.dev/test_api-0.6.0", + "packageUri": "lib/", + "languageVersion": "2.18" + }, + { + "name": "typed_data", + "rootUri": "file:///home/krtirtho/.pub-cache/hosted/pub.dev/typed_data-1.3.2", + "packageUri": "lib/", + "languageVersion": "2.17" + }, + { + "name": "uri", + "rootUri": "file:///home/krtirtho/.pub-cache/hosted/pub.dev/uri-1.0.0", + "packageUri": "lib/", + "languageVersion": "2.12" + }, + { + "name": "yaml", + "rootUri": "file:///home/krtirtho/.pub-cache/hosted/pub.dev/yaml-3.1.2", + "packageUri": "lib/", + "languageVersion": "2.19" + }, + { + "name": "yaml_edit", + "rootUri": "file:///home/krtirtho/.pub-cache/hosted/pub.dev/yaml_edit-2.1.1", + "packageUri": "lib/", + "languageVersion": "2.19" + }, + { + "name": "fl_query_packages", + "rootUri": "../", + "packageUri": "lib/", + "languageVersion": "2.17" + } + ], + "generated": "2023-05-29T02:30:48.970388Z", + "generator": "pub", + "generatorVersion": "3.0.2" +} diff --git a/.dart_tool/package_config_subset b/.dart_tool/package_config_subset new file mode 100644 index 0000000..596bb45 --- /dev/null +++ b/.dart_tool/package_config_subset @@ -0,0 +1,161 @@ +ansi_styles +2.12 +file:///home/krtirtho/.pub-cache/hosted/pub.dev/ansi_styles-0.3.2+1/ +file:///home/krtirtho/.pub-cache/hosted/pub.dev/ansi_styles-0.3.2+1/lib/ +args +2.18 +file:///home/krtirtho/.pub-cache/hosted/pub.dev/args-2.4.1/ +file:///home/krtirtho/.pub-cache/hosted/pub.dev/args-2.4.1/lib/ +async +2.18 +file:///home/krtirtho/.pub-cache/hosted/pub.dev/async-2.11.0/ +file:///home/krtirtho/.pub-cache/hosted/pub.dev/async-2.11.0/lib/ +boolean_selector +2.17 +file:///home/krtirtho/.pub-cache/hosted/pub.dev/boolean_selector-2.1.1/ +file:///home/krtirtho/.pub-cache/hosted/pub.dev/boolean_selector-2.1.1/lib/ +charcode +2.12 +file:///home/krtirtho/.pub-cache/hosted/pub.dev/charcode-1.3.1/ +file:///home/krtirtho/.pub-cache/hosted/pub.dev/charcode-1.3.1/lib/ +cli_launcher +2.18 +file:///home/krtirtho/.pub-cache/hosted/pub.dev/cli_launcher-0.3.1/ +file:///home/krtirtho/.pub-cache/hosted/pub.dev/cli_launcher-0.3.1/lib/ +cli_util +2.19 +file:///home/krtirtho/.pub-cache/hosted/pub.dev/cli_util-0.4.0/ +file:///home/krtirtho/.pub-cache/hosted/pub.dev/cli_util-0.4.0/lib/ +collection +2.18 +file:///home/krtirtho/.pub-cache/hosted/pub.dev/collection-1.17.2/ +file:///home/krtirtho/.pub-cache/hosted/pub.dev/collection-1.17.2/lib/ +conventional_commit +2.18 +file:///home/krtirtho/.pub-cache/hosted/pub.dev/conventional_commit-0.6.0+1/ +file:///home/krtirtho/.pub-cache/hosted/pub.dev/conventional_commit-0.6.0+1/lib/ +file +2.12 +file:///home/krtirtho/.pub-cache/hosted/pub.dev/file-6.1.4/ +file:///home/krtirtho/.pub-cache/hosted/pub.dev/file-6.1.4/lib/ +glob +2.19 +file:///home/krtirtho/.pub-cache/hosted/pub.dev/glob-2.1.2/ +file:///home/krtirtho/.pub-cache/hosted/pub.dev/glob-2.1.2/lib/ +graphs +2.18 +file:///home/krtirtho/.pub-cache/hosted/pub.dev/graphs-2.3.1/ +file:///home/krtirtho/.pub-cache/hosted/pub.dev/graphs-2.3.1/lib/ +http +2.19 +file:///home/krtirtho/.pub-cache/hosted/pub.dev/http-0.13.6/ +file:///home/krtirtho/.pub-cache/hosted/pub.dev/http-0.13.6/lib/ +http_parser +2.12 +file:///home/krtirtho/.pub-cache/hosted/pub.dev/http_parser-4.0.2/ +file:///home/krtirtho/.pub-cache/hosted/pub.dev/http_parser-4.0.2/lib/ +io +2.12 +file:///home/krtirtho/.pub-cache/hosted/pub.dev/io-1.0.4/ +file:///home/krtirtho/.pub-cache/hosted/pub.dev/io-1.0.4/lib/ +json_annotation +2.19 +file:///home/krtirtho/.pub-cache/hosted/pub.dev/json_annotation-4.8.1/ +file:///home/krtirtho/.pub-cache/hosted/pub.dev/json_annotation-4.8.1/lib/ +matcher +2.18 +file:///home/krtirtho/.pub-cache/hosted/pub.dev/matcher-0.12.16/ +file:///home/krtirtho/.pub-cache/hosted/pub.dev/matcher-0.12.16/lib/ +melos +2.18 +file:///home/krtirtho/.pub-cache/hosted/pub.dev/melos-3.1.0/ +file:///home/krtirtho/.pub-cache/hosted/pub.dev/melos-3.1.0/lib/ +meta +2.12 +file:///home/krtirtho/.pub-cache/hosted/pub.dev/meta-1.9.1/ +file:///home/krtirtho/.pub-cache/hosted/pub.dev/meta-1.9.1/lib/ +mustache_template +2.12 +file:///home/krtirtho/.pub-cache/hosted/pub.dev/mustache_template-2.0.0/ +file:///home/krtirtho/.pub-cache/hosted/pub.dev/mustache_template-2.0.0/lib/ +path +2.12 +file:///home/krtirtho/.pub-cache/hosted/pub.dev/path-1.8.3/ +file:///home/krtirtho/.pub-cache/hosted/pub.dev/path-1.8.3/lib/ +platform +2.12 +file:///home/krtirtho/.pub-cache/hosted/pub.dev/platform-3.1.0/ +file:///home/krtirtho/.pub-cache/hosted/pub.dev/platform-3.1.0/lib/ +pool +2.12 +file:///home/krtirtho/.pub-cache/hosted/pub.dev/pool-1.5.1/ +file:///home/krtirtho/.pub-cache/hosted/pub.dev/pool-1.5.1/lib/ +process +2.14 +file:///home/krtirtho/.pub-cache/hosted/pub.dev/process-4.2.4/ +file:///home/krtirtho/.pub-cache/hosted/pub.dev/process-4.2.4/lib/ +prompts +2.12 +file:///home/krtirtho/.pub-cache/hosted/pub.dev/prompts-2.0.0/ +file:///home/krtirtho/.pub-cache/hosted/pub.dev/prompts-2.0.0/lib/ +pub_semver +2.17 +file:///home/krtirtho/.pub-cache/hosted/pub.dev/pub_semver-2.1.4/ +file:///home/krtirtho/.pub-cache/hosted/pub.dev/pub_semver-2.1.4/lib/ +pub_updater +2.12 +file:///home/krtirtho/.pub-cache/hosted/pub.dev/pub_updater-0.2.4/ +file:///home/krtirtho/.pub-cache/hosted/pub.dev/pub_updater-0.2.4/lib/ +pubspec +2.12 +file:///home/krtirtho/.pub-cache/hosted/pub.dev/pubspec-2.3.0/ +file:///home/krtirtho/.pub-cache/hosted/pub.dev/pubspec-2.3.0/lib/ +quiver +2.17 +file:///home/krtirtho/.pub-cache/hosted/pub.dev/quiver-3.2.1/ +file:///home/krtirtho/.pub-cache/hosted/pub.dev/quiver-3.2.1/lib/ +source_span +2.18 +file:///home/krtirtho/.pub-cache/hosted/pub.dev/source_span-1.10.0/ +file:///home/krtirtho/.pub-cache/hosted/pub.dev/source_span-1.10.0/lib/ +stack_trace +2.18 +file:///home/krtirtho/.pub-cache/hosted/pub.dev/stack_trace-1.11.0/ +file:///home/krtirtho/.pub-cache/hosted/pub.dev/stack_trace-1.11.0/lib/ +stream_channel +2.14 +file:///home/krtirtho/.pub-cache/hosted/pub.dev/stream_channel-2.1.1/ +file:///home/krtirtho/.pub-cache/hosted/pub.dev/stream_channel-2.1.1/lib/ +string_scanner +2.18 +file:///home/krtirtho/.pub-cache/hosted/pub.dev/string_scanner-1.2.0/ +file:///home/krtirtho/.pub-cache/hosted/pub.dev/string_scanner-1.2.0/lib/ +term_glyph +2.12 +file:///home/krtirtho/.pub-cache/hosted/pub.dev/term_glyph-1.2.1/ +file:///home/krtirtho/.pub-cache/hosted/pub.dev/term_glyph-1.2.1/lib/ +test_api +2.18 +file:///home/krtirtho/.pub-cache/hosted/pub.dev/test_api-0.6.0/ +file:///home/krtirtho/.pub-cache/hosted/pub.dev/test_api-0.6.0/lib/ +typed_data +2.17 +file:///home/krtirtho/.pub-cache/hosted/pub.dev/typed_data-1.3.2/ +file:///home/krtirtho/.pub-cache/hosted/pub.dev/typed_data-1.3.2/lib/ +uri +2.12 +file:///home/krtirtho/.pub-cache/hosted/pub.dev/uri-1.0.0/ +file:///home/krtirtho/.pub-cache/hosted/pub.dev/uri-1.0.0/lib/ +yaml +2.19 +file:///home/krtirtho/.pub-cache/hosted/pub.dev/yaml-3.1.2/ +file:///home/krtirtho/.pub-cache/hosted/pub.dev/yaml-3.1.2/lib/ +yaml_edit +2.19 +file:///home/krtirtho/.pub-cache/hosted/pub.dev/yaml_edit-2.1.1/ +file:///home/krtirtho/.pub-cache/hosted/pub.dev/yaml_edit-2.1.1/lib/ +fl_query_packages +2.17 +file:///home/krtirtho/dev/fl-query/ +file:///home/krtirtho/dev/fl-query/lib/ +2 diff --git a/.dart_tool/version b/.dart_tool/version new file mode 100644 index 0000000..e86ec35 --- /dev/null +++ b/.dart_tool/version @@ -0,0 +1 @@ +3.10.2 \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..e8b8e06 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,242 @@ +# Change Log + +All notable changes to this project will be documented in this file. +See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. + +## 2023-10-06 + +### Changes + +--- + +Packages with breaking changes: + + - There are no breaking changes in this release. + +Packages with other changes: + + - [`fl_query` - `v1.0.0-alpha.5`](#fl_query---v100-alpha5) + - [`fl_query_devtools` - `v0.1.0-alpha.3`](#fl_query_devtools---v010-alpha3) + - [`fl_query_hooks` - `v1.0.0-alpha.5`](#fl_query_hooks---v100-alpha5) + - [`fl_query_connectivity_plus_adapter` - `v0.1.0-alpha.4`](#fl_query_connectivity_plus_adapter---v010-alpha4) + +Packages with dependency updates only: + +> Packages listed below depend on other packages in this workspace that have had changes. Their versions have been incremented to bump the minimum dependency versions of the packages they depend upon in this project. + + - `fl_query_connectivity_plus_adapter` - `v0.1.0-alpha.4` + +--- + +#### `fl_query` - `v1.0.0-alpha.5` + + - **FIX**(query): isLoading & isRefreshing not working as expected. + - **FIX**(mutation): isMutating not working. + - **FEAT**(infinite_query): add isLoadingNextPage & remove isLoadingPage. + +#### `fl_query_devtools` - `v0.1.0-alpha.3` + + - **FEAT**(infinite_query): add isLoadingNextPage & remove isLoadingPage. + +#### `fl_query_hooks` - `v1.0.0-alpha.5` + + - **FIX**(mutation): isMutating not working. + + +## 2023-09-09 + +### Changes + +--- + +Packages with breaking changes: + + - There are no breaking changes in this release. + +Packages with other changes: + + - [`fl_query_hooks` - `v1.0.0-alpha.4+1`](#fl_query_hooks---v100-alpha41) + +--- + +#### `fl_query_hooks` - `v1.0.0-alpha.4+1` + + - **FIX**(fl_query_hooks): upgrade flutter_hooks version & dart sdk constrain. + + +## 2023-09-09 + +### Changes + +--- + +Packages with breaking changes: + + - There are no breaking changes in this release. + +Packages with other changes: + + - [`fl_query` - `v1.0.0-alpha.4`](#fl_query---v100-alpha4) + - [`fl_query_devtools` - `v0.1.0-alpha.2`](#fl_query_devtools---v010-alpha2) + - [`fl_query_hooks` - `v1.0.0-alpha.4`](#fl_query_hooks---v100-alpha4) + - [`fl_query_connectivity_plus_adapter` - `v0.1.0-alpha.3`](#fl_query_connectivity_plus_adapter---v010-alpha3) + +Packages with dependency updates only: + +> Packages listed below depend on other packages in this workspace that have had changes. Their versions have been incremented to bump the minimum dependency versions of the packages they depend upon in this project. + + - `fl_query_connectivity_plus_adapter` - `v0.1.0-alpha.3` + +--- + +#### `fl_query` - `v1.0.0-alpha.4` + + - **FIX**: mutation onSuccess doesn't refresh all pages of infinite queries. + - **FIX**: no refreshing stale queries with error. + +#### `fl_query_devtools` - `v0.1.0-alpha.2` + + - **FIX**(devtools): no wrapping child inside SizedBox.shrink. + +#### `fl_query_hooks` - `v1.0.0-alpha.4` + + - **FIX**: mutation onSuccess doesn't refresh all pages of infinite queries. + + +## 2023-06-28 + +### Changes + +--- + +Packages with breaking changes: + + - There are no breaking changes in this release. + +Packages with other changes: + + - [`fl_query_connectivity_plus_adapter` - `v0.1.0-alpha.2`](#fl_query_connectivity_plus_adapter---v010-alpha2) + +--- + +#### `fl_query_connectivity_plus_adapter` - `v0.1.0-alpha.2` + + - **FIX**(fl_query_connectivity_plus_adapter): lower the sdk constrains. + + +## 2023-06-24 + +### Changes + +--- + +Packages with breaking changes: + + - There are no breaking changes in this release. + +Packages with other changes: + + - [`fl_query` - `v1.0.0-alpha.3`](#fl_query---v100-alpha3) + - [`fl_query_hooks` - `v1.0.0-alpha.3`](#fl_query_hooks---v100-alpha3) + - [`fl_query_devtools` - `v0.1.0-alpha.1`](#fl_query_devtools---v010-alpha1) + - [`fl_query_connectivity_plus_adapter` - `v0.1.0-alpha.1`](#fl_query_connectivity_plus_adapter---v010-alpha1) + +Packages with dependency updates only: + +> Packages listed below depend on other packages in this workspace that have had changes. Their versions have been incremented to bump the minimum dependency versions of the packages they depend upon in this project. + + - `fl_query_devtools` - `v0.1.0-alpha.1` + - `fl_query_connectivity_plus_adapter` - `v0.1.0-alpha.1` + +--- + +#### `fl_query` - `v1.0.0-alpha.3` + + - **REFACTOR**: directory restructure revamp. + - **REFACTOR**: more convenient ways customizing config. + - **REFACTOR**: stale logic to separate mixin. + - **REFACTOR**: remove KyeType and use String for queryKey and mutationKey. + - **REFACTOR**(example): package specific examples instead of a single example. + - **REFACTOR**(QueryBowl): query bowl logic as a separate class instead of a stateful widget. + - **REFACTOR**: move devtools to separate library. + - **FIX**(fl_query_hooks): unneeded empty instances of query/mutation. + - **FIX**(base_query): onData callback getting called with null #17. + - **FIX**(fl_query_hooks): newest query/mutation/infinite-query instance not getting returned. + - **FIX**: fetch query and infinite query resolving immediately without proper result. + - **FIX**: refetchOnExternalDataChange isn't working #18. + - **FIX**: mutation context param clashing with BuildContext. + - **FIX**: query, infinite_query fetching/refetching when offline. + - **FIX**: state update on unmounted hook and infinite query cache refetch not working. + - **FIX**(client): check for error out put in fetch query and infinite query and mutateMutation immediate resolve. + - **FIX**: not updating queryFn on create query's old query and checking stale status after updating queryFn instead of storing the status before. + - **FIX**(InfiniteQueryJob): remove unneeded `keepPreviousData` property. + - **FEAT**: add mutation and mutation builder with example. + - **FEAT**: infinite query listenable add and cache event stream. + - **FEAT**: add infinite query builder with example. + - **FEAT**: new widget query listable builder. + - **FEAT**: safe setState for builders, separate cache box for query and infinite query and update state before _operate to indicate loading state. + - **FEAT**: working query builder, remove timeout from retryConfig. + - **FEAT**: cache, client, query builder add and refreshOnQueryFnChange option. + - **FEAT**: infinite query implementation. + - **FEAT**: safe cancellation of running operation on reset. + - **FEAT**: initial query and retryer implementation. + - **FEAT**: clean old junk. + - **FEAT**: useQuery hook with working example. + - **FEAT**: useInfiniteQuery hook add. + - **FEAT**: add query and infinite query disk caching support. + - **FEAT**: use function hooks instead of class hooks. + - **FEAT**: new next_page signature, query/mutation fn in notifier and safe update in use_updater. + - **FEAT**(QueryClientProvider): add config parameters and override-able client parameter. + - **FEAT**: add devtools (WIP). + - **FEAT**: add ability to get, refresh query and infinite queries using prefix. + - **FEAT**: connectivity adapter package for connectivity_plus. + - **FEAT**: refresh on network state change and cancel retry when offline. + - **FEAT**: add support for keepPreviousData & examples regarding this. + - **FEAT**: resolve and resolveWith helper support. + - **FEAT**: add initial support for `InfiniteQuery`. + - **FEAT**(infinite-query): onData and onError listener support. + - **FEAT**(infinite-query): add `useInfiniteQuery` hook with example. + - **FEAT**(infinite-query): add setInfiniteQueryData support. + - **FEAT**(infinite-query): add refetchPages, refetchOnStale, refetchOnMount support. + - **FEAT**(infinite-query): add all the features of query in infinite query. + - **FEAT**: implement refetchOnApplicationResume and refetchOnWindowFocus. + - **DOCS**: add dynamic query & mutation section. + - **DOCS**: add paginated-query section and update optimistc update section. + - **DOCS**: update according to the new query bowl refactor. + - **DOCS**: Front page Images added. + - **DOCS**: add infinite query page. + +#### `fl_query_hooks` - `v1.0.0-alpha.3` + + - **REFACTOR**: move devtools to separate library. + - **REFACTOR**: more convenient ways customizing config. + - **REFACTOR**(QueryBowl): query bowl logic as a separate class instead of a stateful widget. + - **REFACTOR**(example): package specific examples instead of a single example. + - **FIX**(fl_query_hooks): fetch query when queryKey changes. + - **FIX**(fl_query_hooks): query/mutation reset to initial memoized values on hot reload. + - **FIX**: state update on unmounted hook and infinite query cache refetch not working. + - **FIX**: refetchOnExternalDataChange isn't working #18. + - **FIX**(base_query): onData callback getting called with null #17. + - **FIX**(fl_query_hooks): unneeded empty instances of query/mutation. + - **FIX**(fl_query_hooks): newest query/mutation/infinite-query instance not getting returned. + - **FEAT**: connectivity adapter package for connectivity_plus. + - **FEAT**: add devtools (WIP). + - **FEAT**: new next_page signature, query/mutation fn in notifier and safe update in use_updater. + - **FEAT**: use function hooks instead of class hooks. + - **FEAT**: use mutation hook add. + - **FEAT**: useInfiniteQuery hook add. + - **FEAT**: useQuery hook with working example. + - **FEAT**: safe cancellation of running operation on reset. + - **FEAT**: add infinite query builder with example. + - **FEAT**: cache, client, query builder add and refreshOnQueryFnChange option. + - **FEAT**: initial query and retryer implementation. + - **FEAT**: clean old junk. + - **FEAT**: add query and infinite query disk caching support. + - **FEAT**(infinite-query): onData and onError listener support. + - **FEAT**(infinite-query): add `useInfiniteQuery` hook with example. + - **FEAT**(infinite-query): add refetchPages, refetchOnStale, refetchOnMount support. + - **FEAT**: add initial support for `InfiniteQuery`. + - **FEAT**: add support for keepPreviousData & examples regarding this. + - **DOCS**: add infinite query page. + - **DOCS**: add paginated-query section and update optimistc update section. + diff --git a/README.md b/README.md index e9a6f4e..f37cab9 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,8 @@ Fl-Query makes asynchronous server state management a breeze in flutter - Smart + effective refetching - Optimistic updates - Automatically cached data invalidation & unneeded query/mutation garbage collection -- Infinite data pagination via `InfiniteQuery` +- Infinite pagination via `InfiniteQuery` +- Lazy persistent cache (Uses [hive](https://pub.dev/packages/hive) for persisting query results to disk) (optional) - Easy to write & understand code. Follows DRY (Don't repeat yourself) convention - Compatible with both vanilla Flutter & elite [flutter_hooks](https://pub.dev/packages/flutter_hooks) @@ -28,25 +29,34 @@ Regular installation: $ flutter pub add fl_query ``` -For elite flutter_hooks user: +For elite flutter_hooks user (Welcome to the flutter cool community btw😎) ```bash -$ flutter pub add flutter_hooks -$ flutter pub add fl_query_hooks +$ flutter pub add flutter_hooks fl_query_hooks ``` # Docs -You can find the documentation (WIP) of fl-query at https://fl-query.krtirtho.dev/ +You can find the documentation of fl-query at https://fl-query.vercel.app/ # Basic Usage -First wrap your `MaterialApp` with with `QueryBowlScope` widget +Initialize the cache databases in your `main` method + +> fl-query uses [hive](https://pub.dev/packages/hive) for persisting data to disk + +```dart +void main()async { + WidgetsFlutterBinding.ensureInitialized(); + await QueryClient.initialize(cachePrefix: 'fl_query_example'); + runApp(MyApp()); +} +``` +In `MyApp` Widget's build method wrap your `MaterialApp` with with `QueryClientProvider` widget ```dart Widget build(BuildContext context) { - return QueryBowlScope( - bowl: QueryBowl(), + return QueryClientProvider( child: MaterialApp( title: 'Fl-Query Example App', theme: ThemeData( @@ -59,104 +69,116 @@ First wrap your `MaterialApp` with with `QueryBowlScope` widget } ``` -Fl-Query has two types of jobs - - `QueryJob`: Used for storing GET requests or for storing changeable yet readonly async data - - `MutationJob`: Used for POST/PUT/DELETE requests or for mutating/changing data in services or a store asynchronously +Let's write use a `Query` now +FL-Query provides a `QueryBuilder` widget that creates and listens to the specified `Query` +and re-runs the builder function whenever there's an update -You can write all your query or mutation logic a method parameter named `task` & identify the query uniquely by passing a unique `queryKey` - -Example of a QueryJob: +It has 2 required parameters(unnamed) `key` & `builder` ```dart -final exampleQueryJob = QueryJob( - queryKey: "example", // have to be unique - task: (queryKey, externalData) async { - final res = await http.get("/api/example-data"); - return jsonDecode(res.body); - } -); -``` +class MyApp extends StatelessWidget{ + MyApp({super.key}); -Store the `QueryJob` somewhere globally accessible in your project so you can reuse it later - -Now you can use this `QueryJob` anywhere inside your flutter app inside the build method using a `QueryBuilder` widget - -```dart -Widget build(BuildContext context){ - return QueryBuilder( - job: exampleQueryJob, - externalData: null, - builder: (context, query) { - if (!query.hasData || query.isLoading) { - return const CircularProgressIndicator(); - } - return Row( - children: [ - Text(query.data!), - ElevatedButton( - child: const Text("Refetch"), - onPressed: () async { - // refetches the query - await query.refetch(); - }, - ), - ], - ); - }, - ); -} -``` - -Or if you're an elite **flutter_hooks** user you can use the `useQuery` hook which is exported from the `package:fl_query_hooks/fl_query_hooks.dart` to do the same thing as above - -```dart -/* other imports */ -import 'package:flutter_hooks/flutter_hooks.dart'; -import 'package:fl_query_hooks/fl_query_hooks.dart'; // importing the fl-query hook package - -class Example extends HookWidget{ - Example(super.key); - - Widget build(BuildContext context) { - final query = useQuery(job: exampleQueryJob, externalData: null); - - if (!query.hasData || query.isLoading) { - return const CircularProgressIndicator(); - } - return Row( - children: [ - Text(query.data!), - ElevatedButton( - child: const Text("Refetch"), - onPressed: () async { - // refetches the query - await query.refetch(); - }, + @override + build(context){ + return QueryBuilder( + 'hello', + () { + return Future.delayed( + const Duration(seconds: 6), () => 'Hello World!'); + }, + initial: 'A replacement', + jsonConfig: JsonConfig( + fromJson: (json) => json['data'], + toJson: (data) => {'data': data}, ), - ], - ); - } + onData: (value) { + debugPrint('onData: $value'); + }, + onError: (error) { + debugPrint('onError: $error'); + }, + builder: (context, query) { + if (query.isLoading) { + return const Center( + child: CircularProgressIndicator(), + ); + } else if (query.hasError) { + return Center( + child: Text(query.error.toString()), + ); + } + return Center( + child: Text(query.data ?? "Unfortunately, there's no data"), + ); + }, + ); + } } ``` +And if you're using **flutter_hooks** you got that too + +```dart +class MyApp extends HookWidget{ + MyApp({super.key}); + + @override + build(context){ + final query = useQuery( + 'hello', + () { + return Future.delayed( + const Duration(seconds: 6), () => 'Hello World!'); + }, + initial: 'A replacement', + jsonConfig: JsonConfig( + fromJson: (json) => json['data'], + toJson: (data) => {'data': data}, + ), + onData: (value) { + debugPrint('onData: $value'); + }, + onError: (error) { + debugPrint('onError: $error'); + }, + ); + + if (query.isLoading) { + return const Center( + child: CircularProgressIndicator(), + ); + } else if (query.hasError) { + return Center( + child: Text(query.error.toString()), + ); + } + return Center( + child: Text(query.data ?? "Unfortunately, there's no data"), + ); + } +} +``` + +*To master the fl-query follow the official blog at https://fl-query.vercel.app/blog* + # Why?

The hell, why?

The main purpose of Fl-Query is providing the easiest way to manage the messy server-state part requiring the least amount of code with code reusability & performance +This let's you focus more on those cool UI animations & transitions✨. Leave the boring stuff to fl-query -**Isn't `FutureBuilder` good?** -Yes but it is only if your commercial server has huge load of power & you're made of money or your app is simple or mostly offline & barely requires internet connection -`FutureBuilder` isn't good for data persistency & its impossible to share data across the entire application using it +**Q. Isn't `FutureBuilder` good?** -**So `FutureProvider` from riverpod or provider not enough?** -Yeah, indeed its more than enough for many applications but what if your app needs Optimistic Updates & proper server-state synchronization or simply want a custom `cacheTime`? Although `FutureProvider` is a viable solution most of the `Future` related stuff, why not kick it up a notch with smart refetching capabilities with proper server-state synchronization? -Riverpod is definitely a inspiration for Fl-Query & the `QueryJob` is actually inspired by riverpod & imo is the best state management solution any library has ever provided but that's still a client state manager just like other client state manager or synchronous data manager + No, of course not. Unless you're from 2013 or your app is a purely offline app +**Q. So `FutureProvider` from riverpod or provider not enough?** + +Probably yes. Although riverpod@v2 has added a lot of caching related features but still optimistic updates, periodic refetching & disk persistence are missing. Let's not forget about infinite pagination, it's a nightmare😅. In case of provider, same story. It's a great package but it's not ideal for server-state management # Notice Board -This project is currently under heavy development & not yet production ready. There are lot of features to cover. If anyone encounters any unintended behavior or any bug please report it. Also we're open to improvement suggestions & feature requests - -**Important!:** The project needs Dart-Flutter developers who are willing to contribute to the project by writing Tests. (I'm the worst example for tester) +We need some bada** coders to write tests and ruin our life🥲 +100% coverage is our goal🙃 \ No newline at end of file diff --git a/packages/fl_query/.flutter-plugins b/packages/fl_query/.flutter-plugins index 4868dd5..3aad94f 100644 --- a/packages/fl_query/.flutter-plugins +++ b/packages/fl_query/.flutter-plugins @@ -1,12 +1,6 @@ # This is a generated file; do not edit or check into version control. -connectivity_plus=/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-2.3.9/ -connectivity_plus_linux=/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_linux-1.3.1/ -connectivity_plus_macos=/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_macos-1.2.6/ -connectivity_plus_web=/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_web-1.2.5/ -connectivity_plus_windows=/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_windows-1.2.2/ -path_provider=/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/path_provider-2.0.11/ -path_provider_android=/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/path_provider_android-2.0.22/ -path_provider_ios=/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/path_provider_ios-2.0.11/ -path_provider_linux=/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/path_provider_linux-2.1.7/ -path_provider_macos=/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/path_provider_macos-2.0.6/ -path_provider_windows=/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/path_provider_windows-2.1.3/ +path_provider=/home/krtirtho/.pub-cache/hosted/pub.dev/path_provider-2.0.15/ +path_provider_android=/home/krtirtho/.pub-cache/hosted/pub.dev/path_provider_android-2.0.27/ +path_provider_foundation=/home/krtirtho/.pub-cache/hosted/pub.dev/path_provider_foundation-2.2.3/ +path_provider_linux=/home/krtirtho/.pub-cache/hosted/pub.dev/path_provider_linux-2.1.11/ +path_provider_windows=/home/krtirtho/.pub-cache/hosted/pub.dev/path_provider_windows-2.1.6/ diff --git a/packages/fl_query/.flutter-plugins-dependencies b/packages/fl_query/.flutter-plugins-dependencies index 9614e81..ebdf132 100644 --- a/packages/fl_query/.flutter-plugins-dependencies +++ b/packages/fl_query/.flutter-plugins-dependencies @@ -1 +1 @@ -{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"connectivity_plus","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-2.3.9/","native_build":true,"dependencies":[]},{"name":"path_provider_ios","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/path_provider_ios-2.0.11/","native_build":true,"dependencies":[]}],"android":[{"name":"connectivity_plus","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-2.3.9/","native_build":true,"dependencies":[]},{"name":"path_provider_android","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/path_provider_android-2.0.22/","native_build":true,"dependencies":[]}],"macos":[{"name":"connectivity_plus_macos","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_macos-1.2.6/","native_build":true,"dependencies":[]},{"name":"path_provider_macos","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/path_provider_macos-2.0.6/","native_build":true,"dependencies":[]}],"linux":[{"name":"connectivity_plus_linux","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_linux-1.3.1/","native_build":false,"dependencies":[]},{"name":"path_provider_linux","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/path_provider_linux-2.1.7/","native_build":false,"dependencies":[]}],"windows":[{"name":"connectivity_plus_windows","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_windows-1.2.2/","native_build":true,"dependencies":[]},{"name":"path_provider_windows","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/path_provider_windows-2.1.3/","native_build":false,"dependencies":[]}],"web":[{"name":"connectivity_plus_web","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_web-1.2.5/","dependencies":[]}]},"dependencyGraph":[{"name":"connectivity_plus","dependencies":["connectivity_plus_linux","connectivity_plus_macos","connectivity_plus_web","connectivity_plus_windows"]},{"name":"connectivity_plus_linux","dependencies":[]},{"name":"connectivity_plus_macos","dependencies":[]},{"name":"connectivity_plus_web","dependencies":[]},{"name":"connectivity_plus_windows","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_android","path_provider_ios","path_provider_linux","path_provider_macos","path_provider_windows"]},{"name":"path_provider_android","dependencies":[]},{"name":"path_provider_ios","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_macos","dependencies":[]},{"name":"path_provider_windows","dependencies":[]}],"date_created":"2022-12-15 14:11:20.974968","version":"3.3.8"} \ No newline at end of file +{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"path_provider_foundation","path":"/home/krtirtho/.pub-cache/hosted/pub.dev/path_provider_foundation-2.2.3/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"android":[{"name":"path_provider_android","path":"/home/krtirtho/.pub-cache/hosted/pub.dev/path_provider_android-2.0.27/","native_build":true,"dependencies":[]}],"macos":[{"name":"path_provider_foundation","path":"/home/krtirtho/.pub-cache/hosted/pub.dev/path_provider_foundation-2.2.3/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"/home/krtirtho/.pub-cache/hosted/pub.dev/path_provider_linux-2.1.11/","native_build":false,"dependencies":[]}],"windows":[{"name":"path_provider_windows","path":"/home/krtirtho/.pub-cache/hosted/pub.dev/path_provider_windows-2.1.6/","native_build":false,"dependencies":[]}],"web":[]},"dependencyGraph":[{"name":"path_provider","dependencies":["path_provider_android","path_provider_foundation","path_provider_linux","path_provider_windows"]},{"name":"path_provider_android","dependencies":[]},{"name":"path_provider_foundation","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]}],"date_created":"2023-06-23 22:55:18.872475","version":"3.10.2"} \ No newline at end of file diff --git a/packages/fl_query/CHANGELOG.md b/packages/fl_query/CHANGELOG.md index 134d659..cf29935 100644 --- a/packages/fl_query/CHANGELOG.md +++ b/packages/fl_query/CHANGELOG.md @@ -1,7 +1,112 @@ +## 1.0.0-alpha.5 + + - **FIX**(query): isLoading & isRefreshing not working as expected. + - **FIX**(mutation): isMutating not working. + - **FEAT**(infinite_query): add isLoadingNextPage & remove isLoadingPage. + +## 1.0.0-alpha.4 + + - **FIX**: mutation onSuccess doesn't refresh all pages of infinite queries. + - **FIX**: no refreshing stale queries with error. + +## 1.0.0-alpha.3 + + - **REFACTOR**: directory restructure revamp. + - **REFACTOR**: more convenient ways customizing config. + - **REFACTOR**: stale logic to separate mixin. + - **REFACTOR**: remove KyeType and use String for queryKey and mutationKey. + - **REFACTOR**(example): package specific examples instead of a single example. + - **REFACTOR**(QueryBowl): query bowl logic as a separate class instead of a stateful widget. + - **REFACTOR**: move devtools to separate library. + - **FIX**(fl_query_hooks): unneeded empty instances of query/mutation. + - **FIX**(base_query): onData callback getting called with null #17. + - **FIX**(fl_query_hooks): newest query/mutation/infinite-query instance not getting returned. + - **FIX**: fetch query and infinite query resolving immediately without proper result. + - **FIX**: refetchOnExternalDataChange isn't working #18. + - **FIX**: mutation context param clashing with BuildContext. + - **FIX**: query, infinite_query fetching/refetching when offline. + - **FIX**: state update on unmounted hook and infinite query cache refetch not working. + - **FIX**(client): check for error out put in fetch query and infinite query and mutateMutation immediate resolve. + - **FIX**: not updating queryFn on create query's old query and checking stale status after updating queryFn instead of storing the status before. + - **FIX**(InfiniteQueryJob): remove unneeded `keepPreviousData` property. + - **FEAT**: add mutation and mutation builder with example. + - **FEAT**: infinite query listenable add and cache event stream. + - **FEAT**: add infinite query builder with example. + - **FEAT**: new widget query listable builder. + - **FEAT**: safe setState for builders, separate cache box for query and infinite query and update state before _operate to indicate loading state. + - **FEAT**: working query builder, remove timeout from retryConfig. + - **FEAT**: cache, client, query builder add and refreshOnQueryFnChange option. + - **FEAT**: infinite query implementation. + - **FEAT**: safe cancellation of running operation on reset. + - **FEAT**: initial query and retryer implementation. + - **FEAT**: clean old junk. + - **FEAT**: useQuery hook with working example. + - **FEAT**: useInfiniteQuery hook add. + - **FEAT**: add query and infinite query disk caching support. + - **FEAT**: use function hooks instead of class hooks. + - **FEAT**: new next_page signature, query/mutation fn in notifier and safe update in use_updater. + - **FEAT**(QueryClientProvider): add config parameters and override-able client parameter. + - **FEAT**: add devtools (WIP). + - **FEAT**: add ability to get, refresh query and infinite queries using prefix. + - **FEAT**: connectivity adapter package for connectivity_plus. + - **FEAT**: refresh on network state change and cancel retry when offline. + - **FEAT**: add support for keepPreviousData & examples regarding this. + - **FEAT**: resolve and resolveWith helper support. + - **FEAT**: add initial support for `InfiniteQuery`. + - **FEAT**(infinite-query): onData and onError listener support. + - **FEAT**(infinite-query): add `useInfiniteQuery` hook with example. + - **FEAT**(infinite-query): add setInfiniteQueryData support. + - **FEAT**(infinite-query): add refetchPages, refetchOnStale, refetchOnMount support. + - **FEAT**(infinite-query): add all the features of query in infinite query. + - **FEAT**: implement refetchOnApplicationResume and refetchOnWindowFocus. + - **DOCS**: add dynamic query & mutation section. + - **DOCS**: add paginated-query section and update optimistc update section. + - **DOCS**: update according to the new query bowl refactor. + - **DOCS**: Front page Images added. + - **DOCS**: add infinite query page. + # Changelog All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +## [1.0.0-alpha.2](https://github.com/KRTirtho/fl-query/compare/v1.0.0-alpha.1...v1.0.0-alpha.2) (2023-03-12) + + +### Features + +* **QueryClientProvider:** add config parameters and override-able client parameter ([f8895e3](https://github.com/KRTirtho/fl-query/commit/f8895e338141488e5bce4401c80b491688932085)) + +### [1.0.0-alpha.1](https://github.com/KRTirtho/fl-query/compare/v0.3.0...v1.0.0-alpha.1) (2023-03-05) + +> **BREAKING** +> - The Jobs API has been disabled. So there's no `QueryJob`, `MutationJob` and `InfiniteQueryJob` anymore. Instead, you can use the `QueryBuilder`, `MutationBuilder` and `InfiniteQueryBuilder` directly +> - Some of classes were renamed to more mature names +> - `QueryBowlProvider` -> `QueryClientProvider` +> - `QueryBowl` -> `QueryClient` +> - The unnecessary `getPreviousPageParam` is now removed from `InfiniteQuery` +> - `getNextPageParam` has been renamed to `nextPage` +> - Also, `fetchNextPage` has been renamed to `fetchNext` +> - `Query` and `InfiniteQuery`'s `setQueryData` has been renamed to `setData` and it now accepts data directly instead of a call back function +> - Finally, `QueryClient`'s unneeded `prefetchQuery` method was eradicated + + +### Features + +* add infinite query builder ([efa2c81](https://github.com/KRTirtho/fl-query/commit/efa2c81505385eba0ba45f50c0debb9e4708804b)) +* add mutation and mutation builder ([6a90f84](https://github.com/KRTirtho/fl-query/commit/6a90f847c90c242ec089ab85f9ec7201a9aacd06)) +* add query and infinite query disk caching support ([074175e](https://github.com/KRTirtho/fl-query/commit/074175ed392370d5165d0573977af8d83422ac31)) +* add Cache, Client, QueryBuilder widget and refreshOnQueryFnChange support for queries ([18584a3](https://github.com/KRTirtho/fl-query/commit/18584a3c57dbb1538fc18a48b41be11fbc11d094)) +* InfiniteQuery implementation ([45b6f92](https://github.com/KRTirtho/fl-query/commit/45b6f92316ca1496e47462eb67aea64f43f8d9c1)) +* add InfiniteQueryListenable widget and cache event stream ([783a273](https://github.com/KRTirtho/fl-query/commit/783a2737b18283478d65082e236629188c124e6b)) +* add Query and Retryer ([b304466](https://github.com/KRTirtho/fl-query/commit/b304466d73654a89c9582b8211b063ae8c661454)) +* infinite query's nextPage method ([f2a23b0](https://github.com/KRTirtho/fl-query/commit/f2a23b085cd657a1612d87749f6592b4d67814c5)) +* new QueryListableBuilder widget ([975f9ea](https://github.com/KRTirtho/fl-query/commit/975f9eafe14d2ae235a67c173622f16ef850e8e7)) +* safe cancellation of running operation on reset ([5dde200](https://github.com/KRTirtho/fl-query/commit/5dde200c84836aba676708c2dd2682a861edb289)) +* safe setState for builders, separate cache box for query and infinite query ([68e60c1](https://github.com/KRTirtho/fl-query/commit/68e60c1914d321bb8e23516966bafc990ea2bc31)) +* add usMutation hook ([383d0e0](https://github.com/KRTirtho/fl-query/commit/383d0e0a85d7db6ee30bc336cb849f4ea401a8f1)) +* add useInfiniteQuery hook ([f9a5207](https://github.com/KRTirtho/fl-query/commit/f9a520740321ababa3974e232562b32364062a35)) +* add useQuery hook ([7fabf44](https://github.com/KRTirtho/fl-query/commit/7fabf44756ed36aaa4481583167735bc18f97ad1)) + ### [0.3.1](https://github.com/KRTirtho/fl-query/compare/v0.3.0...v0.3.1) (2022-10-03) diff --git a/packages/fl_query/README.md b/packages/fl_query/README.md index bb626c9..f37cab9 100644 --- a/packages/fl_query/README.md +++ b/packages/fl_query/README.md @@ -16,7 +16,8 @@ Fl-Query makes asynchronous server state management a breeze in flutter - Smart + effective refetching - Optimistic updates - Automatically cached data invalidation & unneeded query/mutation garbage collection -- Infinite data pagination via `InfiniteQuery` +- Infinite pagination via `InfiniteQuery` +- Lazy persistent cache (Uses [hive](https://pub.dev/packages/hive) for persisting query results to disk) (optional) - Easy to write & understand code. Follows DRY (Don't repeat yourself) convention - Compatible with both vanilla Flutter & elite [flutter_hooks](https://pub.dev/packages/flutter_hooks) @@ -28,25 +29,34 @@ Regular installation: $ flutter pub add fl_query ``` -For elite flutter_hooks user: +For elite flutter_hooks user (Welcome to the flutter cool community btw😎) ```bash -$ flutter pub add flutter_hooks -$ flutter pub add fl_query_hooks +$ flutter pub add flutter_hooks fl_query_hooks ``` # Docs -You can find the documentation (WIP) of fl-query at https://fl-query.vercel.app/ +You can find the documentation of fl-query at https://fl-query.vercel.app/ # Basic Usage -First wrap your `MaterialApp` with with `QueryBowlScope` widget +Initialize the cache databases in your `main` method + +> fl-query uses [hive](https://pub.dev/packages/hive) for persisting data to disk + +```dart +void main()async { + WidgetsFlutterBinding.ensureInitialized(); + await QueryClient.initialize(cachePrefix: 'fl_query_example'); + runApp(MyApp()); +} +``` +In `MyApp` Widget's build method wrap your `MaterialApp` with with `QueryClientProvider` widget ```dart Widget build(BuildContext context) { - return QueryBowlScope( - bowl: QueryBowl(), + return QueryClientProvider( child: MaterialApp( title: 'Fl-Query Example App', theme: ThemeData( @@ -59,104 +69,116 @@ First wrap your `MaterialApp` with with `QueryBowlScope` widget } ``` -Fl-Query has two types of jobs - - `QueryJob`: Used for storing GET requests or for storing changeable yet readonly async data - - `MutationJob`: Used for POST/PUT/DELETE requests or for mutating/changing data in services or a store asynchronously +Let's write use a `Query` now +FL-Query provides a `QueryBuilder` widget that creates and listens to the specified `Query` +and re-runs the builder function whenever there's an update -You can write all your query or mutation logic a method parameter named `task` & identify the query uniquely by passing a unique `queryKey` - -Example of a QueryJob: +It has 2 required parameters(unnamed) `key` & `builder` ```dart -final exampleQueryJob = QueryJob( - queryKey: "example", // have to be unique - task: (queryKey, externalData) async { - final res = await http.get("/api/example-data"); - return jsonDecode(res.body); - } -); -``` +class MyApp extends StatelessWidget{ + MyApp({super.key}); -Store the `QueryJob` somewhere globally accessible in your project so you can reuse it later - -Now you can use this `QueryJob` anywhere inside your flutter app inside the build method using a `QueryBuilder` widget - -```dart -Widget build(BuildContext context){ - return QueryBuilder( - job: exampleQueryJob, - externalData: null, - builder: (context, query) { - if (!query.hasData || query.isLoading) { - return const CircularProgressIndicator(); - } - return Row( - children: [ - Text(query.data!), - ElevatedButton( - child: const Text("Refetch"), - onPressed: () async { - // refetches the query - await query.refetch(); - }, - ), - ], - ); - }, - ); -} -``` - -Or if you're an elite **flutter_hooks** user you can use the `useQuery` hook which is exported from the `package:fl_query_hooks/fl_query_hooks.dart` to do the same thing as above - -```dart -/* other imports */ -import 'package:flutter_hooks/flutter_hooks.dart'; -import 'package:fl_query_hooks/fl_query_hooks.dart'; // importing the fl-query hook package - -class Example extends HookWidget{ - Example(super.key); - - Widget build(BuildContext context) { - final query = useQuery(job: exampleQueryJob, externalData: null); - - if (!query.hasData || query.isLoading) { - return const CircularProgressIndicator(); - } - return Row( - children: [ - Text(query.data!), - ElevatedButton( - child: const Text("Refetch"), - onPressed: () async { - // refetches the query - await query.refetch(); - }, + @override + build(context){ + return QueryBuilder( + 'hello', + () { + return Future.delayed( + const Duration(seconds: 6), () => 'Hello World!'); + }, + initial: 'A replacement', + jsonConfig: JsonConfig( + fromJson: (json) => json['data'], + toJson: (data) => {'data': data}, ), - ], - ); - } + onData: (value) { + debugPrint('onData: $value'); + }, + onError: (error) { + debugPrint('onError: $error'); + }, + builder: (context, query) { + if (query.isLoading) { + return const Center( + child: CircularProgressIndicator(), + ); + } else if (query.hasError) { + return Center( + child: Text(query.error.toString()), + ); + } + return Center( + child: Text(query.data ?? "Unfortunately, there's no data"), + ); + }, + ); + } } ``` +And if you're using **flutter_hooks** you got that too + +```dart +class MyApp extends HookWidget{ + MyApp({super.key}); + + @override + build(context){ + final query = useQuery( + 'hello', + () { + return Future.delayed( + const Duration(seconds: 6), () => 'Hello World!'); + }, + initial: 'A replacement', + jsonConfig: JsonConfig( + fromJson: (json) => json['data'], + toJson: (data) => {'data': data}, + ), + onData: (value) { + debugPrint('onData: $value'); + }, + onError: (error) { + debugPrint('onError: $error'); + }, + ); + + if (query.isLoading) { + return const Center( + child: CircularProgressIndicator(), + ); + } else if (query.hasError) { + return Center( + child: Text(query.error.toString()), + ); + } + return Center( + child: Text(query.data ?? "Unfortunately, there's no data"), + ); + } +} +``` + +*To master the fl-query follow the official blog at https://fl-query.vercel.app/blog* + # Why?

The hell, why?

The main purpose of Fl-Query is providing the easiest way to manage the messy server-state part requiring the least amount of code with code reusability & performance +This let's you focus more on those cool UI animations & transitions✨. Leave the boring stuff to fl-query -**Isn't `FutureBuilder` good?** -Yes but it is only if your commercial server has huge load of power & you're made of money or your app is simple or mostly offline & barely requires internet connection -`FutureBuilder` isn't good for data persistency & its impossible to share data across the entire application using it +**Q. Isn't `FutureBuilder` good?** -**So `FutureProvider` from riverpod or provider not enough?** -Yeah, indeed its more than enough for many applications but what if your app needs Optimistic Updates & proper server-state synchronization or simply want a custom `cacheTime`? Although `FutureProvider` is a viable solution most of the `Future` related stuff, why not kick it up a notch with smart refetching capabilities with proper server-state synchronization? -Riverpod is definitely a inspiration for Fl-Query & the `QueryJob` is actually inspired by riverpod & imo is the best state management solution any library has ever provided but that's still a client state manager just like other client state manager or synchronous data manager + No, of course not. Unless you're from 2013 or your app is a purely offline app +**Q. So `FutureProvider` from riverpod or provider not enough?** + +Probably yes. Although riverpod@v2 has added a lot of caching related features but still optimistic updates, periodic refetching & disk persistence are missing. Let's not forget about infinite pagination, it's a nightmare😅. In case of provider, same story. It's a great package but it's not ideal for server-state management # Notice Board -This project is currently under heavy development & not yet production ready. There are lot of features to cover. If anyone encounters any unintended behavior or any bug please report it. Also we're open to improvement suggestions & feature requests - -**Important!:** The project needs Dart-Flutter developers who are willing to contribute to the project by writing Tests. (I'm the worst example for tester) \ No newline at end of file +We need some bada** coders to write tests and ruin our life🥲 +100% coverage is our goal🙃 \ No newline at end of file diff --git a/packages/fl_query/example/.flutter-plugins b/packages/fl_query/example/.flutter-plugins deleted file mode 100644 index 7051ea8..0000000 --- a/packages/fl_query/example/.flutter-plugins +++ /dev/null @@ -1,12 +0,0 @@ -# This is a generated file; do not edit or check into version control. -connectivity_plus=/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-2.3.9/ -connectivity_plus_linux=/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_linux-1.3.1/ -connectivity_plus_macos=/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_macos-1.2.4/ -connectivity_plus_web=/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_web-1.2.5/ -connectivity_plus_windows=/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_windows-1.2.2/ -path_provider=/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/path_provider-2.0.11/ -path_provider_android=/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/path_provider_android-2.0.22/ -path_provider_ios=/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/path_provider_ios-2.0.11/ -path_provider_linux=/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/path_provider_linux-2.1.7/ -path_provider_macos=/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/path_provider_macos-2.0.6/ -path_provider_windows=/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/path_provider_windows-2.1.3/ diff --git a/packages/fl_query/example/.flutter-plugins-dependencies b/packages/fl_query/example/.flutter-plugins-dependencies deleted file mode 100644 index a69857c..0000000 --- a/packages/fl_query/example/.flutter-plugins-dependencies +++ /dev/null @@ -1 +0,0 @@ -{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"connectivity_plus","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-2.3.9/","native_build":true,"dependencies":[]},{"name":"path_provider_ios","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/path_provider_ios-2.0.11/","native_build":true,"dependencies":[]}],"android":[{"name":"connectivity_plus","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-2.3.9/","native_build":true,"dependencies":[]},{"name":"path_provider_android","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/path_provider_android-2.0.22/","native_build":true,"dependencies":[]}],"macos":[{"name":"connectivity_plus_macos","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_macos-1.2.4/","native_build":true,"dependencies":[]},{"name":"path_provider_macos","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/path_provider_macos-2.0.6/","native_build":true,"dependencies":[]}],"linux":[{"name":"connectivity_plus_linux","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_linux-1.3.1/","native_build":false,"dependencies":[]},{"name":"path_provider_linux","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/path_provider_linux-2.1.7/","native_build":false,"dependencies":[]}],"windows":[{"name":"connectivity_plus_windows","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_windows-1.2.2/","native_build":true,"dependencies":[]},{"name":"path_provider_windows","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/path_provider_windows-2.1.3/","native_build":false,"dependencies":[]}],"web":[{"name":"connectivity_plus_web","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_web-1.2.5/","dependencies":[]}]},"dependencyGraph":[{"name":"connectivity_plus","dependencies":["connectivity_plus_linux","connectivity_plus_macos","connectivity_plus_web","connectivity_plus_windows"]},{"name":"connectivity_plus_linux","dependencies":[]},{"name":"connectivity_plus_macos","dependencies":[]},{"name":"connectivity_plus_web","dependencies":[]},{"name":"connectivity_plus_windows","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_android","path_provider_ios","path_provider_linux","path_provider_macos","path_provider_windows"]},{"name":"path_provider_android","dependencies":[]},{"name":"path_provider_ios","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_macos","dependencies":[]},{"name":"path_provider_windows","dependencies":[]}],"date_created":"2022-12-24 13:10:41.077116","version":"3.3.8"} \ No newline at end of file diff --git a/packages/fl_query/example/.gitignore b/packages/fl_query/example/.gitignore index a8e938c..24476c5 100644 --- a/packages/fl_query/example/.gitignore +++ b/packages/fl_query/example/.gitignore @@ -32,9 +32,6 @@ migrate_working_dir/ .pub/ /build/ -# Web related -lib/generated_plugin_registrant.dart - # Symbolication related app.*.symbols diff --git a/packages/fl_query/example/.metadata b/packages/fl_query/example/.metadata index 95f73f5..083a42e 100644 --- a/packages/fl_query/example/.metadata +++ b/packages/fl_query/example/.metadata @@ -4,7 +4,7 @@ # This file should be version controlled. version: - revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 + revision: b06b8b2710955028a6b562f5aa6fe62941d6febf channel: stable project_type: app @@ -13,26 +13,26 @@ project_type: app migration: platforms: - platform: root - create_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 - base_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 + create_revision: b06b8b2710955028a6b562f5aa6fe62941d6febf + base_revision: b06b8b2710955028a6b562f5aa6fe62941d6febf - platform: android - create_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 - base_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 + create_revision: b06b8b2710955028a6b562f5aa6fe62941d6febf + base_revision: b06b8b2710955028a6b562f5aa6fe62941d6febf - platform: ios - create_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 - base_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 + create_revision: b06b8b2710955028a6b562f5aa6fe62941d6febf + base_revision: b06b8b2710955028a6b562f5aa6fe62941d6febf - platform: linux - create_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 - base_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 + create_revision: b06b8b2710955028a6b562f5aa6fe62941d6febf + base_revision: b06b8b2710955028a6b562f5aa6fe62941d6febf - platform: macos - create_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 - base_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 + create_revision: b06b8b2710955028a6b562f5aa6fe62941d6febf + base_revision: b06b8b2710955028a6b562f5aa6fe62941d6febf - platform: web - create_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 - base_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 + create_revision: b06b8b2710955028a6b562f5aa6fe62941d6febf + base_revision: b06b8b2710955028a6b562f5aa6fe62941d6febf - platform: windows - create_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 - base_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 + create_revision: b06b8b2710955028a6b562f5aa6fe62941d6febf + base_revision: b06b8b2710955028a6b562f5aa6fe62941d6febf # User provided section diff --git a/packages/fl_query/example/README.md b/packages/fl_query/example/README.md index 2b3fce4..1b7a4e3 100644 --- a/packages/fl_query/example/README.md +++ b/packages/fl_query/example/README.md @@ -1,16 +1,3 @@ # example A new Flutter project. - -## Getting Started - -This project is a starting point for a Flutter application. - -A few resources to get you started if this is your first Flutter project: - -- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab) -- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook) - -For help getting started with Flutter development, view the -[online documentation](https://docs.flutter.dev/), which offers tutorials, -samples, guidance on mobile development, and a full API reference. diff --git a/packages/fl_query/example/analysis_options.yaml b/packages/fl_query/example/analysis_options.yaml index 61b6c4d..f9b3034 100644 --- a/packages/fl_query/example/analysis_options.yaml +++ b/packages/fl_query/example/analysis_options.yaml @@ -1,29 +1 @@ -# This file configures the analyzer, which statically analyzes Dart code to -# check for errors, warnings, and lints. -# -# The issues identified by the analyzer are surfaced in the UI of Dart-enabled -# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be -# invoked from the command line by running `flutter analyze`. - -# The following line activates a set of recommended lints for Flutter apps, -# packages, and plugins designed to encourage good coding practices. include: package:flutter_lints/flutter.yaml - -linter: - # The lint rules applied to this project can be customized in the - # section below to disable rules from the `package:flutter_lints/flutter.yaml` - # included above or to enable additional rules. A list of all available lints - # and their documentation is published at - # https://dart-lang.github.io/linter/lints/index.html. - # - # Instead of disabling a lint rule for the entire project in the - # section below, it can also be suppressed for a single line of code - # or a specific dart file by using the `// ignore: name_of_lint` and - # `// ignore_for_file: name_of_lint` syntax on the line or in the file - # producing the lint. - rules: - # avoid_print: false # Uncomment to disable the `avoid_print` rule - # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule - -# Additional information about this file can be found at -# https://dart.dev/guides/language/analysis-options diff --git a/packages/fl_query/example/android/app/build.gradle b/packages/fl_query/example/android/app/build.gradle index 0833ecf..b52183a 100644 --- a/packages/fl_query/example/android/app/build.gradle +++ b/packages/fl_query/example/android/app/build.gradle @@ -46,7 +46,7 @@ android { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "com.example.example" // You can update the following values to match your application needs. - // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration. + // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration. minSdkVersion flutter.minSdkVersion targetSdkVersion flutter.targetSdkVersion versionCode flutterVersionCode.toInteger() diff --git a/packages/fl_query/example/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java b/packages/fl_query/example/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java deleted file mode 100644 index 13c6128..0000000 --- a/packages/fl_query/example/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java +++ /dev/null @@ -1,29 +0,0 @@ -package io.flutter.plugins; - -import androidx.annotation.Keep; -import androidx.annotation.NonNull; -import io.flutter.Log; - -import io.flutter.embedding.engine.FlutterEngine; - -/** - * Generated file. Do not edit. - * This file is generated by the Flutter tool based on the - * plugins that support the Android platform. - */ -@Keep -public final class GeneratedPluginRegistrant { - private static final String TAG = "GeneratedPluginRegistrant"; - public static void registerWith(@NonNull FlutterEngine flutterEngine) { - try { - flutterEngine.getPlugins().add(new dev.fluttercommunity.plus.connectivity.ConnectivityPlugin()); - } catch(Exception e) { - Log.e(TAG, "Error registering plugin connectivity_plus, dev.fluttercommunity.plus.connectivity.ConnectivityPlugin", e); - } - try { - flutterEngine.getPlugins().add(new io.flutter.plugins.pathprovider.PathProviderPlugin()); - } catch(Exception e) { - Log.e(TAG, "Error registering plugin path_provider_android, io.flutter.plugins.pathprovider.PathProviderPlugin", e); - } - } -} diff --git a/packages/fl_query/example/android/build.gradle b/packages/fl_query/example/android/build.gradle index 83ae220..58a8c74 100644 --- a/packages/fl_query/example/android/build.gradle +++ b/packages/fl_query/example/android/build.gradle @@ -1,12 +1,12 @@ buildscript { - ext.kotlin_version = '1.6.10' + ext.kotlin_version = '1.7.10' repositories { google() mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:7.1.2' + classpath 'com.android.tools.build:gradle:7.2.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } diff --git a/packages/fl_query/example/android/gradle/wrapper/gradle-wrapper.jar b/packages/fl_query/example/android/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 13372ae..0000000 Binary files a/packages/fl_query/example/android/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/packages/fl_query/example/android/gradle/wrapper/gradle-wrapper.properties b/packages/fl_query/example/android/gradle/wrapper/gradle-wrapper.properties index cc5527d..3c472b9 100644 --- a/packages/fl_query/example/android/gradle/wrapper/gradle-wrapper.properties +++ b/packages/fl_query/example/android/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,5 @@ -#Fri Jun 23 08:50:38 CEST 2017 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip diff --git a/packages/fl_query/example/android/gradlew b/packages/fl_query/example/android/gradlew deleted file mode 100755 index 9d82f78..0000000 --- a/packages/fl_query/example/android/gradlew +++ /dev/null @@ -1,160 +0,0 @@ -#!/usr/bin/env bash - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn ( ) { - echo "$*" -} - -die ( ) { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; -esac - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules -function splitJvmOpts() { - JVM_OPTS=("$@") -} -eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS -JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" - -exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/packages/fl_query/example/android/gradlew.bat b/packages/fl_query/example/android/gradlew.bat deleted file mode 100644 index aec9973..0000000 --- a/packages/fl_query/example/android/gradlew.bat +++ /dev/null @@ -1,90 +0,0 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windowz variants - -if not "%OS%" == "Windows_NT" goto win9xME_args -if "%@eval[2+2]" == "4" goto 4NT_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* -goto execute - -:4NT_args -@rem Get arguments from the 4NT Shell from JP Software -set CMD_LINE_ARGS=%$ - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/packages/fl_query/example/android/local.properties b/packages/fl_query/example/android/local.properties deleted file mode 100644 index 46883a8..0000000 --- a/packages/fl_query/example/android/local.properties +++ /dev/null @@ -1,5 +0,0 @@ -sdk.dir=/home/krtirtho/Android/Sdk -flutter.sdk=/home/krtirtho/fvm/versions/3.3.5 -flutter.buildMode=debug -flutter.versionName=1.0.0 -flutter.versionCode=1 \ No newline at end of file diff --git a/packages/fl_query/example/ios/Flutter/AppFrameworkInfo.plist b/packages/fl_query/example/ios/Flutter/AppFrameworkInfo.plist index 8d4492f..9625e10 100644 --- a/packages/fl_query/example/ios/Flutter/AppFrameworkInfo.plist +++ b/packages/fl_query/example/ios/Flutter/AppFrameworkInfo.plist @@ -21,6 +21,6 @@ CFBundleVersion 1.0 MinimumOSVersion - 9.0 + 11.0 diff --git a/packages/fl_query/example/ios/Flutter/Generated.xcconfig b/packages/fl_query/example/ios/Flutter/Generated.xcconfig deleted file mode 100644 index 2ceb582..0000000 --- a/packages/fl_query/example/ios/Flutter/Generated.xcconfig +++ /dev/null @@ -1,14 +0,0 @@ -// This is a generated file; do not edit or check into version control. -FLUTTER_ROOT=/home/krtirtho/fvm/versions/3.3.5 -FLUTTER_APPLICATION_PATH=/home/krtirtho/dev/fl-query/packages/fl_query/example -COCOAPODS_PARALLEL_CODE_SIGN=true -FLUTTER_TARGET=lib/main.dart -FLUTTER_BUILD_DIR=build -FLUTTER_BUILD_NAME=1.0.0 -FLUTTER_BUILD_NUMBER=1 -EXCLUDED_ARCHS[sdk=iphonesimulator*]=i386 -EXCLUDED_ARCHS[sdk=iphoneos*]=armv7 -DART_OBFUSCATION=false -TRACK_WIDGET_CREATION=true -TREE_SHAKE_ICONS=false -PACKAGE_CONFIG=.dart_tool/package_config.json diff --git a/packages/fl_query/example/ios/Flutter/flutter_export_environment.sh b/packages/fl_query/example/ios/Flutter/flutter_export_environment.sh deleted file mode 100755 index 7557696..0000000 --- a/packages/fl_query/example/ios/Flutter/flutter_export_environment.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh -# This is a generated file; do not edit or check into version control. -export "FLUTTER_ROOT=/home/krtirtho/fvm/versions/3.3.5" -export "FLUTTER_APPLICATION_PATH=/home/krtirtho/dev/fl-query/packages/fl_query/example" -export "COCOAPODS_PARALLEL_CODE_SIGN=true" -export "FLUTTER_TARGET=lib/main.dart" -export "FLUTTER_BUILD_DIR=build" -export "FLUTTER_BUILD_NAME=1.0.0" -export "FLUTTER_BUILD_NUMBER=1" -export "DART_OBFUSCATION=false" -export "TRACK_WIDGET_CREATION=true" -export "TREE_SHAKE_ICONS=false" -export "PACKAGE_CONFIG=.dart_tool/package_config.json" diff --git a/packages/fl_query/example/ios/Runner.xcodeproj/project.pbxproj b/packages/fl_query/example/ios/Runner.xcodeproj/project.pbxproj index 6edd238..fe3d67b 100644 --- a/packages/fl_query/example/ios/Runner.xcodeproj/project.pbxproj +++ b/packages/fl_query/example/ios/Runner.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 50; + objectVersion = 54; objects = { /* Begin PBXBuildFile section */ @@ -171,6 +171,7 @@ /* Begin PBXShellScriptBuildPhase section */ 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; buildActionMask = 2147483647; files = ( ); @@ -185,6 +186,7 @@ }; 9740EEB61CF901F6004384FC /* Run Script */ = { isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; buildActionMask = 2147483647; files = ( ); @@ -272,7 +274,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; @@ -349,7 +351,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -398,7 +400,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; diff --git a/packages/fl_query/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png b/packages/fl_query/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png index 28c6bf0..7353c41 100644 Binary files a/packages/fl_query/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png and b/packages/fl_query/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png differ diff --git a/packages/fl_query/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png b/packages/fl_query/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png index 2ccbfd9..797d452 100644 Binary files a/packages/fl_query/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png and b/packages/fl_query/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png differ diff --git a/packages/fl_query/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png b/packages/fl_query/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png index f091b6b..6ed2d93 100644 Binary files a/packages/fl_query/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png and b/packages/fl_query/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png differ diff --git a/packages/fl_query/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png b/packages/fl_query/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png index 4cde121..4cd7b00 100644 Binary files a/packages/fl_query/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png and b/packages/fl_query/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png differ diff --git a/packages/fl_query/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png b/packages/fl_query/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png index d0ef06e..fe73094 100644 Binary files a/packages/fl_query/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png and b/packages/fl_query/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png differ diff --git a/packages/fl_query/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png b/packages/fl_query/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png index dcdc230..321773c 100644 Binary files a/packages/fl_query/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png and b/packages/fl_query/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png differ diff --git a/packages/fl_query/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png b/packages/fl_query/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png index 2ccbfd9..797d452 100644 Binary files a/packages/fl_query/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png and b/packages/fl_query/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png differ diff --git a/packages/fl_query/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png b/packages/fl_query/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png index c8f9ed8..502f463 100644 Binary files a/packages/fl_query/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png and b/packages/fl_query/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png differ diff --git a/packages/fl_query/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png b/packages/fl_query/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png index a6d6b86..0ec3034 100644 Binary files a/packages/fl_query/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png and b/packages/fl_query/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png differ diff --git a/packages/fl_query/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png b/packages/fl_query/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png index a6d6b86..0ec3034 100644 Binary files a/packages/fl_query/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png and b/packages/fl_query/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png differ diff --git a/packages/fl_query/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png b/packages/fl_query/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png index 75b2d16..e9f5fea 100644 Binary files a/packages/fl_query/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png and b/packages/fl_query/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png differ diff --git a/packages/fl_query/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png b/packages/fl_query/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png index c4df70d..84ac32a 100644 Binary files a/packages/fl_query/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png and b/packages/fl_query/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png differ diff --git a/packages/fl_query/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png b/packages/fl_query/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png index 6a84f41..8953cba 100644 Binary files a/packages/fl_query/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png and b/packages/fl_query/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png differ diff --git a/packages/fl_query/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png b/packages/fl_query/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png index d0e1f58..0467bf1 100644 Binary files a/packages/fl_query/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png and b/packages/fl_query/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png differ diff --git a/packages/fl_query/example/ios/Runner/GeneratedPluginRegistrant.h b/packages/fl_query/example/ios/Runner/GeneratedPluginRegistrant.h deleted file mode 100644 index 7a89092..0000000 --- a/packages/fl_query/example/ios/Runner/GeneratedPluginRegistrant.h +++ /dev/null @@ -1,19 +0,0 @@ -// -// Generated file. Do not edit. -// - -// clang-format off - -#ifndef GeneratedPluginRegistrant_h -#define GeneratedPluginRegistrant_h - -#import - -NS_ASSUME_NONNULL_BEGIN - -@interface GeneratedPluginRegistrant : NSObject -+ (void)registerWithRegistry:(NSObject*)registry; -@end - -NS_ASSUME_NONNULL_END -#endif /* GeneratedPluginRegistrant_h */ diff --git a/packages/fl_query/example/ios/Runner/GeneratedPluginRegistrant.m b/packages/fl_query/example/ios/Runner/GeneratedPluginRegistrant.m deleted file mode 100644 index d8aace8..0000000 --- a/packages/fl_query/example/ios/Runner/GeneratedPluginRegistrant.m +++ /dev/null @@ -1,28 +0,0 @@ -// -// Generated file. Do not edit. -// - -// clang-format off - -#import "GeneratedPluginRegistrant.h" - -#if __has_include() -#import -#else -@import connectivity_plus; -#endif - -#if __has_include() -#import -#else -@import path_provider_ios; -#endif - -@implementation GeneratedPluginRegistrant - -+ (void)registerWithRegistry:(NSObject*)registry { - [ConnectivityPlusPlugin registerWithRegistrar:[registry registrarForPlugin:@"ConnectivityPlusPlugin"]]; - [FLTPathProviderPlugin registerWithRegistrar:[registry registrarForPlugin:@"FLTPathProviderPlugin"]]; -} - -@end diff --git a/packages/fl_query/example/ios/Runner/Info.plist b/packages/fl_query/example/ios/Runner/Info.plist index 907f329..7f55346 100644 --- a/packages/fl_query/example/ios/Runner/Info.plist +++ b/packages/fl_query/example/ios/Runner/Info.plist @@ -45,5 +45,7 @@ CADisableMinimumFrameDurationOnPhone + UIApplicationSupportsIndirectInputEvents + diff --git a/packages/fl_query/example/lib/components/basic_infinite_query.dart b/packages/fl_query/example/lib/components/basic_infinite_query.dart deleted file mode 100644 index 3ce0af4..0000000 --- a/packages/fl_query/example/lib/components/basic_infinite_query.dart +++ /dev/null @@ -1,97 +0,0 @@ -import 'dart:convert'; - -import 'package:flutter/material.dart'; -import 'package:fl_query/fl_query.dart'; -import 'package:http/http.dart' as http; - -final infiniteQueryJob = InfiniteQueryJob( - queryKey: "infinite-posts", - initialParam: 1, - task: (queryKey, pageParam, externalData) async { - return jsonDecode( - (await http.get( - Uri.parse("https://jsonplaceholder.typicode.com/posts/$pageParam"), - )) - .body, - ); - }, - getNextPageParam: (lastPage, lastParam) { - return lastParam + 1; - }, - getPreviousPageParam: (lastPage, lastParam) { - return lastParam - 1; - }, -); - -class BasicInfiniteQueryExample extends StatelessWidget { - const BasicInfiniteQueryExample({Key? key}) : super(key: key); - - @override - Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar(), - body: InfiniteQueryBuilder( - job: infiniteQueryJob, - externalData: null, - builder: (context, infiniteQuery) { - return Stack( - children: [ - ListView.builder( - itemCount: infiniteQuery.pages.length + 1, - itemBuilder: (context, index) { - if (index == 0) { - return Text( - """ - InfiniteQuery properties - - isFetchingNextPage: ${infiniteQuery.isFetchingNextPage} - isFetchingPreviousPage: ${infiniteQuery.isFetchingPreviousPage} - isLoading: ${infiniteQuery.isLoading} - isRefetching: ${infiniteQuery.isRefetching} - isError: ${infiniteQuery.isError} - isSuccess: ${infiniteQuery.isSuccess} - isIdle: ${infiniteQuery.isIdle} - isInactive: ${infiniteQuery.isInactive} - isStale: ${infiniteQuery.isStale} - fetched: ${infiniteQuery.fetched} - - hasData: ${infiniteQuery.hasData} - hasError: ${infiniteQuery.hasError} - hasNextPage: ${infiniteQuery.hasNextPage} - hasPreviousPage: ${infiniteQuery.hasPreviousPage} - - refetchCount: ${infiniteQuery.refetchCount} - retryAttempts: ${infiniteQuery.retryAttempts} - updatedAt: ${infiniteQuery.updatedAt} - """, - ); - } - final page = infiniteQuery.pages[index - 1]; - return ListTile( - title: Text(page?["title"] ?? ""), - subtitle: Text(page?["body"] ?? ""), - ); - }, - ), - Align( - alignment: Alignment.bottomRight, - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - IconButton( - icon: const Icon(Icons.refresh_rounded), - onPressed: () => infiniteQuery.refetchPages(), - ), - IconButton( - icon: const Icon(Icons.get_app_rounded), - onPressed: () => infiniteQuery.fetchNextPage(), - ), - ], - ), - ), - ], - ); - }), - ); - } -} diff --git a/packages/fl_query/example/lib/components/basic_mutation.dart b/packages/fl_query/example/lib/components/basic_mutation.dart deleted file mode 100644 index 348edf9..0000000 --- a/packages/fl_query/example/lib/components/basic_mutation.dart +++ /dev/null @@ -1,122 +0,0 @@ -import 'dart:convert'; -import 'dart:math'; - -import 'package:fl_query_example/components/basic_query.dart'; -import 'package:http/http.dart' as http; - -import 'package:fl_query/fl_query.dart'; -import 'package:flutter/material.dart'; - -final basicMutationJob = MutationJob>( - mutationKey: "basic-mutation-example", - task: (key, data) async { - final response = await http.post( - Uri.parse( - // to simulate a failing response environment - Random().nextBool() - ? "https://jsonplaceholder.typicode.com/posts" - : "https://google.com", - ), - headers: {'Content-type': 'application/json; charset=UTF-8'}, - body: jsonEncode(data), - ); - return jsonDecode(response.body); - }, -); - -class BasicMutationExample extends StatefulWidget { - const BasicMutationExample({Key? key}) : super(key: key); - - @override - State createState() => _BasicMutationExampleState(); -} - -class _BasicMutationExampleState extends State { - late TextEditingController titleController; - late TextEditingController bodyController; - late int id; - @override - void initState() { - super.initState(); - id = Random().nextInt(2000000); - titleController = TextEditingController(); - bodyController = TextEditingController(); - } - - @override - void dispose() { - titleController.dispose(); - bodyController.dispose(); - super.dispose(); - } - - @override - Widget build(BuildContext context) { - return Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - "# Basic Mutation Example (with Failure & Retry simulation)", - style: Theme.of(context).textTheme.headline5, - ), - MutationBuilder>( - job: basicMutationJob, - onMutate: (v) { - final data = - QueryBowl.of(context).getQuery(successJob.queryKey)?.data; - QueryBowl.of(context) - .setQueryData(successJob.queryKey, (oldData) { - if (oldData?.contains("After Mutate (OPTIMISTIC UPDATE)") == - true) { - return "$oldData"; - } - return "$oldData - After Mutate (OPTIMISTIC UPDATE)"; - }); - return data; - }, - onData: (data, variables, context) { - print("Passed Variable: $variables"); - print("Safe Previous Value: $context"); - }, - builder: (context, mutation) { - return Padding( - padding: const EdgeInsets.all(8.0), - child: Column( - children: [ - TextField( - controller: titleController, - decoration: const InputDecoration(labelText: "Title"), - ), - TextField( - controller: bodyController, - decoration: const InputDecoration(labelText: "Body"), - ), - const SizedBox(height: 20), - ElevatedButton( - onPressed: () { - final title = titleController.value.text; - final body = bodyController.value.text; - if (body.isEmpty || title.isEmpty) return; - mutation.mutate({ - "title": title, - "body": body, - "id": id, - }, onData: (data, variables, context) { - // resetting the form - titleController.text = ""; - bodyController.text = ""; - }); - }, - child: const Text("Post"), - ), - const SizedBox(height: 20), - if (mutation.hasData) Text("Response\n${mutation.data}"), - if (mutation.hasError) Text(mutation.error.toString()), - ], - ), - ); - }), - ], - ); - } -} diff --git a/packages/fl_query/example/lib/components/basic_query.dart b/packages/fl_query/example/lib/components/basic_query.dart deleted file mode 100644 index 16f39c2..0000000 --- a/packages/fl_query/example/lib/components/basic_query.dart +++ /dev/null @@ -1,94 +0,0 @@ -import 'dart:math'; - -import 'package:fl_query/fl_query.dart'; -import 'package:flutter/material.dart'; - -final bowl = QueryBowl(); - -final successJob = QueryJob( - queryKey: "greetings-example", - task: (queryKey, _) => Future.delayed( - const Duration(seconds: 2), - () => - "The work successfully executed. Data: key=($queryKey) value=${Random.secure().nextInt(100)}", - ), -); - -final canFailJob = QueryJob( - queryKey: "failure-example", - task: (queryKey, _) => Random().nextBool() - ? Future.error("$queryKey operation failed for unknown reason") - : Future.value( - "Successful execution. Result: $queryKey=${Random().nextInt(100)}", - ), -); - -class BasicQueryExample extends StatelessWidget { - const BasicQueryExample({Key? key}) : super(key: key); - - @override - Widget build(BuildContext context) { - return Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - "# Basic Query Example", - style: Theme.of(context).textTheme.headline5, - ), - QueryBuilder( - job: successJob, - externalData: null, - onData: (data) { - print("Success: $data"); - }, - builder: (context, query) { - if (!query.hasData || query.isLoading || query.isRefetching) { - return const CircularProgressIndicator(); - } - return Row( - children: [ - Text(query.data!), - ElevatedButton( - child: const Text("Refetch"), - onPressed: () async { - await query.refetch(); - }, - ), - ], - ); - }, - ), - QueryBuilder( - job: canFailJob, - externalData: null, - onError: (error) { - print("Error: $error"); - }, - builder: (context, query) { - if (!query.hasData || query.isLoading || query.isRefetching) { - return const CircularProgressIndicator(); - } - return Row( - children: [ - if (query.hasError) - Text( - "${query.error}. Retrying: ${query.retryAttempts}", - ), - if (query.hasData) - Text( - "Success after ${query.retryAttempts}\nData: ${query.data}", - ), - ElevatedButton( - child: const Text("Refetch"), - onPressed: () async { - await query.refetch(); - }, - ), - ], - ); - }, - ), - ], - ); - } -} diff --git a/packages/fl_query/example/lib/components/infinite_query_disk_cache.dart b/packages/fl_query/example/lib/components/infinite_query_disk_cache.dart deleted file mode 100644 index aeb7490..0000000 --- a/packages/fl_query/example/lib/components/infinite_query_disk_cache.dart +++ /dev/null @@ -1,127 +0,0 @@ -import 'dart:convert'; - -import 'package:fl_query/fl_query.dart'; -import 'package:flutter/material.dart'; -import 'package:http/http.dart' as http; - -class Todo { - int? userId; - int? id; - String? title; - bool? completed; - - Todo({this.userId, this.id, this.title, this.completed}); - - Todo.fromJson(Map json) { - userId = json['userId']; - id = json['id']; - title = json['title']; - completed = json['completed']; - } - - Map toJson() { - final Map data = {}; - data['userId'] = userId; - data['id'] = id; - data['title'] = title; - data['completed'] = completed; - return data; - } -} - -final infiniteQueryDiskCacheExampleQuery = - InfiniteQueryJob, void, int>( - queryKey: 'infiniteQueryDiskCacheExampleQuery', - initialParam: 0, - getNextPageParam: (lastPage, lastParam) { - if (lastPage.length < 5) return null; - return lastParam + 5; - }, - getPreviousPageParam: (firstPage, firstParam) { - if (firstParam == 0) return null; - return firstParam - 5; - }, - serialize: (data) { - return jsonEncode(data.map((todo) => todo.toJson()).toList()); - }, - deserialize: (raw) { - return List.from(jsonDecode(raw)) - .map((todo) => Todo.fromJson(todo)) - .toList(); - }, - serializePageParam: (param) => param.toString(), - deserializePageParam: (rawParam) => int.parse(rawParam), - task: (_, pageParam, __) async { - final res = await http.get( - Uri.parse( - "https://jsonplaceholder.typicode.com/todos?_start=$pageParam&_end=${pageParam + 5}"), - ); - final body = List.from(jsonDecode(res.body)) - .map((todo) => Todo.fromJson(todo)) - .toList() - ..shuffle(); - if (pageParam == 0) await Future.delayed(const Duration(seconds: 5)); - return body; - }, -); - -class InfiniteQueryDiskCacheExample extends StatefulWidget { - const InfiniteQueryDiskCacheExample({Key? key}) : super(key: key); - - @override - State createState() => - _InfiniteQueryDiskCacheExampleState(); -} - -class _InfiniteQueryDiskCacheExampleState - extends State { - @override - Widget build(BuildContext context) { - return ListTile( - title: const Text("Infinite Query Disk Cache Example"), - onTap: () { - Navigator.of(context).push( - MaterialPageRoute( - builder: (context) { - return Scaffold( - appBar: AppBar( - title: const Text("Infinite Query Disk Cache Example")), - body: InfiniteQueryBuilder, void, int>( - job: infiniteQueryDiskCacheExampleQuery, - externalData: null, - builder: (context, query) { - final data = query.pages - .expand((page) => page?.toList() ?? []) - .toList(); - return Scaffold( - floatingActionButton: FloatingActionButton( - child: const Icon(Icons.download_rounded), - onPressed: () { - if (query.hasNextPage == true) { - query.fetchNextPage(); - } - }, - ), - body: ListView.builder( - itemCount: data.length, - itemBuilder: (context, index) { - return CheckboxListTile( - value: data[index].completed == true, - title: Text(data[index].title ?? ""), - dense: true, - secondary: Text(data[index].id.toString()), - onChanged: null, - ); - }, - ), - ); - }, - ), - ); - }, - ), - ); - }, - ); - } -} diff --git a/packages/fl_query/example/lib/components/lazy_query.dart b/packages/fl_query/example/lib/components/lazy_query.dart deleted file mode 100644 index 6027f01..0000000 --- a/packages/fl_query/example/lib/components/lazy_query.dart +++ /dev/null @@ -1,46 +0,0 @@ -import 'package:fl_query/fl_query.dart'; -import 'package:flutter/material.dart'; - -final lazyQueryJob = QueryJob( - queryKey: "lazy-query", - enabled: false, - task: ( - queryKey, - data, - ) { - return Future.delayed(const Duration(milliseconds: 500), - () => "Result: key=$queryKey value=$data"); - }, -); - -class LazyQueryExample extends StatelessWidget { - const LazyQueryExample({Key? key}) : super(key: key); - - @override - Widget build(BuildContext context) { - return Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - "# Lazy Query Example", - style: Theme.of(context).textTheme.headline5, - ), - QueryBuilder( - job: lazyQueryJob, - externalData: "Love", - builder: (context, query) { - return Row( - children: [ - Text("Current Data: ${query.data ?? "Loading"}"), - ElevatedButton( - child: const Text("Refetch Query"), - onPressed: () => query.refetch(), - ), - ], - ); - }, - ), - ], - ); - } -} diff --git a/packages/fl_query/example/lib/components/mutation_variable_key.dart b/packages/fl_query/example/lib/components/mutation_variable_key.dart deleted file mode 100644 index ef69204..0000000 --- a/packages/fl_query/example/lib/components/mutation_variable_key.dart +++ /dev/null @@ -1,67 +0,0 @@ -import 'dart:math'; - -import 'package:fl_query/fl_query.dart'; -import 'package:flutter/material.dart'; - -final mutationVariableKeyJob = MutationJob.withVariableKey( - preMutationKey: "mutation-example", - task: (queryKey, variables) { - return Future.value("$variables"); - }, -); - -class MutationVariableKeyExample extends StatefulWidget { - const MutationVariableKeyExample({Key? key}) : super(key: key); - - @override - State createState() => - _MutationVariableKeyExampleState(); -} - -class _MutationVariableKeyExampleState - extends State { - late double id; - - @override - void initState() { - super.initState(); - id = Random().nextDouble(); - } - - @override - Widget build(BuildContext context) { - return Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - "# Mutation Variable Key Example", - style: Theme.of(context).textTheme.headline5, - ), - MutationBuilder( - job: mutationVariableKeyJob(id.toString()), - builder: (context, mutation) { - return Row( - children: [ - Text("${mutation.mutationKey} Result: ${mutation.data}"), - ElevatedButton( - child: const Text("Generate Random Data"), - onPressed: () { - mutation.mutate(Random().nextDouble()); - }, - ), - ElevatedButton( - child: const Text("New Mutation"), - onPressed: () { - setState(() { - id = Random().nextDouble(); - }); - }, - ), - ], - ); - }, - ) - ], - ); - } -} diff --git a/packages/fl_query/example/lib/components/query_disk_cache.dart b/packages/fl_query/example/lib/components/query_disk_cache.dart deleted file mode 100644 index b6b4dd2..0000000 --- a/packages/fl_query/example/lib/components/query_disk_cache.dart +++ /dev/null @@ -1,79 +0,0 @@ -import 'dart:convert'; - -import 'package:fl_query/fl_query.dart'; -import 'package:flutter/material.dart'; -import 'package:http/http.dart' as http; - -final queryDiskCacheExampleQuery = QueryJob, void>( - queryKey: 'queryDiskCacheExampleQuery', - serialize: (data) { - return jsonEncode(data.map((user) => user.toJson()).toList()); - }, - deserialize: (raw) { - return List.from(jsonDecode(raw)) - .map((user) => User.fromJson(user)) - .toList(); - }, - task: (_, __) async { - final res = - await http.get(Uri.parse("https://jsonplaceholder.typicode.com/users")); - final body = List.from(jsonDecode(res.body)) - .map((user) => User.fromJson(user)) - .toList() - ..shuffle(); - await Future.delayed(const Duration(seconds: 5)); - return body; - }, -); - -class User { - int? id; - String? name; - String? username; - String? email; - - User({this.id, this.name, this.username, this.email}); - - User.fromJson(Map json) { - id = json['id']; - name = json['name']; - username = json['username']; - email = json['email']; - } - - Map toJson() { - final Map data = {}; - data['id'] = id; - data['name'] = name; - data['username'] = username; - data['email'] = email; - return data; - } -} - -class QueryDiskCacheExample extends StatelessWidget { - const QueryDiskCacheExample({Key? key}) : super(key: key); - - @override - Widget build(BuildContext context) { - return QueryBuilder, void>( - job: queryDiskCacheExampleQuery, - externalData: null, - builder: (context, query) { - if (!query.hasData) { - return const Center(child: CircularProgressIndicator()); - } - return ListView.builder( - shrinkWrap: true, - itemCount: query.data?.length, - itemBuilder: (context, index) { - return ListTile( - title: Text(query.data![index].name!), - subtitle: Text(query.data![index].email!), - ); - }, - ); - }, - ); - } -} diff --git a/packages/fl_query/example/lib/components/query_external_data.dart b/packages/fl_query/example/lib/components/query_external_data.dart deleted file mode 100644 index d835835..0000000 --- a/packages/fl_query/example/lib/components/query_external_data.dart +++ /dev/null @@ -1,75 +0,0 @@ -import 'dart:math'; - -import 'package:fl_query/fl_query.dart'; -import 'package:flutter/material.dart'; - -final jobWithExternalData = QueryJob( - queryKey: "query-external-data", - cacheTime: const Duration(seconds: 10), - refetchOnExternalDataChange: true, - task: (queryKey, data) { - return Future.delayed(const Duration(milliseconds: 500), - () => "Hello from $queryKey with $data"); - }, -); - -class QueryExternalDataExample extends StatefulWidget { - const QueryExternalDataExample({Key? key}) : super(key: key); - - @override - State createState() => - _QueryExternalDataExampleState(); -} - -class _QueryExternalDataExampleState extends State { - late double externalData; - - @override - void initState() { - super.initState(); - externalData = Random().nextDouble() * 200; - } - - @override - Widget build(BuildContext context) { - return Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - "# Query With External Data Example", - style: Theme.of(context).textTheme.headline5, - ), - QueryBuilder( - job: jobWithExternalData, - externalData: externalData, - builder: (context, query) { - if (query.isLoading || query.isRefetching || !query.hasData) { - return const CircularProgressIndicator(); - } - return Row( - children: [ - Container( - width: query.externalData, - height: query.externalData, - decoration: const BoxDecoration( - shape: BoxShape.circle, - color: Colors.blue, - ), - child: Center(child: Text(query.externalData.toString())), - ), - ElevatedButton( - child: const Text("New Id"), - onPressed: () { - setState(() { - externalData = Random().nextDouble() * 200; - }); - }, - ) - ], - ); - }, - ), - ], - ); - } -} diff --git a/packages/fl_query/example/lib/components/query_previous_data.dart b/packages/fl_query/example/lib/components/query_previous_data.dart deleted file mode 100644 index 50a68b4..0000000 --- a/packages/fl_query/example/lib/components/query_previous_data.dart +++ /dev/null @@ -1,70 +0,0 @@ -import 'dart:convert'; - -import 'package:fl_query/fl_query.dart'; -import 'package:flutter/material.dart'; -import 'package:http/http.dart' as http; - -final todoJob = QueryJob.withVariableKey( - preQueryKey: "todo", - task: (queryKey, _) async { - final res = await http.get( - Uri.parse( - "https://jsonplaceholder.typicode.com/todos/${getVariable(queryKey)}"), - ); - return jsonDecode(res.body); - }, - keepPreviousData: true, -); - -class QueryPreviousDataExample extends StatefulWidget { - const QueryPreviousDataExample({Key? key}) : super(key: key); - - @override - State createState() => - _QueryPreviousDataExampleState(); -} - -class _QueryPreviousDataExampleState extends State { - int id = 1; - - @override - Widget build(BuildContext context) { - return Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - "# Query Variable Key with keepPreviousData", - style: Theme.of(context).textTheme.headline5, - ), - QueryBuilder( - job: todoJob(id.toString()), - externalData: null, - builder: (context, query) { - if (query.hasError) return Text(query.error.toString()); - if (!query.hasData) return const CircularProgressIndicator(); - return Text(jsonEncode(query.data ?? {})); - }), - Row( - children: [ - IconButton( - icon: const Icon(Icons.remove), - onPressed: () { - setState(() { - id -= 1; - }); - }, - ), - IconButton( - icon: const Icon(Icons.add), - onPressed: () { - setState(() { - id += 1; - }); - }, - ), - ], - ) - ], - ); - } -} diff --git a/packages/fl_query/example/lib/components/query_variable_key.dart b/packages/fl_query/example/lib/components/query_variable_key.dart deleted file mode 100644 index 0e8382f..0000000 --- a/packages/fl_query/example/lib/components/query_variable_key.dart +++ /dev/null @@ -1,66 +0,0 @@ -import 'dart:math'; - -import 'package:fl_query/fl_query.dart'; -import 'package:flutter/material.dart'; - -final queryVariableKeyJob = QueryJob.withVariableKey( - preQueryKey: "variable-query", - task: (queryKey, externalData) { - return Future.delayed( - const Duration(milliseconds: 500), - () => "QueryKey:${queryKey.split("#").last}", - ); - }, -); - -class QueryVariableKeyExample extends StatefulWidget { - const QueryVariableKeyExample({Key? key}) : super(key: key); - - @override - State createState() => - _QueryVariableKeyExampleState(); -} - -class _QueryVariableKeyExampleState extends State { - late double id; - @override - void initState() { - super.initState(); - id = Random().nextDouble() * 200; - } - - @override - Widget build(BuildContext context) { - return Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - "# Query Variable Example", - style: Theme.of(context).textTheme.headline5, - ), - QueryBuilder( - job: queryVariableKeyJob(id.toString()), - externalData: null, - builder: (context, query) { - if (query.isLoading || query.isRefetching || !query.hasData) { - return const CircularProgressIndicator(); - } - return Row( - children: [ - Text("Query Result: ${query.data}"), - ElevatedButton( - child: const Text("New Id"), - onPressed: () { - setState(() { - id = Random().nextDouble() * 200; - }); - }, - ), - ], - ); - }, - ), - ], - ); - } -} diff --git a/packages/fl_query/example/lib/generated_plugin_registrant.dart b/packages/fl_query/example/lib/generated_plugin_registrant.dart deleted file mode 100644 index 533f170..0000000 --- a/packages/fl_query/example/lib/generated_plugin_registrant.dart +++ /dev/null @@ -1,17 +0,0 @@ -// -// Generated file. Do not edit. -// - -// ignore_for_file: directives_ordering -// ignore_for_file: lines_longer_than_80_chars -// ignore_for_file: depend_on_referenced_packages - -import 'package:connectivity_plus_web/connectivity_plus_web.dart'; - -import 'package:flutter_web_plugins/flutter_web_plugins.dart'; - -// ignore: public_member_api_docs -void registerPlugins(Registrar registrar) { - ConnectivityPlusPlugin.registerWith(registrar); - registrar.registerMessageHandler(); -} diff --git a/packages/fl_query/example/lib/main.dart b/packages/fl_query/example/lib/main.dart index 1bca34e..b01b448 100644 --- a/packages/fl_query/example/lib/main.dart +++ b/packages/fl_query/example/lib/main.dart @@ -1,87 +1,44 @@ -import 'package:fl_query_example/components/basic_infinite_query.dart'; -import 'package:fl_query_example/components/basic_mutation.dart'; +import 'package:fl_query_connectivity_plus_adapter/fl_query_connectivity_plus_adapter.dart'; +import 'package:fl_query_devtools/fl_query_devtools.dart'; +import 'package:fl_query_example/router.dart'; import 'package:fl_query/fl_query.dart'; -import 'package:fl_query_example/components/basic_query.dart'; -import 'package:fl_query_example/components/infinite_query_disk_cache.dart'; -import 'package:fl_query_example/components/lazy_query.dart'; -import 'package:fl_query_example/components/mutation_variable_key.dart'; -import 'package:fl_query_example/components/query_disk_cache.dart'; -import 'package:fl_query_example/components/query_external_data.dart'; -import 'package:fl_query_example/components/query_previous_data.dart'; -import 'package:fl_query_example/components/query_variable_key.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/rendering.dart'; void main() async { WidgetsFlutterBinding.ensureInitialized(); - await initializeFlQuery(cacheKey: "example"); - debugRepaintRainbowEnabled = true; - runApp(const MyApp()); + await QueryClient.initialize( + cachePrefix: 'fl_query_example', + connectivity: FlQueryConnectivityPlusAdapter(), + ); + runApp( + QueryClientProvider( + child: const MainApp(), + ), + ); } -class MyApp extends StatelessWidget { - const MyApp({Key? key}) : super(key: key); +class MainApp extends StatelessWidget { + const MainApp({super.key}); @override Widget build(BuildContext context) { - return QueryBowlScope( - bowl: QueryBowl(), - child: MaterialApp( - // showPerformanceOverlay: true, - title: 'Flutter Demo', - theme: ThemeData( - useMaterial3: true, - primarySwatch: Colors.blue, - ), - home: const MyHomePage(), + return MaterialApp.router( + theme: ThemeData( + colorSchemeSeed: Colors.red[100], + useMaterial3: true, ), - ); - } -} - -class MyHomePage extends StatefulWidget { - const MyHomePage({Key? key}) : super(key: key); - - @override - State createState() => _MyHomePageState(); -} - -class _MyHomePageState extends State with WidgetsBindingObserver { - @override - Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar( - title: const Text("Fl Query Example"), - ), - body: SingleChildScrollView( - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Column( - children: [ - const BasicQueryExample(), - const QueryExternalDataExample(), - const LazyQueryExample(), - const QueryVariableKeyExample(), - const QueryPreviousDataExample(), - ListTile( - title: const Text("Infinite Query Example"), - trailing: const Icon(Icons.open_in_new), - onTap: () { - Navigator.of(context).push( - MaterialPageRoute( - builder: (context) => const BasicInfiniteQueryExample(), - ), - ); - }, + title: 'FL Query Example', + builder: (context, child) { + return FlQueryDevtools( + child: QueryStateResolverProvider( + child: child!, + offline: () => const Center( + child: Text("Why u offline? How can u live?"), ), - const QueryDiskCacheExample(), - const InfiniteQueryDiskCacheExample(), - const Divider(), - const BasicMutationExample(), - const MutationVariableKeyExample(), - ], - ), - )), + ), + ); + }, + routerConfig: router, ); } } diff --git a/packages/fl_query/example/lib/models/product.dart b/packages/fl_query/example/lib/models/product.dart new file mode 100644 index 0000000..f613d52 --- /dev/null +++ b/packages/fl_query/example/lib/models/product.dart @@ -0,0 +1,92 @@ +class Product { + int id; + String title; + String description; + double price; + double discountPercentage; + double rating; + double stock; + String brand; + String category; + String thumbnail; + List images; + + Product({ + required this.id, + required this.title, + required this.description, + required this.price, + required this.discountPercentage, + required this.rating, + required this.stock, + required this.brand, + required this.category, + required this.thumbnail, + required this.images, + }); + + Product.fromJson(Map json) + : id = json['id'], + title = json['title'], + description = json['description'], + price = json['price'].toDouble(), + discountPercentage = json['discountPercentage'].toDouble(), + rating = json['rating'].toDouble(), + stock = json['stock'].toDouble(), + brand = json['brand'], + category = json['category'], + thumbnail = json['thumbnail'], + images = json['images'].cast(); + + Map toJson() { + final Map data = { + 'id': id, + 'title': title, + 'description': description, + 'price': price, + 'discountPercentage': discountPercentage, + 'rating': rating, + 'stock': stock, + 'brand': brand, + 'category': category, + 'thumbnail': thumbnail, + 'images': images, + }; + return data; + } +} + +class PagedProducts { + List products; + int total; + int skip; + int limit; + + PagedProducts({ + this.products = const [], + required this.total, + required this.skip, + required this.limit, + }); + + PagedProducts.fromJson(Map json) + : products = json['products'] + ?.map((v) => Product.fromJson( + Map.castFrom(v), + )) + .toList() ?? + [], + total = json['total'], + skip = json['skip'], + limit = json['limit']; + + Map toJson() { + final Map data = { + 'products': products.map((v) => v.toJson()).toList(), + 'total': total, + 'skip': skip, + 'limit': limit, + }; + return data; + } +} diff --git a/packages/fl_query/example/lib/pages/home.dart b/packages/fl_query/example/lib/pages/home.dart new file mode 100644 index 0000000..1b5ae5c --- /dev/null +++ b/packages/fl_query/example/lib/pages/home.dart @@ -0,0 +1,31 @@ +import 'package:flutter/material.dart'; +import 'package:go_router/go_router.dart'; + +class HomePage extends StatelessWidget { + const HomePage({super.key}); + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text('FL Query Example'), + ), + body: ListView( + children: [ + ListTile( + title: const Text('Query'), + onTap: () => GoRouter.of(context).push('/query'), + ), + ListTile( + title: const Text('Infinite Query'), + onTap: () => GoRouter.of(context).push('/infinite-query'), + ), + ListTile( + title: const Text('Mutation'), + onTap: () => GoRouter.of(context).push('/mutation'), + ), + ], + ), + ); + } +} diff --git a/packages/fl_query/example/lib/pages/infinite_query.dart b/packages/fl_query/example/lib/pages/infinite_query.dart new file mode 100644 index 0000000..a6d8589 --- /dev/null +++ b/packages/fl_query/example/lib/pages/infinite_query.dart @@ -0,0 +1,109 @@ +import 'dart:convert'; + +import 'package:fl_query_example/models/product.dart'; +import 'package:fl_query/fl_query.dart'; +import 'package:flutter/material.dart'; +import 'package:http/http.dart'; + +class InfiniteQueryPageWidget extends StatefulWidget { + const InfiniteQueryPageWidget({super.key}); + + @override + State createState() => + _InfiniteQueryPageWidgetState(); +} + +class _InfiniteQueryPageWidgetState extends State { + final controller = ScrollController(); + + @override + void initState() { + super.initState(); + controller.addListener(() async { + if (controller.position.pixels == controller.position.maxScrollExtent) { + final query = QueryClient.of(context).getInfiniteQuery("products"); + await query?.fetchNext(); + } + }); + } + + @override + void dispose() { + controller.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text('Infinite Query'), + ), + floatingActionButton: + InfiniteQueryListenable("products", builder: (context, query) { + return FloatingActionButton( + onPressed: () { + query?.fetchNext(); + }, + child: Text(query?.pages.length.toString() ?? "-69"), + ); + }), + body: InfiniteQueryBuilder( + "products", + (page) async { + final res = await get(Uri.parse( + "https://dummyjson.com/products?limit=10&skip=${page * 10}", + )); + + if (res.statusCode == 200) { + return PagedProducts.fromJson(jsonDecode(res.body)); + } else { + throw ClientException(res.statusCode.toString(), res.request?.url); + } + }, + nextPage: (lastPage, lastPageData) { + /// returning [null] will set [hasNextPage] to [false] + if (lastPageData.products.length < 10) return null; + return lastPage + 1; + }, + initialPage: 0, + // jsonConfig: JsonConfig( + // fromJson: (json) => PagedProducts.fromJson(json), + // toJson: (data) => data.toJson(), + // ), + builder: (context, query) { + final products = query.pages.map((e) => e.products).expand((e) => e); + + return query.resolve( + (data) => ListView( + controller: controller, + children: [ + for (final product in products) + ListTile( + title: Text(product.title), + subtitle: Text(product.description), + leading: Image.network(product.thumbnail), + ), + if (query.hasNextPage) + const Center( + child: CircularProgressIndicator(), + ), + if (query.hasErrors) + ...query.errors.map((e) => Text(e.message)).toList(), + ], + ), + loading: () => const Center( + child: CircularProgressIndicator(), + ), + error: (error) => const Center( + child: Text("Sorry! There was an error :'("), + ), + offline: () => const Center( + child: Text("Yo. You're offline. Are you in a jungle?"), + ), + ); + }, + ), + ); + } +} diff --git a/packages/fl_query/example/lib/pages/mutation/mutation.dart b/packages/fl_query/example/lib/pages/mutation/mutation.dart new file mode 100644 index 0000000..6133a9f --- /dev/null +++ b/packages/fl_query/example/lib/pages/mutation/mutation.dart @@ -0,0 +1,128 @@ +import 'package:fl_query/fl_query.dart'; +import 'package:flutter/material.dart'; + +class MutationPage extends StatefulWidget { + const MutationPage({super.key}); + + @override + State createState() => _MutationPageState(); +} + +class _MutationPageState extends State { + late TextEditingController _nameController; + late TextEditingController _emailController; + late TextEditingController _passwordController; + + @override + void initState() { + super.initState(); + _nameController = TextEditingController(); + _emailController = TextEditingController(); + _passwordController = TextEditingController(); + } + + @override + void dispose() { + _nameController.dispose(); + _emailController.dispose(); + _passwordController.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text('Mutation'), + ), + body: MutationBuilder, dynamic, Map, + dynamic>( + 'sign-up', + (variables) { + return Future.delayed( + const Duration(seconds: 5), + () => { + 'name': variables['name'], + 'email': variables['email'], + 'password': variables['password'], + }, + ); + }, + onMutate: (variables) { + debugPrint('onMutate: $variables'); + return "Recover ME"; + }, + onData: (data, recoveryData) { + debugPrint('onData: $data'); + debugPrint('recoveryData: $recoveryData'); + }, + refreshQueries: const ['hello'], + builder: (context, mutation) { + if (mutation.hasData) { + return ListView( + padding: const EdgeInsets.all(16), + children: [ + Center( + child: Text('Welcome ${mutation.data!['name']}'), + ), + const SizedBox(height: 16), + Center( + child: Text('Your email is ${mutation.data!['email']}'), + ), + const SizedBox(height: 16), + ElevatedButton( + onPressed: () { + mutation.reset(); + }, + child: const Text('Log out'), + ), + ], + ); + } + + return ListView( + padding: const EdgeInsets.all(16), + children: [ + TextField( + controller: _nameController, + keyboardType: TextInputType.name, + decoration: const InputDecoration( + labelText: 'Name', + ), + ), + const SizedBox(height: 16), + TextField( + controller: _emailController, + keyboardType: TextInputType.emailAddress, + decoration: const InputDecoration( + labelText: 'Email', + ), + ), + const SizedBox(height: 16), + TextField( + controller: _passwordController, + obscureText: true, + decoration: const InputDecoration( + labelText: 'Password', + ), + ), + const SizedBox(height: 20), + ElevatedButton( + onPressed: () async { + await mutation.mutate({ + 'name': _nameController.text, + 'email': _emailController.text, + 'password': _passwordController.text, + }); + }, + child: mutation.isMutating + ? const CircularProgressIndicator() + : const Text('Sign Up'), + ), + ], + ); + }, + ), + ); + } +} diff --git a/packages/fl_query/example/lib/pages/query.dart b/packages/fl_query/example/lib/pages/query.dart new file mode 100644 index 0000000..e7e4f88 --- /dev/null +++ b/packages/fl_query/example/lib/pages/query.dart @@ -0,0 +1,58 @@ +import 'dart:math'; + +import 'package:fl_query/fl_query.dart'; +import 'package:flutter/material.dart'; + +class QueryPage extends StatelessWidget { + const QueryPage({super.key}); + + @override + Widget build(BuildContext context) { + final value = Random().nextInt(200000); + return Scaffold( + appBar: AppBar( + title: const Text('Query'), + ), + floatingActionButton: + QueryListenable('hello', builder: (context, query) { + if (query == null) { + return const SizedBox(); + } + return FloatingActionButton( + onPressed: () { + query.refresh(); + }, + child: Text(query.data ?? 'No Data'), + ); + }), + body: QueryBuilder( + 'hello', + () { + return Future.delayed( + const Duration(seconds: 6), + () => 'Hello World! $value', + ); + }, + initial: 'Hello', + // jsonConfig: JsonConfig( + // fromJson: (json) => json['data'], + // toJson: (data) => {'data': data}, + // ), + onData: (value) { + debugPrint('onData: $value'); + }, + onError: (error) { + debugPrint('onError: $error'); + }, + builder: (context, query) { + return query.resolveWith( + context, + (data) => Center(child: Text(data)), + error: (error) => Center(child: Text(error.toString())), + loading: () => const Center(child: CircularProgressIndicator()), + ); + }, + ), + ); + } +} diff --git a/packages/fl_query/example/lib/router.dart b/packages/fl_query/example/lib/router.dart new file mode 100644 index 0000000..dca362d --- /dev/null +++ b/packages/fl_query/example/lib/router.dart @@ -0,0 +1,27 @@ +import "package:fl_query_example/pages/home.dart"; +import "package:fl_query_example/pages/infinite_query.dart"; +import "package:fl_query_example/pages/mutation/mutation.dart"; +import "package:fl_query_example/pages/query.dart"; +import "package:go_router/go_router.dart"; + +final router = GoRouter( + initialLocation: '/', + routes: [ + GoRoute( + path: '/', + builder: (context, state) => const HomePage(), + ), + GoRoute( + path: '/query', + builder: (context, state) => const QueryPage(), + ), + GoRoute( + path: '/infinite-query', + builder: (context, state) => const InfiniteQueryPageWidget(), + ), + GoRoute( + path: '/mutation', + builder: (context, state) => const MutationPage(), + ), + ], +); diff --git a/packages/fl_query/example/linux/flutter/ephemeral/.plugin_symlinks/connectivity_plus_linux b/packages/fl_query/example/linux/flutter/ephemeral/.plugin_symlinks/connectivity_plus_linux deleted file mode 120000 index 81fb0db..0000000 --- a/packages/fl_query/example/linux/flutter/ephemeral/.plugin_symlinks/connectivity_plus_linux +++ /dev/null @@ -1 +0,0 @@ -/opt/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_linux-1.3.1/ \ No newline at end of file diff --git a/packages/fl_query/example/linux/flutter/ephemeral/flutter_linux/fl_basic_message_channel.h b/packages/fl_query/example/linux/flutter/ephemeral/flutter_linux/fl_basic_message_channel.h deleted file mode 100644 index b9fec01..0000000 --- a/packages/fl_query/example/linux/flutter/ephemeral/flutter_linux/fl_basic_message_channel.h +++ /dev/null @@ -1,205 +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. - -#ifndef FLUTTER_SHELL_PLATFORM_LINUX_FL_BASIC_MESSAGE_CHANNEL_H_ -#define FLUTTER_SHELL_PLATFORM_LINUX_FL_BASIC_MESSAGE_CHANNEL_H_ - -#if !defined(__FLUTTER_LINUX_INSIDE__) && !defined(FLUTTER_LINUX_COMPILATION) -#error "Only can be included directly." -#endif - -#include -#include - -#include "fl_binary_messenger.h" -#include "fl_message_codec.h" - -G_BEGIN_DECLS - -G_DECLARE_FINAL_TYPE(FlBasicMessageChannel, - fl_basic_message_channel, - FL, - BASIC_MESSAGE_CHANNEL, - GObject) - -G_DECLARE_FINAL_TYPE(FlBasicMessageChannelResponseHandle, - fl_basic_message_channel_response_handle, - FL, - BASIC_MESSAGE_CHANNEL_RESPONSE_HANDLE, - GObject) - -/** - * FlBasicMessageChannel: - * - * #FlBasicMessageChannel is an object that allows sending and receiving - * messages to/from Dart code over platform channels. - * - * The following example shows how to send messages on a channel: - * - * |[ - * static FlBasicMessageChannel *channel = NULL; - * - * static void message_cb (FlBasicMessageChannel* channel, - * FlValue* message, - * FlBasicMessageChannelResponseHandle* response_handle, - * gpointer user_data) { - * g_autoptr(FlValue) response = handle_message (message); - * g_autoptr(GError) error = NULL; - * if (!fl_basic_message_channel_respond (channel, response_handle, response, - * &error)) - * g_warning ("Failed to send channel response: %s", error->message); - * } - * - * static void message_response_cb (GObject *object, - * GAsyncResult *result, - * gpointer user_data) { - * g_autoptr(GError) error = NULL; - * g_autoptr(FlValue) response = - * fl_basic_message_channel_send_finish (FL_BASIC_MESSAGE_CHANNEL (object), - * result, &error); - * if (response == NULL) { - * g_warning ("Failed to send message: %s", error->message); - * return; - * } - * - * handle_response (response); - * } - * - * static void setup_channel () { - * g_autoptr(FlStandardMessageCodec) codec = fl_standard_message_codec_new (); - * channel = fl_basic_message_channel_new (messenger, "flutter/foo", - * FL_MESSAGE_CODEC (codec)); - * fl_basic_message_channel_set_message_handler (channel, message_cb, NULL, - * NULL); - * - * g_autoptr(FlValue) message = fl_value_new_string ("Hello World"); - * fl_basic_message_channel_send (channel, message, NULL, - * message_response_cb, NULL); - * } - * ]| - * - * #FlBasicMessageChannel matches the BasicMessageChannel class in the Flutter - * services library. - */ - -/** - * FlBasicMessageChannelResponseHandle: - * - * #FlBasicMessageChannelResponseHandle is an object used to send responses - * with. - */ - -/** - * FlBasicMessageChannelMessageHandler: - * @channel: an #FlBasicMessageChannel. - * @message: message received. - * @response_handle: a handle to respond to the message with. - * @user_data: (closure): data provided when registering this handler. - * - * Function called when a message is received. Call - * fl_basic_message_channel_respond() to respond to this message. If the - * response is not occurring in this callback take a reference to - * @response_handle and release that once it has been responded to. Failing to - * respond before the last reference to @response_handle is dropped is a - * programming error. - */ -typedef void (*FlBasicMessageChannelMessageHandler)( - FlBasicMessageChannel* channel, - FlValue* message, - FlBasicMessageChannelResponseHandle* response_handle, - gpointer user_data); - -/** - * fl_basic_message_channel_new: - * @messenger: an #FlBinaryMessenger. - * @name: a channel name. - * @codec: the message codec. - * - * Creates a basic message channel. @codec must match the codec used on the Dart - * end of the channel. - * - * Returns: a new #FlBasicMessageChannel. - */ -FlBasicMessageChannel* fl_basic_message_channel_new( - FlBinaryMessenger* messenger, - const gchar* name, - FlMessageCodec* codec); - -/** - * fl_basic_message_channel_set_message_handler: - * @channel: an #FlBasicMessageChannel. - * @handler: (allow-none): function to call when a message is received on this - * channel or %NULL to disable the handler. - * @user_data: (closure): user data to pass to @handler. - * @destroy_notify: (allow-none): a function which gets called to free - * @user_data, or %NULL. - * - * Sets the function called when a message is received from the Dart side of the - * channel. See #FlBasicMessageChannelMessageHandler for details on how to - * respond to messages. - * - * The handler is removed if the channel is closed or is replaced by another - * handler, set @destroy_notify if you want to detect this. - */ -void fl_basic_message_channel_set_message_handler( - FlBasicMessageChannel* channel, - FlBasicMessageChannelMessageHandler handler, - gpointer user_data, - GDestroyNotify destroy_notify); - -/** - * fl_basic_message_channel_respond: - * @channel: an #FlBasicMessageChannel. - * @response_handle: handle that was provided in a - * #FlBasicMessageChannelMessageHandler. - * @message: (allow-none): message response to send or %NULL for an empty - * response. - * @error: (allow-none): #GError location to store the error occurring, or %NULL - * to ignore. - * - * Responds to a message. - * - * Returns: %TRUE on success. - */ -gboolean fl_basic_message_channel_respond( - FlBasicMessageChannel* channel, - FlBasicMessageChannelResponseHandle* response_handle, - FlValue* message, - GError** error); - -/** - * fl_basic_message_channel_send: - * @channel: an #FlBasicMessageChannel. - * @message: message to send, must match what the #FlMessageCodec supports. - * @cancellable: (allow-none): a #GCancellable or %NULL. - * @callback: (scope async): (allow-none): a #GAsyncReadyCallback to call when - * the request is satisfied or %NULL to ignore the response. - * @user_data: (closure): user data to pass to @callback. - * - * Asynchronously sends a message. - */ -void fl_basic_message_channel_send(FlBasicMessageChannel* channel, - FlValue* message, - GCancellable* cancellable, - GAsyncReadyCallback callback, - gpointer user_data); - -/** - * fl_basic_message_channel_send_finish: - * @channel: an #FlBasicMessageChannel. - * @result: a #GAsyncResult. - * @error: (allow-none): #GError location to store the error occurring, or %NULL - * to ignore. - * - * Completes request started with fl_basic_message_channel_send(). - * - * Returns: message response on success or %NULL on error. - */ -FlValue* fl_basic_message_channel_send_finish(FlBasicMessageChannel* channel, - GAsyncResult* result, - GError** error); - -G_END_DECLS - -#endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_BASIC_MESSAGE_CHANNEL_H_ diff --git a/packages/fl_query/example/linux/flutter/ephemeral/flutter_linux/fl_binary_codec.h b/packages/fl_query/example/linux/flutter/ephemeral/flutter_linux/fl_binary_codec.h deleted file mode 100644 index e7223d8..0000000 --- a/packages/fl_query/example/linux/flutter/ephemeral/flutter_linux/fl_binary_codec.h +++ /dev/null @@ -1,45 +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. - -#ifndef FLUTTER_SHELL_PLATFORM_LINUX_FL_BINARY_CODEC_H_ -#define FLUTTER_SHELL_PLATFORM_LINUX_FL_BINARY_CODEC_H_ - -#if !defined(__FLUTTER_LINUX_INSIDE__) && !defined(FLUTTER_LINUX_COMPILATION) -#error "Only can be included directly." -#endif - -#include "fl_message_codec.h" - -G_BEGIN_DECLS - -G_DECLARE_FINAL_TYPE(FlBinaryCodec, - fl_binary_codec, - FL, - BINARY_CODEC, - FlMessageCodec) - -/** - * FlBinaryCodec: - * - * #FlBinaryCodec is an #FlMessageCodec that implements the Flutter binary - * message encoding. This only encodes and decodes #FlValue of type - * #FL_VALUE_TYPE_UINT8_LIST, other types #FlValues will generate an error - * during encoding. - * - * #FlBinaryCodec matches the BinaryCodec class in the Flutter services - * library. - */ - -/** - * fl_binary_codec_new: - * - * Creates an #FlBinaryCodec. - * - * Returns: a new #FlBinaryCodec. - */ -FlBinaryCodec* fl_binary_codec_new(); - -G_END_DECLS - -#endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_BINARY_CODEC_H_ diff --git a/packages/fl_query/example/linux/flutter/ephemeral/flutter_linux/fl_binary_messenger.h b/packages/fl_query/example/linux/flutter/ephemeral/flutter_linux/fl_binary_messenger.h deleted file mode 100644 index 84af654..0000000 --- a/packages/fl_query/example/linux/flutter/ephemeral/flutter_linux/fl_binary_messenger.h +++ /dev/null @@ -1,189 +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. - -#ifndef FLUTTER_SHELL_PLATFORM_LINUX_FL_BINARY_MESSENGER_H_ -#define FLUTTER_SHELL_PLATFORM_LINUX_FL_BINARY_MESSENGER_H_ - -#if !defined(__FLUTTER_LINUX_INSIDE__) && !defined(FLUTTER_LINUX_COMPILATION) -#error "Only can be included directly." -#endif - -#include -#include - -G_BEGIN_DECLS - -/** - * FlBinaryMessengerError: - * @FL_BINARY_MESSENGER_ERROR_ALREADY_RESPONDED: unable to send response, this - * message has already been responded to. - * - * Errors for #FlBinaryMessenger objects to set on failures. - */ -#define FL_BINARY_MESSENGER_ERROR fl_binary_messenger_codec_error_quark() - -typedef enum { - FL_BINARY_MESSENGER_ERROR_ALREADY_RESPONDED, -} FlBinaryMessengerError; - -GQuark fl_binary_messenger_codec_error_quark(void) G_GNUC_CONST; - -G_DECLARE_INTERFACE(FlBinaryMessenger, - fl_binary_messenger, - FL, - BINARY_MESSENGER, - GObject) - -G_DECLARE_DERIVABLE_TYPE(FlBinaryMessengerResponseHandle, - fl_binary_messenger_response_handle, - FL, - BINARY_MESSENGER_RESPONSE_HANDLE, - GObject) - -/** - * FlBinaryMessengerMessageHandler: - * @messenger: an #FlBinaryMessenger. - * @channel: channel message received on. - * @message: message content received from Dart. - * @response_handle: a handle to respond to the message with. - * @user_data: (closure): data provided when registering this handler. - * - * Function called when platform messages are received. Call - * fl_binary_messenger_send_response() to respond to this message. If the - * response is not occurring in this callback take a reference to - * @response_handle and release that once it has been responded to. Failing to - * respond before the last reference to @response_handle is dropped is a - * programming error. - */ -typedef void (*FlBinaryMessengerMessageHandler)( - FlBinaryMessenger* messenger, - const gchar* channel, - GBytes* message, - FlBinaryMessengerResponseHandle* response_handle, - gpointer user_data); - -struct _FlBinaryMessengerInterface { - GTypeInterface parent_iface; - - void (*set_message_handler_on_channel)( - FlBinaryMessenger* messenger, - const gchar* channel, - FlBinaryMessengerMessageHandler handler, - gpointer user_data, - GDestroyNotify destroy_notify); - - gboolean (*send_response)(FlBinaryMessenger* messenger, - FlBinaryMessengerResponseHandle* response_handle, - GBytes* response, - GError** error); - - void (*send_on_channel)(FlBinaryMessenger* messenger, - const gchar* channel, - GBytes* message, - GCancellable* cancellable, - GAsyncReadyCallback callback, - gpointer user_data); - - GBytes* (*send_on_channel_finish)(FlBinaryMessenger* messenger, - GAsyncResult* result, - GError** error); -}; - -struct _FlBinaryMessengerResponseHandleClass { - GObjectClass parent_class; -}; - -/** - * FlBinaryMessenger: - * - * #FlBinaryMessenger is an object that allows sending and receiving of platform - * messages with an #FlEngine. - */ - -/** - * FlBinaryMessengerResponseHandle: - * - * #FlBinaryMessengerResponseHandle is an object used to send responses with. - */ - -/** - * fl_binary_messenger_set_platform_message_handler: - * @binary_messenger: an #FlBinaryMessenger. - * @channel: channel to listen on. - * @handler: (allow-none): function to call when a message is received on this - * channel or %NULL to disable a handler - * @user_data: (closure): user data to pass to @handler. - * @destroy_notify: (allow-none): a function which gets called to free - * @user_data, or %NULL. - * - * Sets the function called when a platform message is received on the given - * channel. See #FlBinaryMessengerMessageHandler for details on how to respond - * to messages. - * - * The handler is removed if the channel is closed or is replaced by another - * handler, set @destroy_notify if you want to detect this. - */ -void fl_binary_messenger_set_message_handler_on_channel( - FlBinaryMessenger* messenger, - const gchar* channel, - FlBinaryMessengerMessageHandler handler, - gpointer user_data, - GDestroyNotify destroy_notify); - -/** - * fl_binary_messenger_send_response: - * @binary_messenger: an #FlBinaryMessenger. - * @response_handle: handle that was provided in a - * #FlBinaryMessengerMessageHandler. - * @response: (allow-none): response to send or %NULL for an empty response. - * @error: (allow-none): #GError location to store the error occurring, or %NULL - * to ignore. - * - * Responds to a platform message. - * - * Returns: %TRUE on success. - */ -gboolean fl_binary_messenger_send_response( - FlBinaryMessenger* messenger, - FlBinaryMessengerResponseHandle* response_handle, - GBytes* response, - GError** error); - -/** - * fl_binary_messenger_send_on_channel: - * @binary_messenger: an #FlBinaryMessenger. - * @channel: channel to send to. - * @message: (allow-none): message buffer to send or %NULL for an empty message. - * @cancellable: (allow-none): a #GCancellable or %NULL. - * @callback: (scope async): a #GAsyncReadyCallback to call when the request is - * satisfied. - * @user_data: (closure): user data to pass to @callback. - * - * Asynchronously sends a platform message. - */ -void fl_binary_messenger_send_on_channel(FlBinaryMessenger* messenger, - const gchar* channel, - GBytes* message, - GCancellable* cancellable, - GAsyncReadyCallback callback, - gpointer user_data); - -/** - * fl_binary_messenger_send_on_channel_finish: - * @binary_messenger: an #FlBinaryMessenger. - * @result: a #GAsyncResult. - * @error: (allow-none): #GError location to store the error occurring, or %NULL - * to ignore. - * - * Completes request started with fl_binary_messenger_send_on_channel(). - * - * Returns: (transfer full): message response on success or %NULL on error. - */ -GBytes* fl_binary_messenger_send_on_channel_finish(FlBinaryMessenger* messenger, - GAsyncResult* result, - GError** error); - -G_END_DECLS - -#endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_BINARY_MESSENGER_H_ diff --git a/packages/fl_query/example/linux/flutter/ephemeral/flutter_linux/fl_dart_project.h b/packages/fl_query/example/linux/flutter/ephemeral/flutter_linux/fl_dart_project.h deleted file mode 100644 index 1b56e24..0000000 --- a/packages/fl_query/example/linux/flutter/ephemeral/flutter_linux/fl_dart_project.h +++ /dev/null @@ -1,125 +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. - -#ifndef FLUTTER_SHELL_PLATFORM_LINUX_FL_DART_PROJECT_H_ -#define FLUTTER_SHELL_PLATFORM_LINUX_FL_DART_PROJECT_H_ - -#include - -#if !defined(__FLUTTER_LINUX_INSIDE__) && !defined(FLUTTER_LINUX_COMPILATION) -#error "Only can be included directly." -#endif - -G_BEGIN_DECLS - -G_DECLARE_FINAL_TYPE(FlDartProject, fl_dart_project, FL, DART_PROJECT, GObject) - -/** - * FlDartProject: - * - * #FlDartProject represents a Dart project. It is used to provide information - * about the application when creating an #FlView. - */ - -/** - * fl_dart_project_new: - * - * Creates a Flutter project for the currently running executable. The following - * data files are required relative to the location of the executable: - * - data/flutter_assets/ (as built by the Flutter tool). - * - data/icudtl.dat (provided as a resource by the Flutter tool). - * - lib/libapp.so (as built by the Flutter tool when in AOT mode). - * - * Returns: a new #FlDartProject. - */ -FlDartProject* fl_dart_project_new(); - -/** - * fl_dart_project_set_enable_mirrors: - * @project: an #FlDartProject. - * @enable_mirrors: %TRUE if the dart:mirrors library should be used. - * - * Sets if this Flutter project can use the dart:mirrors library. - * - * Deprecated: This function is temporary and will be removed in a future - * release. - */ -void fl_dart_project_set_enable_mirrors(FlDartProject* project, - gboolean enable_mirrors) G_DEPRECATED; - -/** - * fl_dart_project_get_enable_mirrors: - * @project: an #FlDartProject. - * - * Gets if this Flutter project can use the dart:mirrors library. - * - * Returns: %TRUE if the dart:mirrors library can be used. - * - * Deprecated: This function is temporary and will be removed in a future - * release. - */ -gboolean fl_dart_project_get_enable_mirrors(FlDartProject* project) - G_DEPRECATED; - -/** - * fl_dart_project_get_aot_library_path: - * @project: an #FlDartProject. - * - * Gets the path to the AOT library in the Flutter application. - * - * Returns: (type filename): an absolute file path, e.g. - * "/projects/my_dart_project/lib/libapp.so". - */ -const gchar* fl_dart_project_get_aot_library_path(FlDartProject* project); - -/** - * fl_dart_project_get_assets_path: - * @project: an #FlDartProject. - * - * Gets the path to the directory containing the assets used in the Flutter - * application. - * - * Returns: (type filename): an absolute directory path, e.g. - * "/projects/my_dart_project/data/flutter_assets". - */ -const gchar* fl_dart_project_get_assets_path(FlDartProject* project); - -/** - * fl_dart_project_get_icu_data_path: - * @project: an #FlDartProject. - * - * Gets the path to the ICU data file in the Flutter application. - * - * Returns: (type filename): an absolute file path, e.g. - * "/projects/my_dart_project/data/icudtl.dat". - */ -const gchar* fl_dart_project_get_icu_data_path(FlDartProject* project); - -/** - * fl_dart_project_set_dart_entrypoint_arguments: - * @project: an #FlDartProject. - * @argv: a pointer to a NULL-terminated array of C strings containing the - * command line arguments. - * - * Sets the command line arguments to be passed through to the Dart - * entrypoint function. - */ -void fl_dart_project_set_dart_entrypoint_arguments(FlDartProject* project, - char** argv); - -/** - * fl_dart_project_get_dart_entrypoint_arguments: - * @project: an #FlDartProject. - * - * Gets the command line arguments to be passed through to the Dart entrypoint - * function. - * - * Returns: a NULL-terminated array of strings containing the command line - * arguments to be passed to the Dart entrypoint. - */ -gchar** fl_dart_project_get_dart_entrypoint_arguments(FlDartProject* project); - -G_END_DECLS - -#endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_DART_PROJECT_H_ diff --git a/packages/fl_query/example/linux/flutter/ephemeral/flutter_linux/fl_engine.h b/packages/fl_query/example/linux/flutter/ephemeral/flutter_linux/fl_engine.h deleted file mode 100644 index 6740c0b..0000000 --- a/packages/fl_query/example/linux/flutter/ephemeral/flutter_linux/fl_engine.h +++ /dev/null @@ -1,60 +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. - -#ifndef FLUTTER_SHELL_PLATFORM_LINUX_FL_ENGINE_H_ -#define FLUTTER_SHELL_PLATFORM_LINUX_FL_ENGINE_H_ - -#if !defined(__FLUTTER_LINUX_INSIDE__) && !defined(FLUTTER_LINUX_COMPILATION) -#error "Only can be included directly." -#endif - -#include - -#include "fl_binary_messenger.h" -#include "fl_dart_project.h" -#include "fl_texture_registrar.h" - -G_BEGIN_DECLS - -G_DECLARE_FINAL_TYPE(FlEngine, fl_engine, FL, ENGINE, GObject) - -/** - * FlEngine: - * - * #FlEngine is an object that contains a running Flutter engine. - */ - -/** - * fl_engine_new_headless: - * @project: an #FlDartProject. - * - * Creates new Flutter engine running in headless mode. - * - * Returns: a new #FlEngine. - */ -FlEngine* fl_engine_new_headless(FlDartProject* project); - -/** - * fl_engine_get_binary_messenger: - * @engine: an #FlEngine. - * - * Gets the messenger to communicate with this engine. - * - * Returns: an #FlBinaryMessenger. - */ -FlBinaryMessenger* fl_engine_get_binary_messenger(FlEngine* engine); - -/** - * fl_engine_get_texture_registrar: - * @engine: an #FlEngine. - * - * Gets the texture registrar for registering textures. - * - * Returns: an #FlTextureRegistrar. - */ -FlTextureRegistrar* fl_engine_get_texture_registrar(FlEngine* engine); - -G_END_DECLS - -#endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_ENGINE_H_ diff --git a/packages/fl_query/example/linux/flutter/ephemeral/flutter_linux/fl_event_channel.h b/packages/fl_query/example/linux/flutter/ephemeral/flutter_linux/fl_event_channel.h deleted file mode 100644 index 7141def..0000000 --- a/packages/fl_query/example/linux/flutter/ephemeral/flutter_linux/fl_event_channel.h +++ /dev/null @@ -1,187 +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. - -#ifndef FLUTTER_SHELL_PLATFORM_LINUX_FL_EVENT_CHANNEL_H_ -#define FLUTTER_SHELL_PLATFORM_LINUX_FL_EVENT_CHANNEL_H_ - -#if !defined(__FLUTTER_LINUX_INSIDE__) && !defined(FLUTTER_LINUX_COMPILATION) -#error "Only can be included directly." -#endif - -#include -#include - -#include "fl_binary_messenger.h" -#include "fl_method_channel.h" -#include "fl_method_response.h" - -G_BEGIN_DECLS - -G_DECLARE_FINAL_TYPE(FlEventChannel, - fl_event_channel, - FL, - EVENT_CHANNEL, - GObject) - -/** - * FlEventChannel: - * - * #FlEventChannel is an object that allows sending - * an events stream to Dart code over platform channels. - * - * The following example shows how to send events on a channel: - * - * |[ - * static FlEventChannel *channel = NULL; - * static gboolean send_events = FALSE; - * - * static void event_occurs_cb (FooEvent *event) { - * if (send_events) { - * g_autoptr(FlValue) message = foo_event_to_value (event); - * g_autoptr(GError) error = NULL; - * if (!fl_event_channel_send (channel, message, NULL, &error)) { - * g_warning ("Failed to send event: %s", error->message); - * } - * } - * } - * - * static FlMethodErrorResponse* listen_cb (FlEventChannel* channel, - * FlValue *args, - * gpointer user_data) { - * send_events = TRUE; - * return NULL; - * } - * - * static FlMethodErrorResponse* cancel_cb (GObject *object, - * FlValue *args, - * gpointer user_data) { - * send_events = FALSE; - * return NULL; - * } - * - * static void setup_channel () { - * g_autoptr(FlStandardMethodCodec) codec = fl_standard_method_codec_new (); - * channel = fl_event_channel_new (messenger, "flutter/foo", - * FL_METHOD_CODEC (codec)); - * fl_event_channel_set_stream_handlers (channel, listen_cb, cancel_cb, - * NULL, NULL); - * } - * ]| - * - * #FlEventChannel matches the EventChannel class in the Flutter - * services library. - */ - -/** - * FlEventChannelHandler: - * @channel: an #FlEventChannel. - * @args: arguments passed from the Dart end of the channel. - * @user_data: (closure): data provided when registering this handler. - * - * Function called when the stream is listened to or cancelled. - * - * Returns: (transfer full): an #FlMethodErrorResponse or %NULL if no error. - */ -typedef FlMethodErrorResponse* (*FlEventChannelHandler)(FlEventChannel* channel, - FlValue* args, - gpointer user_data); - -/** - * fl_event_channel_new: - * @messenger: an #FlBinaryMessenger. - * @name: a channel name. - * @codec: the message codec. - * - * Creates an event channel. @codec must match the codec used on the Dart - * end of the channel. - * - * Returns: a new #FlEventChannel. - */ -FlEventChannel* fl_event_channel_new(FlBinaryMessenger* messenger, - const gchar* name, - FlMethodCodec* codec); - -/** - * fl_event_channel_set_stream_handlers: - * @channel: an #FlEventChannel. - * @listen_handler: (allow-none): function to call when the Dart side of the - * channel starts listening to the stream. - * @cancel_handler: (allow-none): function to call when the Dart side of the - * channel cancels their subscription to the stream. - * @user_data: (closure): user data to pass to @listen_handler and - * @cancel_handler. - * @destroy_notify: (allow-none): a function which gets called to free - * @user_data, or %NULL. - * - * Sets the functions called when the Dart side requests the stream to start and - * finish. - * - * The handlers are removed if the channel is closed or is replaced by another - * handler, set @destroy_notify if you want to detect this. - */ -void fl_event_channel_set_stream_handlers(FlEventChannel* channel, - FlEventChannelHandler listen_handler, - FlEventChannelHandler cancel_handler, - gpointer user_data, - GDestroyNotify destroy_notify); - -/** - * fl_event_channel_send: - * @channel: an #FlEventChannel. - * @event: event to send, must match what the #FlMethodCodec supports. - * @cancellable: (allow-none): a #GCancellable or %NULL. - * @error: (allow-none): #GError location to store the error occurring, or %NULL - * to ignore. - * - * Sends an event on the channel. - * Events should only be sent once the channel is being listened to. - * - * Returns: %TRUE if successful. - */ -gboolean fl_event_channel_send(FlEventChannel* channel, - FlValue* event, - GCancellable* cancellable, - GError** error); - -/** - * fl_event_channel_send_error: - * @channel: an #FlEventChannel. - * @code: error code to send. - * @message: error message to send. - * @details: (allow-none): error details or %NULL. - * @cancellable: (allow-none): a #GCancellable or %NULL. - * @error: (allow-none): #GError location to store the error occurring, or %NULL - * to ignore. - * - * Sends an error on the channel. - * Errors should only be sent once the channel is being listened to. - * - * Returns: %TRUE if successful. - */ -gboolean fl_event_channel_send_error(FlEventChannel* channel, - const gchar* code, - const gchar* message, - FlValue* details, - GCancellable* cancellable, - GError** error); - -/** - * fl_event_channel_send_end_of_stream: - * @channel: an #FlEventChannel. - * @cancellable: (allow-none): a #GCancellable or %NULL. - * @error: (allow-none): #GError location to store the error occurring, or %NULL - * to ignore. - * - * Indicates the stream has completed. - * It is a programmer error to send any more events after calling this. - * - * Returns: %TRUE if successful. - */ -gboolean fl_event_channel_send_end_of_stream(FlEventChannel* channel, - GCancellable* cancellable, - GError** error); - -G_END_DECLS - -#endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_EVENT_CHANNEL_H_ diff --git a/packages/fl_query/example/linux/flutter/ephemeral/flutter_linux/fl_json_message_codec.h b/packages/fl_query/example/linux/flutter/ephemeral/flutter_linux/fl_json_message_codec.h deleted file mode 100644 index ddf6818..0000000 --- a/packages/fl_query/example/linux/flutter/ephemeral/flutter_linux/fl_json_message_codec.h +++ /dev/null @@ -1,96 +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. - -#ifndef FLUTTER_SHELL_PLATFORM_LINUX_FL_JSON_MESSAGE_CODEC_H_ -#define FLUTTER_SHELL_PLATFORM_LINUX_FL_JSON_MESSAGE_CODEC_H_ - -#if !defined(__FLUTTER_LINUX_INSIDE__) && !defined(FLUTTER_LINUX_COMPILATION) -#error "Only can be included directly." -#endif - -#include "fl_message_codec.h" - -G_BEGIN_DECLS - -/** - * FlJsonMessageCodecError: - * @FL_JSON_MESSAGE_CODEC_ERROR_INVALID_UTF8: Message is not valid UTF-8. - * @FL_JSON_MESSAGE_CODEC_ERROR_INVALID_JSON: Message is not valid JSON. - * @FL_JSON_MESSAGE_CODEC_ERROR_INVALID_OBJECT_KEY_TYPE: Invalid object key - * type. - * - * Errors for #FlJsonMessageCodec objects to set on failures. - */ -#define FL_JSON_MESSAGE_CODEC_ERROR fl_json_message_codec_error_quark() - -typedef enum { - FL_JSON_MESSAGE_CODEC_ERROR_INVALID_UTF8, - FL_JSON_MESSAGE_CODEC_ERROR_INVALID_JSON, - FL_JSON_MESSAGE_CODEC_ERROR_INVALID_OBJECT_KEY_TYPE, -} FlJsonMessageCodecError; - -GQuark fl_json_message_codec_error_quark(void) G_GNUC_CONST; - -G_DECLARE_FINAL_TYPE(FlJsonMessageCodec, - fl_json_message_codec, - FL, - JSON_CODEC, - FlMessageCodec) - -/** - * FlJsonMessageCodec: - * - * #FlJsonMessageCodec is an #FlMessageCodec that implements the encodes - * #FlValue to/from JSON. This codec encodes and decodes #FlValue of type - * #FL_VALUE_TYPE_NULL, #FL_VALUE_TYPE_BOOL, #FL_VALUE_TYPE_INT, - * #FL_VALUE_TYPE_FLOAT, #FL_VALUE_TYPE_STRING, #FL_VALUE_TYPE_UINT8_LIST, - * #FL_VALUE_TYPE_INT32_LIST, #FL_VALUE_TYPE_INT64_LIST, - * #FL_VALUE_TYPE_FLOAT_LIST, #FL_VALUE_TYPE_LIST, and #FL_VALUE_TYPE_MAP. - * - * #FlJsonMessageCodec matches the JSONMessageCodec class in the Flutter - * services library. - */ - -/** - * fl_json_message_codec_new: - * - * Creates an #FlJsonMessageCodec. - * - * Returns: a new #FlJsonMessageCodec. - */ -FlJsonMessageCodec* fl_json_message_codec_new(); - -/** - * fl_json_message_codec_encode: - * @codec: an #FlJsonMessageCodec. - * @value: value to encode. - * @error: (allow-none): #GError location to store the error occurring, or - * %NULL. - * - * Encodes a value to a JSON string. - * - * Returns: a JSON representation of this value or %NULL on error. - */ -gchar* fl_json_message_codec_encode(FlJsonMessageCodec* codec, - FlValue* value, - GError** error); - -/** - * fl_json_message_codec_decode: - * @codec: an #FlJsonMessageCodec. - * @text: UTF-8 text in JSON format. - * @error: (allow-none): #GError location to store the error occurring, or - * %NULL. - * - * Decodes a value from a JSON string. - * - * Returns: an #FlValue or %NULL on error. - */ -FlValue* fl_json_message_codec_decode(FlJsonMessageCodec* codec, - const gchar* text, - GError** error); - -G_END_DECLS - -#endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_JSON_MESSAGE_CODEC_H_ diff --git a/packages/fl_query/example/linux/flutter/ephemeral/flutter_linux/fl_json_method_codec.h b/packages/fl_query/example/linux/flutter/ephemeral/flutter_linux/fl_json_method_codec.h deleted file mode 100644 index 70ddf79..0000000 --- a/packages/fl_query/example/linux/flutter/ephemeral/flutter_linux/fl_json_method_codec.h +++ /dev/null @@ -1,44 +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. - -#ifndef FLUTTER_SHELL_PLATFORM_LINUX_FL_JSON_METHOD_CODEC_H_ -#define FLUTTER_SHELL_PLATFORM_LINUX_FL_JSON_METHOD_CODEC_H_ - -#if !defined(__FLUTTER_LINUX_INSIDE__) && !defined(FLUTTER_LINUX_COMPILATION) -#error "Only can be included directly." -#endif - -#include "fl_method_codec.h" - -G_BEGIN_DECLS - -G_DECLARE_FINAL_TYPE(FlJsonMethodCodec, - fl_json_method_codec, - FL, - JSON_METHOD_CODEC, - FlMethodCodec) - -/** - * FlJsonMethodCodec: - * - * #FlJsonMessageCodec is an #FlMethodCodec that implements method calls using - * the Flutter JSON message encoding. It should be used with an - * #FlMethodChannel. - * - * #FlJsonMethodCodec matches the JSONMethodCodec class in the Flutter services - * library. - */ - -/** - * fl_json_method_codec_new: - * - * Creates an #FlJsonMethodCodec. - * - * Returns: a new #FlJsonMethodCodec. - */ -FlJsonMethodCodec* fl_json_method_codec_new(); - -G_END_DECLS - -#endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_JSON_METHOD_CODEC_H_ diff --git a/packages/fl_query/example/linux/flutter/ephemeral/flutter_linux/fl_message_codec.h b/packages/fl_query/example/linux/flutter/ephemeral/flutter_linux/fl_message_codec.h deleted file mode 100644 index b74aad2..0000000 --- a/packages/fl_query/example/linux/flutter/ephemeral/flutter_linux/fl_message_codec.h +++ /dev/null @@ -1,129 +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. - -#ifndef FLUTTER_SHELL_PLATFORM_LINUX_FL_MESSAGE_CODEC_H_ -#define FLUTTER_SHELL_PLATFORM_LINUX_FL_MESSAGE_CODEC_H_ - -#if !defined(__FLUTTER_LINUX_INSIDE__) && !defined(FLUTTER_LINUX_COMPILATION) -#error "Only can be included directly." -#endif - -#include - -#include "fl_value.h" - -G_BEGIN_DECLS - -/** - * FlMessageCodecError: - * @FL_MESSAGE_CODEC_ERROR_FAILED: Codec failed due to an unspecified error. - * @FL_MESSAGE_CODEC_ERROR_OUT_OF_DATA: Codec ran out of data reading a value. - * @FL_MESSAGE_CODEC_ERROR_ADDITIONAL_DATA: Additional data encountered in - * message. - * @FL_MESSAGE_CODEC_ERROR_UNSUPPORTED_TYPE: Codec encountered an unsupported - * #FlValue. - * - * Errors for #FlMessageCodec objects to set on failures. - */ -#define FL_MESSAGE_CODEC_ERROR fl_message_codec_error_quark() - -typedef enum { - FL_MESSAGE_CODEC_ERROR_FAILED, - FL_MESSAGE_CODEC_ERROR_OUT_OF_DATA, - FL_MESSAGE_CODEC_ERROR_ADDITIONAL_DATA, - FL_MESSAGE_CODEC_ERROR_UNSUPPORTED_TYPE, -} FlMessageCodecError; - -GQuark fl_message_codec_error_quark(void) G_GNUC_CONST; - -G_DECLARE_DERIVABLE_TYPE(FlMessageCodec, - fl_message_codec, - FL, - MESSAGE_CODEC, - GObject) - -/** - * FlMessageCodec: - * - * #FlMessageCodec is a message encoding/decoding mechanism that operates on - * #FlValue objects. Both operations returns errors if the conversion fails. - * Such situations should be treated as programming errors. - * - * #FlMessageCodec matches the MethodCodec class in the Flutter services - * library. - */ - -struct _FlMessageCodecClass { - GObjectClass parent_class; - - /** - * FlMessageCodec::encode_message: - * @codec: A #FlMessageCodec. - * @message: message to encode or %NULL to encode the null value. - * @error: (allow-none): #GError location to store the error occurring, or - * %NULL. - * - * Virtual method to encode a message. A subclass must implement this method. - * If the subclass cannot handle the type of @message then it must generate a - * FL_MESSAGE_CODEC_ERROR_UNSUPPORTED_TYPE error. - * - * Returns: a binary message or %NULL on error. - */ - GBytes* (*encode_message)(FlMessageCodec* codec, - FlValue* message, - GError** error); - - /** - * FlMessageCodec::decode_message: - * @codec: an #FlMessageCodec. - * @message: binary message to decode. - * @error: (allow-none): #GError location to store the error occurring, or - * %NULL. - * - * Virtual method to decode a message. A subclass must implement this method. - * If @message is too small then a #FL_MESSAGE_CODEC_ERROR_OUT_OF_DATA error - * must be generated. If @message is too large then a - * #FL_MESSAGE_CODEC_ERROR_ADDITIONAL_DATA error must be generated. - * - * Returns: an #FlValue or %NULL on error. - */ - FlValue* (*decode_message)(FlMessageCodec* codec, - GBytes* message, - GError** error); -}; - -/** - * fl_message_codec_encode_message: - * @codec: an #FlMessageCodec. - * @buffer: buffer to write to. - * @message: message to encode or %NULL to encode the null value. - * @error: (allow-none): #GError location to store the error occurring, or - * %NULL. - * - * Encodes a message into a binary representation. - * - * Returns: a binary encoded message or %NULL on error. - */ -GBytes* fl_message_codec_encode_message(FlMessageCodec* codec, - FlValue* message, - GError** error); - -/** - * fl_message_codec_decode_message: - * @codec: an #FlMessageCodec. - * @message: binary message to decode. - * @error: (allow-none): #GError location to store the error occurring, or - * %NULL. - * - * Decodes a message from a binary encoding. - * - * Returns: an #FlValue or %NULL on error. - */ -FlValue* fl_message_codec_decode_message(FlMessageCodec* codec, - GBytes* message, - GError** error); - -G_END_DECLS - -#endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_MESSAGE_CODEC_H_ diff --git a/packages/fl_query/example/linux/flutter/ephemeral/flutter_linux/fl_method_call.h b/packages/fl_query/example/linux/flutter/ephemeral/flutter_linux/fl_method_call.h deleted file mode 100644 index 5a5ebc7..0000000 --- a/packages/fl_query/example/linux/flutter/ephemeral/flutter_linux/fl_method_call.h +++ /dev/null @@ -1,115 +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. - -#ifndef FLUTTER_SHELL_PLATFORM_LINUX_FL_METHOD_CALL_H_ -#define FLUTTER_SHELL_PLATFORM_LINUX_FL_METHOD_CALL_H_ - -#if !defined(__FLUTTER_LINUX_INSIDE__) && !defined(FLUTTER_LINUX_COMPILATION) -#error "Only can be included directly." -#endif - -#include - -#include "fl_method_response.h" -#include "fl_value.h" - -G_BEGIN_DECLS - -G_DECLARE_FINAL_TYPE(FlMethodCall, fl_method_call, FL, METHOD_CALL, GObject) - -/** - * FlMethodCall: - * - * #FlMethodCall represents and incoming method call as returned by an - * #FlMethodChannel. - */ - -/** - * fl_method_call_get_name: - * @method_call: an #FlMethodCall. - * - * Gets the name of the method call. - * - * Returns: a method name. - */ -const gchar* fl_method_call_get_name(FlMethodCall* method_call); - -/** - * fl_method_call_get_args: - * @method_call: an #FlMethodCall. - * - * Gets the arguments passed to the method. - * - * Returns: an #FlValue. - */ -FlValue* fl_method_call_get_args(FlMethodCall* method_call); - -/** - * fl_method_call_respond: - * @method_call: an #FlMethodCall. - * @response: an #FlMethodResponse. - * @error: (allow-none): #GError location to store the error occurring, or %NULL - * to ignore. - * - * Responds to a method call. - * - * Returns: %TRUE on success. - */ -gboolean fl_method_call_respond(FlMethodCall* method_call, - FlMethodResponse* response, - GError** error); - -/** - * fl_method_call_respond_success: - * @method_call: an #FlMethodCall. - * @result: (allow-none): value to respond with, must match what the - * #FlMethodCodec supports. - * @error: (allow-none): #GError location to store the error occurring, or %NULL - * to ignore. - * - * Convenience method that responds to method call with - * #FlMethodSuccessResponse. - * - * Returns: %TRUE on success. - */ -gboolean fl_method_call_respond_success(FlMethodCall* method_call, - FlValue* result, - GError** error); - -/** - * fl_method_call_respond_error: - * @method_call: an #FlMethodCall. - * @code: error code. - * @message: (allow-none): error message. - * @details: (allow-none): details for the error. - * @error: (allow-none): #GError location to store the error occurring, or %NULL - * to ignore. - * - * Convenience method that responds to method call with #FlMethodErrorResponse. - * - * Returns: %TRUE on success. - */ -gboolean fl_method_call_respond_error(FlMethodCall* method_call, - const gchar* code, - const gchar* message, - FlValue* details, - GError** error); - -/** - * fl_method_call_respond_not_implemented: - * @method_call: an #FlMethodCall. - * @error: (allow-none): #GError location to store the error occurring, or %NULL - * to ignore. - * - * Convenience method that responds to method call with - * #FlMethodNotImplementedResponse. - * - * Returns: %TRUE on success. - */ -gboolean fl_method_call_respond_not_implemented(FlMethodCall* method_call, - GError** error); - -G_END_DECLS - -#endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_METHOD_CALL_H_ diff --git a/packages/fl_query/example/linux/flutter/ephemeral/flutter_linux/fl_method_channel.h b/packages/fl_query/example/linux/flutter/ephemeral/flutter_linux/fl_method_channel.h deleted file mode 100644 index f4102ed..0000000 --- a/packages/fl_query/example/linux/flutter/ephemeral/flutter_linux/fl_method_channel.h +++ /dev/null @@ -1,190 +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. - -#ifndef FLUTTER_SHELL_PLATFORM_LINUX_FL_METHOD_CHANNEL_H_ -#define FLUTTER_SHELL_PLATFORM_LINUX_FL_METHOD_CHANNEL_H_ - -#if !defined(__FLUTTER_LINUX_INSIDE__) && !defined(FLUTTER_LINUX_COMPILATION) -#error "Only can be included directly." -#endif - -#include -#include - -#include "fl_binary_messenger.h" -#include "fl_method_call.h" -#include "fl_method_codec.h" -#include "fl_method_response.h" - -G_BEGIN_DECLS - -G_DECLARE_FINAL_TYPE(FlMethodChannel, - fl_method_channel, - FL, - METHOD_CHANNEL, - GObject) - -/** - * FlMethodChannel: - * - * #FlMethodChannel is an object that allows method calls to and from Dart code. - * - * The following example shows how to call and handle methods on a channel. - * See #FlMethodResponse for how to handle errors in more detail. - * - * |[ - * static FlMethodChannel *channel = NULL; - * - * static void method_call_cb (FlMethodChannel* channel, - * FlMethodCall* method_call, - * gpointer user_data) { - * g_autoptr(FlMethodResponse) response = NULL; - * if (strcmp (fl_method_call_get_name (method_call), "Foo.bar") == 0) { - * g_autoptr(GError) bar_error = NULL; - * g_autoptr(FlValue) result = - * do_bar (fl_method_call_get_args (method_call), &bar_error); - * if (result == NULL) - * response = - * FL_METHOD_RESPONSE (fl_method_error_response_new ("bar error", - * bar_error->message)); - * else - * response = FL_METHOD_RESPONSE (fl_method_success_response_new - * (result)); } else response = FL_METHOD_RESPONSE - * (fl_method_not_implemented_response_new ()); - * - * g_autoptr(GError) error = NULL; - * if (!fl_method_call_respond(method_call, response)) - * g_warning ("Failed to send response: %s", error->message); - * } - * - * static void method_response_cb(GObject *object, - * GAsyncResult *result, - * gpointer user_data) { - * g_autoptr(GError) error = NULL; - * g_autoptr(FlMethodResponse) response = - * fl_method_channel_invoke_method_finish (FL_METHOD_CODEC (object), result, - * &error); - * if (response == NULL) { - * g_warning ("Failed to call method: %s", error->message); - * return; - * } - * - * g_autoptr(FlValue) value = - * fl_method_response_get_result (response, &error); - * if (response == NULL) { - * g_warning ("Method returned error: %s", error->message); - * return; - * } - * - * use_result (value); - * } - * - * static void call_method () { - * g_autoptr(FlStandardMethodCodec) codec = fl_standard_method_codec_new (); - * channel = - * fl_method_channel_new(messenger, "flutter/foo", FL_METHOD_CODEC (codec)); - * fl_method_channel_set_method_call_handler (channel, method_call_cb, NULL, - * NULL); - * - * g_autoptr(FlValue) args = fl_value_new_string ("Hello World"); - * fl_method_channel_invoke_method (channel, "Foo.foo", args, - * cancellable, method_response_cb, NULL); - * } - * ]| - * - * #FlMethodChannel matches the MethodChannel class in the Flutter services - * library. - */ - -/** - * FlMethodChannelMethodCallHandler: - * @channel: an #FlMethodChannel. - * @method_call: an #FlMethodCall. - * @user_data: (closure): data provided when registering this handler. - * - * Function called when a method call is received. Respond to the method call - * with fl_method_call_respond(). If the response is not occurring in this - * callback take a reference to @method_call and release that once it has been - * responded to. Failing to respond before the last reference to @method_call is - * dropped is a programming error. - */ -typedef void (*FlMethodChannelMethodCallHandler)(FlMethodChannel* channel, - FlMethodCall* method_call, - gpointer user_data); - -/** - * fl_method_channel_new: - * @messenger: an #FlBinaryMessenger. - * @name: a channel name. - * @codec: the method codec. - * - * Creates a new method channel. @codec must match the codec used on the Dart - * end of the channel. - * - * Returns: a new #FlMethodChannel. - */ -FlMethodChannel* fl_method_channel_new(FlBinaryMessenger* messenger, - const gchar* name, - FlMethodCodec* codec); - -/** - * fl_method_channel_set_method_call_handler: - * @channel: an #FlMethodChannel. - * @handler: function to call when a method call is received on this channel. - * @user_data: (closure): user data to pass to @handler. - * @destroy_notify: (allow-none): a function which gets called to free - * @user_data, or %NULL. - * - * Sets the function called when a method call is received from the Dart side of - * the channel. See #FlMethodChannelMethodCallHandler for details on how to - * respond to method calls. - * - * The handler is removed if the channel is closed or is replaced by another - * handler, set @destroy_notify if you want to detect this. - */ -void fl_method_channel_set_method_call_handler( - FlMethodChannel* channel, - FlMethodChannelMethodCallHandler handler, - gpointer user_data, - GDestroyNotify destroy_notify); - -/** - * fl_method_channel_invoke_method: - * @channel: an #FlMethodChannel. - * @method: the method to call. - * @args: (allow-none): arguments to the method, must match what the - * #FlMethodCodec supports. - * @cancellable: (allow-none): a #GCancellable or %NULL. - * @callback: (scope async): (allow-none): a #GAsyncReadyCallback to call when - * the request is satisfied or %NULL to ignore the response. - * @user_data: (closure): user data to pass to @callback. - * - * Calls a method on this channel. - */ -void fl_method_channel_invoke_method(FlMethodChannel* channel, - const gchar* method, - FlValue* args, - GCancellable* cancellable, - GAsyncReadyCallback callback, - gpointer user_data); - -/** - * fl_method_channel_invoke_method_finish: - * @channel: an #FlMethodChannel. - * @result: #GAsyncResult. - * @error: (allow-none): #GError location to store the error occurring, or %NULL - * to ignore. - * - * Completes request started with fl_method_channel_invoke_method(). - * - * Returns: (transfer full): an #FlMethodResponse or %NULL on error. - */ -FlMethodResponse* fl_method_channel_invoke_method_finish( - FlMethodChannel* channel, - GAsyncResult* result, - GError** error); - -G_END_DECLS - -#endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_METHOD_CHANNEL_H_ diff --git a/packages/fl_query/example/linux/flutter/ephemeral/flutter_linux/fl_method_codec.h b/packages/fl_query/example/linux/flutter/ephemeral/flutter_linux/fl_method_codec.h deleted file mode 100644 index 97bf8e9..0000000 --- a/packages/fl_query/example/linux/flutter/ephemeral/flutter_linux/fl_method_codec.h +++ /dev/null @@ -1,131 +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. - -#ifndef FLUTTER_SHELL_PLATFORM_LINUX_FL_METHOD_CODEC_H_ -#define FLUTTER_SHELL_PLATFORM_LINUX_FL_METHOD_CODEC_H_ - -#if !defined(__FLUTTER_LINUX_INSIDE__) && !defined(FLUTTER_LINUX_COMPILATION) -#error "Only can be included directly." -#endif - -#include - -#include "fl_method_response.h" -#include "fl_value.h" - -G_BEGIN_DECLS - -G_DECLARE_DERIVABLE_TYPE(FlMethodCodec, - fl_method_codec, - FL, - METHOD_CODEC, - GObject) - -/** - * FlMethodCodec: - * - * #FlMethodCodec is an abstract class that encodes and decodes method calls on - * a platform channel. Override this class to implement an encoding. - * - * #FlMethodCodec matches the MethodCodec class in the Flutter services - * library. - */ - -struct _FlMethodCodecClass { - GObjectClass parent_class; - - /** - * FlMethodCodec::encode_method_call: - * @codec: an #FlMethodCodec. - * @name: method name. - * @args: (allow-none): method arguments, or %NULL. - * @error: (allow-none): #GError location to store the error occurring, or - * %NULL. - * - * Encodes a method call. - * - * Returns: (transfer full): a binary encoding of this method call or %NULL if - * not able to encode. - */ - GBytes* (*encode_method_call)(FlMethodCodec* codec, - const gchar* name, - FlValue* args, - GError** error); - - /** - * FlMethodCodec::decode_method_call: - * @codec: an #FlMethodCodec - * @message: message to decode. - * @name: (transfer full): location to write method name or %NULL if not - * required - * @args: (transfer full): location to write method arguments, or %NULL if not - * required - * @error: (allow-none): #GError location to store the error occurring, or - * %NULL - * - * Decodes a method call. - * - * Returns: %TRUE if successfully decoded. - */ - gboolean (*decode_method_call)(FlMethodCodec* codec, - GBytes* message, - gchar** name, - FlValue** args, - GError** error); - - /** - * FlMethodCodec::encode_success_envelope: - * @codec: an #FlMethodCodec. - * @result: (allow-none): method result, or %NULL. - * @error: (allow-none): #GError location to store the error occurring, or - * %NULL. - * - * Encodes a successful response to a method call. - * - * Returns: (transfer full): a binary encoding of this response or %NULL if - * not able to encode. - */ - GBytes* (*encode_success_envelope)(FlMethodCodec* codec, - FlValue* result, - GError** error); - - /** - * FlMethodCodec::encode_error_envelope: - * @codec: an #FlMethodCodec. - * @code: an error code. - * @message: (allow-none): an error message, or %NULL. - * @details: (allow-none): error details, or %NULL. - * @error: (allow-none): #GError location to store the error occurring, or - * %NULL. - * - * Encodes an error response to a method call. - * - * Returns: (transfer full): a binary encoding of this response or %NULL if - * not able to encode. - */ - GBytes* (*encode_error_envelope)(FlMethodCodec* codec, - const gchar* code, - const gchar* message, - FlValue* details, - GError** error); - - /** - * FlMethodCodec::decode_response: - * @codec: an #FlMethodCodec. - * @message: message to decode. - * @error: (allow-none): #GError location to store the error occurring, or - * %NULL. - * - * Decodes a response to a method call. - * - * Returns: a new #FlMethodResponse or %NULL on error. - */ - FlMethodResponse* (*decode_response)(FlMethodCodec* codec, - GBytes* message, - GError** error); -}; - -G_END_DECLS - -#endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_METHOD_CODEC_H_ diff --git a/packages/fl_query/example/linux/flutter/ephemeral/flutter_linux/fl_method_response.h b/packages/fl_query/example/linux/flutter/ephemeral/flutter_linux/fl_method_response.h deleted file mode 100644 index 90c4b9c..0000000 --- a/packages/fl_query/example/linux/flutter/ephemeral/flutter_linux/fl_method_response.h +++ /dev/null @@ -1,212 +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. - -#ifndef FLUTTER_SHELL_PLATFORM_LINUX_FL_METHOD_RESPONSE_H_ -#define FLUTTER_SHELL_PLATFORM_LINUX_FL_METHOD_RESPONSE_H_ - -#if !defined(__FLUTTER_LINUX_INSIDE__) && !defined(FLUTTER_LINUX_COMPILATION) -#error "Only can be included directly." -#endif - -#include - -#include "fl_value.h" - -G_BEGIN_DECLS - -/** - * FlMethodResponseError: - * @FL_METHOD_RESPONSE_ERROR_FAILED: Call failed due to an unspecified error. - * @FL_METHOD_RESPONSE_ERROR_REMOTE_ERROR: An error was returned by the other - * side of the channel. - * @FL_METHOD_RESPONSE_ERROR_NOT_IMPLEMENTED: The requested method is not - * implemented. - * - * Errors set by `fl_method_response_get_result` when the method call response - * is not #FlMethodSuccessResponse. - */ -#define FL_METHOD_RESPONSE_ERROR fl_method_response_error_quark() - -typedef enum { - FL_METHOD_RESPONSE_ERROR_FAILED, - FL_METHOD_RESPONSE_ERROR_REMOTE_ERROR, - FL_METHOD_RESPONSE_ERROR_NOT_IMPLEMENTED, -} FlMethodResponseError; - -GQuark fl_method_response_error_quark(void) G_GNUC_CONST; - -G_DECLARE_DERIVABLE_TYPE(FlMethodResponse, - fl_method_response, - FL, - METHOD_RESPONSE, - GObject) - -struct _FlMethodResponseClass { - GObjectClass parent_class; -}; - -G_DECLARE_FINAL_TYPE(FlMethodSuccessResponse, - fl_method_success_response, - FL, - METHOD_SUCCESS_RESPONSE, - FlMethodResponse) - -G_DECLARE_FINAL_TYPE(FlMethodErrorResponse, - fl_method_error_response, - FL, - METHOD_ERROR_RESPONSE, - FlMethodResponse) - -G_DECLARE_FINAL_TYPE(FlMethodNotImplementedResponse, - fl_method_not_implemented_response, - FL, - METHOD_NOT_IMPLEMENTED_RESPONSE, - FlMethodResponse) - -/** - * FlMethodResponse: - * - * #FlMethodResponse contains the information returned when an #FlMethodChannel - * method call returns. If you expect the method call to be successful use - * fl_method_response_get_result(). If you want to handle error cases then you - * should use code like: - * - * |[ - * if (FL_IS_METHOD_SUCCESS_RESPONSE (response)) { - * FlValue *result = - * fl_method_success_response_get_result( - * FL_METHOD_SUCCESS_RESPONSE (response)); - * handle_result (result); - * } else if (FL_IS_METHOD_ERROR_RESPONSE (response)) { - * FlMethodErrorResponse *error_response = - * FL_METHOD_ERROR_RESPONSE (response); - * handle_error (fl_method_error_response_get_code (error_response), - * fl_method_error_response_get_message (error_response), - * fl_method_error_response_get_details (error_response)); - * } - * else if (FL_IS_METHOD_NOT_IMPLEMENTED_RESPONSE (response)) { - * handle_not_implemented (); - * } - * } - * ]| - */ - -/** - * FlMethodSuccessResponse: - * - * #FlMethodSuccessResponse is the #FlMethodResponse returned when a method call - * has successfully completed. The result of the method call is obtained using - * `fl_method_success_response_get_result`. - */ - -/** - * FlMethodErrorResponse: - * - * #FlMethodErrorResponse is the #FlMethodResponse returned when a method call - * results in an error. The error details are obtained using - * `fl_method_error_response_get_code`, `fl_method_error_response_get_message` - * and `fl_method_error_response_get_details`. - */ - -/** - * FlMethodNotImplementedResponse: - * - * #FlMethodNotImplementedResponse is the #FlMethodResponse returned when a - * method call is not implemented. - */ - -/** - * fl_method_response_get_result: - * @response: an #FlMethodResponse. - * @error: (allow-none): #GError location to store the error occurring, or %NULL - * to ignore. - * - * Gets the result of a method call, or an error if the response wasn't - * successful. - * - * Returns: an #FlValue or %NULL on error. - */ -FlValue* fl_method_response_get_result(FlMethodResponse* response, - GError** error); - -/** - * fl_method_success_response_new: - * @result: (allow-none): the #FlValue returned by the method call or %NULL. - * - * Creates a response to a method call when that method has successfully - * completed. - * - * Returns: a new #FlMethodResponse. - */ -FlMethodSuccessResponse* fl_method_success_response_new(FlValue* result); - -/** - * fl_method_success_response_get_result: - * @response: an #FlMethodSuccessResponse. - * - * Gets the result of the method call. - * - * Returns: an #FlValue. - */ -FlValue* fl_method_success_response_get_result( - FlMethodSuccessResponse* response); - -/** - * fl_method_error_response_new: - * @result: an #FlValue. - * @code: an error code. - * @message: (allow-none): an error message. - * @details: (allow-none): error details. - * - * Creates a response to a method call when that method has returned an error. - * - * Returns: a new #FlMethodErrorResponse. - */ -FlMethodErrorResponse* fl_method_error_response_new(const gchar* code, - const gchar* message, - FlValue* details); - -/** - * fl_method_error_response_get_code: - * @response: an #FlMethodErrorResponse. - * - * Gets the error code reported. - * - * Returns: an error code. - */ -const gchar* fl_method_error_response_get_code(FlMethodErrorResponse* response); - -/** - * fl_method_error_response_get_message: - * @response: an #FlMethodErrorResponse. - * - * Gets the error message reported. - * - * Returns: an error message or %NULL if no error message provided. - */ -const gchar* fl_method_error_response_get_message( - FlMethodErrorResponse* response); - -/** - * fl_method_error_response_get_details: - * @response: an #FlMethodErrorResponse. - * - * Gets the details provided with this error. - * - * Returns: an #FlValue or %NULL if no details provided. - */ -FlValue* fl_method_error_response_get_details(FlMethodErrorResponse* response); - -/** - * fl_method_not_implemented_response_new: - * - * Creates a response to a method call when that method does not exist. - * - * Returns: a new #FlMethodNotImplementedResponse. - */ -FlMethodNotImplementedResponse* fl_method_not_implemented_response_new(); - -G_END_DECLS - -#endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_METHOD_RESPONSE_H_ diff --git a/packages/fl_query/example/linux/flutter/ephemeral/flutter_linux/fl_pixel_buffer_texture.h b/packages/fl_query/example/linux/flutter/ephemeral/flutter_linux/fl_pixel_buffer_texture.h deleted file mode 100644 index adddd77..0000000 --- a/packages/fl_query/example/linux/flutter/ephemeral/flutter_linux/fl_pixel_buffer_texture.h +++ /dev/null @@ -1,107 +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. - -#ifndef FLUTTER_SHELL_PLATFORM_LINUX_FL_PIXEL_BUFFER_TEXTURE_H_ -#define FLUTTER_SHELL_PLATFORM_LINUX_FL_PIXEL_BUFFER_TEXTURE_H_ - -#if !defined(__FLUTTER_LINUX_INSIDE__) && !defined(FLUTTER_LINUX_COMPILATION) -#error "Only can be included directly." -#endif - -#include "fl_texture.h" - -G_BEGIN_DECLS - -G_DECLARE_DERIVABLE_TYPE(FlPixelBufferTexture, - fl_pixel_buffer_texture, - FL, - PIXEL_BUFFER_TEXTURE, - GObject) - -/** - * FlPixelBufferTexture: - * - * #FlPixelBufferTexture represents an OpenGL texture generated from a pixel - * buffer. - * - * The following example shows how to implement an #FlPixelBufferTexture. - * ![ - * // Type definition, constructor, init, destructor and class_init are - * // omitted. - * struct _VideoPixelBufferTexture { // extends FlPixelBufferTexture - * FlPixelBufferTexture parent_instance; - * - * uint8_t *buffer; // your pixel buffer. - * } - * - * G_DEFINE_TYPE(VideoTexture, - * video_texture, - * fl_pixel_buffer_texture_get_type ()) - * - * static gboolean - * video_texture_copy_pixels (FlPixelBufferTexture* texture, - * const uint8_t** out_buffer, - * uint32_t* width, - * uint32_t* height, - * GError** error) { - * // This method is called on Render Thread. Be careful with your - * // cross-thread operation. - * - * // @width and @height are initially stored the canvas size in Flutter. - * - * // You must prepare your pixel buffer in RGBA format. - * // So you may do some format conversion first if your original pixel - * // buffer is not in RGBA format. - * manage_your_pixel_buffer_here (); - * - * if (your_operations_are_successfully_finished) { - * // Directly return pointer to your pixel buffer here. - * // Flutter takes content of your pixel buffer after this function - * // is finished. So you must make the buffer live long enough until - * // next tick of Render Thread. - * // If it is hard to manage lifetime of your pixel buffer, you should - * // take look into #FlTextureGL. - * - * *out_buffer = buffer; - * *width = real_width_of_buffer; - * *height = real_height_of_buffer; - * return TRUE; - * } else { - * // set @error to report failure. - * return FALSE; - * } - * } - * ]| - */ - -struct _FlPixelBufferTextureClass { - GObjectClass parent_class; - - /** - * FlPixelBufferTexture::copy_pixels: - * @texture: an #FlPixelBufferTexture. - * @buffer: (out): pixel data. - * @width: (inout): width of the texture in pixels. - * @height: (inout): height of the texture in pixels. - * @error: (allow-none): #GError location to store the error occurring, or - * %NULL to ignore. - * - * Retrieve pixel buffer in RGBA format. - * - * As this method is usually invoked from the render thread, you must - * take care of proper synchronization. It also needs to be ensured that - * the returned buffer is not released prior to unregistering this texture. - * - * Returns: %TRUE on success. - */ - gboolean (*copy_pixels)(FlPixelBufferTexture* texture, - const uint8_t** buffer, - uint32_t* width, - uint32_t* height, - GError** error); -}; - -G_END_DECLS - -#endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_PIXEL_BUFFER_TEXTURE_H_ diff --git a/packages/fl_query/example/linux/flutter/ephemeral/flutter_linux/fl_plugin_registrar.h b/packages/fl_query/example/linux/flutter/ephemeral/flutter_linux/fl_plugin_registrar.h deleted file mode 100644 index 6382804..0000000 --- a/packages/fl_query/example/linux/flutter/ephemeral/flutter_linux/fl_plugin_registrar.h +++ /dev/null @@ -1,76 +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. - -#ifndef FLUTTER_SHELL_PLATFORM_LINUX_FL_PLUGIN_REGISTRAR_H_ -#define FLUTTER_SHELL_PLATFORM_LINUX_FL_PLUGIN_REGISTRAR_H_ - -#if !defined(__FLUTTER_LINUX_INSIDE__) && !defined(FLUTTER_LINUX_COMPILATION) -#error "Only can be included directly." -#endif - -#include - -#include "fl_binary_messenger.h" -#include "fl_texture_registrar.h" -#include "fl_view.h" - -G_BEGIN_DECLS - -G_DECLARE_INTERFACE(FlPluginRegistrar, - fl_plugin_registrar, - FL, - PLUGIN_REGISTRAR, - GObject) - -struct _FlPluginRegistrarInterface { - GTypeInterface parent_iface; - - FlBinaryMessenger* (*get_messenger)(FlPluginRegistrar* registrar); - - FlTextureRegistrar* (*get_texture_registrar)(FlPluginRegistrar* registrar); - - FlView* (*get_view)(FlPluginRegistrar* registrar); -}; - -/** - * FlPluginRegistrar: - * - * #FlPluginRegistrar is used when registering new plugins. - */ - -/** - * fl_plugin_registrar_get_messenger: - * @registrar: an #FlPluginRegistrar. - * - * Gets the messenger this plugin can communicate with. - * - * Returns: an #FlBinaryMessenger. - */ -FlBinaryMessenger* fl_plugin_registrar_get_messenger( - FlPluginRegistrar* registrar); - -/** - * fl_plugin_registrar_get_texture_registrar: - * @registrar: an #FlPluginRegistrar. - * - * Gets the texture registrar this plugin can communicate with. - * - * Returns: an #FlTextureRegistrar. - */ -FlTextureRegistrar* fl_plugin_registrar_get_texture_registrar( - FlPluginRegistrar* registrar); - -/** - * fl_plugin_registrar_get_view: - * @registrar: an #FlPluginRegistrar. - * - * Get the view that Flutter is rendering with. - * - * Returns: (allow-none): an #FlView or %NULL if running in headless mode. - */ -FlView* fl_plugin_registrar_get_view(FlPluginRegistrar* registrar); - -G_END_DECLS - -#endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_PLUGIN_REGISTRAR_H_ diff --git a/packages/fl_query/example/linux/flutter/ephemeral/flutter_linux/fl_plugin_registry.h b/packages/fl_query/example/linux/flutter/ephemeral/flutter_linux/fl_plugin_registry.h deleted file mode 100644 index ac16aba..0000000 --- a/packages/fl_query/example/linux/flutter/ephemeral/flutter_linux/fl_plugin_registry.h +++ /dev/null @@ -1,61 +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. - -#ifndef FLUTTER_SHELL_PLATFORM_LINUX_FL_PLUGIN_REGISTRY_H_ -#define FLUTTER_SHELL_PLATFORM_LINUX_FL_PLUGIN_REGISTRY_H_ - -#if !defined(__FLUTTER_LINUX_INSIDE__) && !defined(FLUTTER_LINUX_COMPILATION) -#error "Only can be included directly." -#endif - -#include - -#include "fl_plugin_registrar.h" - -G_BEGIN_DECLS - -G_DECLARE_INTERFACE(FlPluginRegistry, - fl_plugin_registry, - FL, - PLUGIN_REGISTRY, - GObject) - -/** - * FlPluginRegistry: - * - * #FlPluginRegistry vends #FlPluginRegistrar objects for named plugins. - */ - -struct _FlPluginRegistryInterface { - GTypeInterface g_iface; - - /** - * FlPluginRegistry::get_registrar_for_plugin: - * @registry: an #FlPluginRegistry. - * @name: plugin name. - * - * Gets the plugin registrar for the plugin with @name. - * - * Returns: (transfer full): an #FlPluginRegistrar. - */ - FlPluginRegistrar* (*get_registrar_for_plugin)(FlPluginRegistry* registry, - const gchar* name); -}; - -/** - * fl_plugin_registry_get_registrar_for_plugin: - * @registry: an #FlPluginRegistry. - * @name: plugin name. - * - * Gets the plugin registrar for the plugin with @name. - * - * Returns: (transfer full): an #FlPluginRegistrar. - */ -FlPluginRegistrar* fl_plugin_registry_get_registrar_for_plugin( - FlPluginRegistry* registry, - const gchar* name); - -G_END_DECLS - -#endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_PLUGIN_REGISTRY_H_ diff --git a/packages/fl_query/example/linux/flutter/ephemeral/flutter_linux/fl_standard_message_codec.h b/packages/fl_query/example/linux/flutter/ephemeral/flutter_linux/fl_standard_message_codec.h deleted file mode 100644 index 2af7b83..0000000 --- a/packages/fl_query/example/linux/flutter/ephemeral/flutter_linux/fl_standard_message_codec.h +++ /dev/null @@ -1,47 +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. - -#ifndef FLUTTER_SHELL_PLATFORM_LINUX_FL_STANDARD_MESSAGE_CODEC_H_ -#define FLUTTER_SHELL_PLATFORM_LINUX_FL_STANDARD_MESSAGE_CODEC_H_ - -#if !defined(__FLUTTER_LINUX_INSIDE__) && !defined(FLUTTER_LINUX_COMPILATION) -#error "Only can be included directly." -#endif - -#include "fl_message_codec.h" - -G_BEGIN_DECLS - -G_DECLARE_FINAL_TYPE(FlStandardMessageCodec, - fl_standard_message_codec, - FL, - STANDARD_CODEC, - FlMessageCodec) - -/** - * FlStandardMessageCodec: - * - * #FlStandardMessageCodec is an #FlMessageCodec that implements the Flutter - * standard message encoding. This codec encodes and decodes #FlValue of type - * #FL_VALUE_TYPE_NULL, #FL_VALUE_TYPE_BOOL, #FL_VALUE_TYPE_INT, - * #FL_VALUE_TYPE_FLOAT, #FL_VALUE_TYPE_STRING, #FL_VALUE_TYPE_UINT8_LIST, - * #FL_VALUE_TYPE_INT32_LIST, #FL_VALUE_TYPE_INT64_LIST, - * #FL_VALUE_TYPE_FLOAT_LIST, #FL_VALUE_TYPE_LIST, and #FL_VALUE_TYPE_MAP. - * - * #FlStandardMessageCodec matches the StandardCodec class in the Flutter - * services library. - */ - -/* - * fl_standard_message_codec_new: - * - * Creates an #FlStandardMessageCodec. - * - * Returns: a new #FlStandardMessageCodec. - */ -FlStandardMessageCodec* fl_standard_message_codec_new(); - -G_END_DECLS - -#endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_STANDARD_MESSAGE_CODEC_H_ diff --git a/packages/fl_query/example/linux/flutter/ephemeral/flutter_linux/fl_standard_method_codec.h b/packages/fl_query/example/linux/flutter/ephemeral/flutter_linux/fl_standard_method_codec.h deleted file mode 100644 index 1685ebc..0000000 --- a/packages/fl_query/example/linux/flutter/ephemeral/flutter_linux/fl_standard_method_codec.h +++ /dev/null @@ -1,44 +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. - -#ifndef FLUTTER_SHELL_PLATFORM_LINUX_FL_STANDARD_METHOD_CODEC_H_ -#define FLUTTER_SHELL_PLATFORM_LINUX_FL_STANDARD_METHOD_CODEC_H_ - -#if !defined(__FLUTTER_LINUX_INSIDE__) && !defined(FLUTTER_LINUX_COMPILATION) -#error "Only can be included directly." -#endif - -#include "fl_method_codec.h" - -G_BEGIN_DECLS - -G_DECLARE_FINAL_TYPE(FlStandardMethodCodec, - fl_standard_method_codec, - FL, - STANDARD_METHOD_CODEC, - FlMethodCodec) - -/** - * FlStandardMethodCodec: - * - * #FlStandardMethodCodec is an #FlMethodCodec that implements method calls - * using the Flutter standard message encoding. It should be used with a - * #FlMethodChannel. - * - * #FlStandardMethodCodec matches the StandardMethodCodec class in the Flutter - * services library. - */ - -/** - * fl_standard_method_codec_new: - * - * Creates an #FlStandardMethodCodec. - * - * Returns: a new #FlStandardMethodCodec. - */ -FlStandardMethodCodec* fl_standard_method_codec_new(); - -G_END_DECLS - -#endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_STANDARD_METHOD_CODEC_H_ diff --git a/packages/fl_query/example/linux/flutter/ephemeral/flutter_linux/fl_string_codec.h b/packages/fl_query/example/linux/flutter/ephemeral/flutter_linux/fl_string_codec.h deleted file mode 100644 index 8f49e9f..0000000 --- a/packages/fl_query/example/linux/flutter/ephemeral/flutter_linux/fl_string_codec.h +++ /dev/null @@ -1,44 +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. - -#ifndef FLUTTER_SHELL_PLATFORM_LINUX_FL_STRING_CODEC_H_ -#define FLUTTER_SHELL_PLATFORM_LINUX_FL_STRING_CODEC_H_ - -#if !defined(__FLUTTER_LINUX_INSIDE__) && !defined(FLUTTER_LINUX_COMPILATION) -#error "Only can be included directly." -#endif - -#include "fl_message_codec.h" - -G_BEGIN_DECLS - -G_DECLARE_FINAL_TYPE(FlStringCodec, - fl_string_codec, - FL, - STRING_CODEC, - FlMessageCodec) - -/** - * FlStringCodec: - * - * #FlStringCodec is an #FlMessageCodec that implements the Flutter string - * message encoding. This only encodes and decodes #FlValue of type - * #FL_VALUE_TYPE_STRING, other types #FlValues will generate an error during - * encoding. - * - * #FlStringCodec matches the StringCodec class in the Flutter services library. - */ - -/** - * fl_string_codec_new: - * - * Creates an #FlStringCodec. - * - * Returns: a new #FlStringCodec. - */ -FlStringCodec* fl_string_codec_new(); - -G_END_DECLS - -#endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_STRING_CODEC_H_ diff --git a/packages/fl_query/example/linux/flutter/ephemeral/flutter_linux/fl_texture.h b/packages/fl_query/example/linux/flutter/ephemeral/flutter_linux/fl_texture.h deleted file mode 100644 index 45ceb51..0000000 --- a/packages/fl_query/example/linux/flutter/ephemeral/flutter_linux/fl_texture.h +++ /dev/null @@ -1,35 +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. - -#ifndef FLUTTER_SHELL_PLATFORM_LINUX_FL_TEXTURE_H_ -#define FLUTTER_SHELL_PLATFORM_LINUX_FL_TEXTURE_H_ - -#if !defined(__FLUTTER_LINUX_INSIDE__) && !defined(FLUTTER_LINUX_COMPILATION) -#error "Only can be included directly." -#endif - -#include -#include - -G_BEGIN_DECLS - -G_DECLARE_INTERFACE(FlTexture, fl_texture, FL, TEXTURE, GObject) - -/** - * FlTexture: - * - * #FlTexture represents a texture. - * - * You can derive #FlTextureGL for populating hardware-accelerated textures or - * instantiate #FlPixelBufferTexture for populating pixel buffers. Do NOT - * directly implement this interface. - */ - -struct _FlTextureInterface { - GTypeInterface g_iface; -}; - -G_END_DECLS - -#endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_TEXTURE_H_ diff --git a/packages/fl_query/example/linux/flutter/ephemeral/flutter_linux/fl_texture_gl.h b/packages/fl_query/example/linux/flutter/ephemeral/flutter_linux/fl_texture_gl.h deleted file mode 100644 index 949f4af..0000000 --- a/packages/fl_query/example/linux/flutter/ephemeral/flutter_linux/fl_texture_gl.h +++ /dev/null @@ -1,103 +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. - -#ifndef FLUTTER_SHELL_PLATFORM_LINUX_FL_TEXTURE_GL_H_ -#define FLUTTER_SHELL_PLATFORM_LINUX_FL_TEXTURE_GL_H_ - -#if !defined(__FLUTTER_LINUX_INSIDE__) && !defined(FLUTTER_LINUX_COMPILATION) -#error "Only can be included directly." -#endif - -#include -#include -#include "fl_texture.h" - -G_BEGIN_DECLS - -G_DECLARE_DERIVABLE_TYPE(FlTextureGL, fl_texture_gl, FL, TEXTURE_GL, GObject) - -/** - * FlTextureGL: - * - * #FlTextureGL is an abstract class that represents an OpenGL texture. - * - * If you want to render textures in other OpenGL context, create and use the - * #GdkGLContext by calling gdk_window_create_gl_context () with the #GdkWindow - * of #FlView. The context will be shared with the one used by Flutter. - * - * The following example shows how to implement an #FlTextureGL. - * ![ - * #include - * - * // Type definition, constructor, init, destructor, and class_init are - * // omitted. - * struct _VideoTextureGL { // extends FlTextureGL - * FlTextureGL parent_instance; - * - * GLuint texture_id; - * }; - * - * G_DEFINE_TYPE(VideoTexture, - * video_texture, - * fl_texture_gl_get_type ()) - * - * static gboolean - * video_texture_populate (FlTextureGL *texture, - * uint32_t *target, - * uint32_t *name, - * uint32_t *width, - * uint32_t *height, - * GError **error) { - * VideoTextureGL *self = VIDEO_TEXTURE_GL (texture); - * if (self->texture_id == 0) { - * glGenTextures (1, &self->texture_id); - * glBindTexture (GL_TEXTURE_2D, self->texture_id); - * // further configuration here. - * } else { - * glBindTexture (GL_TEXTURE_2D, self->texture_id); - * } - * - * // For example, we render pixel buffer here. - * // Note that Flutter only accepts textures in GL_RGBA8 format. - * static char buffer[] = { 0x1f, 0x2f, 0x3f, 0x4f }; // 1x1 pixel. - * glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8, 1, 1, 0, GL_RGBA, - * GL_UNSIGNED_BYTE, buffer); - * - * *target = GL_TEXTURE_2D; - * *name = self->texture_id; - * *width = 1; - * *height = 1; - * - * return TRUE; - * } - * ]| - */ - -struct _FlTextureGLClass { - GObjectClass parent_class; - - /** - * Virtual method called when Flutter populates this texture. The OpenGL - * context used by Flutter has been already set. - * @texture: an #FlTexture. - * @target: texture target (example GL_TEXTURE_2D or GL_TEXTURE_RECTANGLE). - * @name: (out): name of texture. - * @width: (inout): width of the texture in pixels. - * @height: (inout): height of the texture in pixels. - * @error: (allow-none): #GError location to store the error occurring, or - * %NULL to ignore. - * - * Returns: %TRUE on success. - */ - gboolean (*populate)(FlTextureGL* texture, - uint32_t* target, - uint32_t* name, - uint32_t* width, - uint32_t* height, - GError** error); -}; - -G_END_DECLS - -#endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_TEXTURE_H_ diff --git a/packages/fl_query/example/linux/flutter/ephemeral/flutter_linux/fl_texture_registrar.h b/packages/fl_query/example/linux/flutter/ephemeral/flutter_linux/fl_texture_registrar.h deleted file mode 100644 index 1c03cdc..0000000 --- a/packages/fl_query/example/linux/flutter/ephemeral/flutter_linux/fl_texture_registrar.h +++ /dev/null @@ -1,91 +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. - -#ifndef FLUTTER_SHELL_PLATFORM_LINUX_FL_TEXTURE_REGISTRAR_H_ -#define FLUTTER_SHELL_PLATFORM_LINUX_FL_TEXTURE_REGISTRAR_H_ - -#if !defined(__FLUTTER_LINUX_INSIDE__) && !defined(FLUTTER_LINUX_COMPILATION) -#error "Only can be included directly." -#endif - -#include -#include - -#include "fl_texture.h" - -G_BEGIN_DECLS - -G_DECLARE_INTERFACE(FlTextureRegistrar, - fl_texture_registrar, - FL, - TEXTURE_REGISTRAR, - GObject) - -struct _FlTextureRegistrarInterface { - GTypeInterface parent_iface; - - gboolean (*register_texture)(FlTextureRegistrar* registrar, - FlTexture* texture); - - FlTexture* (*lookup_texture)(FlTextureRegistrar* registrar, int64_t id); - - gboolean (*mark_texture_frame_available)(FlTextureRegistrar* registrar, - FlTexture* texture); - - gboolean (*unregister_texture)(FlTextureRegistrar* registrar, - FlTexture* texture); -}; - -/** - * FlTextureRegistrar: - * - * #FlTextureRegistrar is used when registering textures. - * - * Flutter Framework accesses your texture by the related unique texture ID. To - * draw your texture in Dart, you should add Texture widget in your widget tree - * with the same texture ID. Use platform channels to send this unique texture - * ID to the Dart side. - */ - -/** - * fl_texture_registrar_register_texture: - * @registrar: an #FlTextureRegistrar. - * @texture: an #FlTexture for registration. - * - * Registers a texture. - * - * Returns: %TRUE on success. - */ -gboolean fl_texture_registrar_register_texture(FlTextureRegistrar* registrar, - FlTexture* texture); - -/** - * fl_texture_registrar_mark_texture_frame_available: - * @registrar: an #FlTextureRegistrar. - * @texture: the texture that has a frame available. - * - * Notifies the flutter engine that the texture object has updated and needs to - * be rerendered. - * - * Returns: %TRUE on success. - */ -gboolean fl_texture_registrar_mark_texture_frame_available( - FlTextureRegistrar* registrar, - FlTexture* texture); - -/** - * fl_texture_registrar_unregister_texture: - * @registrar: an #FlTextureRegistrar. - * @texture: the texture being unregistered. - * - * Unregisters an existing texture object. - * - * Returns: %TRUE on success. - */ -gboolean fl_texture_registrar_unregister_texture(FlTextureRegistrar* registrar, - FlTexture* texture); - -G_END_DECLS - -#endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_TEXTURE_REGISTRAR_H_ diff --git a/packages/fl_query/example/linux/flutter/ephemeral/flutter_linux/fl_value.h b/packages/fl_query/example/linux/flutter/ephemeral/flutter_linux/fl_value.h deleted file mode 100644 index 7365d46..0000000 --- a/packages/fl_query/example/linux/flutter/ephemeral/flutter_linux/fl_value.h +++ /dev/null @@ -1,614 +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. - -#ifndef FLUTTER_SHELL_PLATFORM_LINUX_FL_VALUE_H_ -#define FLUTTER_SHELL_PLATFORM_LINUX_FL_VALUE_H_ - -#include -#include -#include - -#if !defined(__FLUTTER_LINUX_INSIDE__) && !defined(FLUTTER_LINUX_COMPILATION) -#error "Only can be included directly." -#endif - -G_BEGIN_DECLS - -/** - * FlValue: - * - * #FlValue is an object that contains the data types used in the platform - * channel used by Flutter. - * - * In Dart the values are represented as follows: - * - #FL_VALUE_TYPE_NULL: Null - * - #FL_VALUE_TYPE_BOOL: bool - * - #FL_VALUE_TYPE_INT: num - * - #FL_VALUE_TYPE_FLOAT: num - * - #FL_VALUE_TYPE_STRING: String - * - #FL_VALUE_TYPE_UINT8_LIST: Uint8List - * - #FL_VALUE_TYPE_INT32_LIST: Int32List - * - #FL_VALUE_TYPE_INT64_LIST: Int64List - * - #FL_VALUE_TYPE_FLOAT32_LIST: Float32List - * - #FL_VALUE_TYPE_FLOAT_LIST: Float64List - * - #FL_VALUE_TYPE_LIST: List - * - #FL_VALUE_TYPE_MAP: Map - * - * See #FlMessageCodec to encode and decode these values. - */ -typedef struct _FlValue FlValue; - -/** - * FlValueType: - * @FL_VALUE_TYPE_NULL: The null value. - * @FL_VALUE_TYPE_BOOL: A boolean. - * @FL_VALUE_TYPE_INT: A 64 bit signed integer. - * @FL_VALUE_TYPE_FLOAT: A 64 bit floating point number. - * @FL_VALUE_TYPE_STRING: UTF-8 text. - * @FL_VALUE_TYPE_UINT8_LIST: An ordered list of unsigned 8 bit integers. - * @FL_VALUE_TYPE_INT32_LIST: An ordered list of 32 bit integers. - * @FL_VALUE_TYPE_INT64_LIST: An ordered list of 64 bit integers. - * @FL_VALUE_TYPE_FLOAT_LIST: An ordered list of floating point numbers. - * @FL_VALUE_TYPE_LIST: An ordered list of #FlValue objects. - * @FL_VALUE_TYPE_MAP: A map of #FlValue objects keyed by #FlValue object. - * @FL_VALUE_TYPE_FLOAT32_LIST: An ordered list of 32bit floating point numbers. - * - * Types of #FlValue. - */ -typedef enum { - FL_VALUE_TYPE_NULL, - FL_VALUE_TYPE_BOOL, - FL_VALUE_TYPE_INT, - FL_VALUE_TYPE_FLOAT, - FL_VALUE_TYPE_STRING, - FL_VALUE_TYPE_UINT8_LIST, - FL_VALUE_TYPE_INT32_LIST, - FL_VALUE_TYPE_INT64_LIST, - FL_VALUE_TYPE_FLOAT_LIST, - FL_VALUE_TYPE_LIST, - FL_VALUE_TYPE_MAP, - FL_VALUE_TYPE_FLOAT32_LIST, -} FlValueType; - -/** - * fl_value_new_null: - * - * Creates an #FlValue that contains a null value. The equivalent Dart type is - * null. - * - * Returns: a new #FlValue. - */ -FlValue* fl_value_new_null(); - -/** - * fl_value_new_bool: - * @value: the value. - * - * Creates an #FlValue that contains a boolean value. The equivalent Dart type - * is a bool. - * - * Returns: a new #FlValue. - */ -FlValue* fl_value_new_bool(bool value); - -/** - * fl_value_new_int: - * @value: the value. - * - * Creates an #FlValue that contains an integer number. The equivalent Dart type - * is a num. - * - * Returns: a new #FlValue. - */ -FlValue* fl_value_new_int(int64_t value); - -/** - * fl_value_new_float: - * @value: the value. - * - * Creates an #FlValue that contains a floating point number. The equivalent - * Dart type is a num. - * - * Returns: a new #FlValue. - */ -FlValue* fl_value_new_float(double value); - -/** - * fl_value_new_string: - * @value: a %NULL-terminated UTF-8 string. - * - * Creates an #FlValue that contains UTF-8 text. The equivalent Dart type is a - * String. - * - * Returns: a new #FlValue. - */ -FlValue* fl_value_new_string(const gchar* value); - -/** - * fl_value_new_string_sized: - * @value: a buffer containing UTF-8 text. It does not require a nul terminator. - * @value_length: the number of bytes to use from @value. - * - * Creates an #FlValue that contains UTF-8 text. The equivalent Dart type is a - * String. - * - * Returns: a new #FlValue. - */ -FlValue* fl_value_new_string_sized(const gchar* value, size_t value_length); - -/** - * fl_value_new_uint8_list: - * @value: an array of unsigned 8 bit integers. - * @value_length: number of elements in @value. - * - * Creates an ordered list containing 8 bit unsigned integers. The data is - * copied. The equivalent Dart type is a Uint8List. - * - * Returns: a new #FlValue. - */ -FlValue* fl_value_new_uint8_list(const uint8_t* value, size_t value_length); - -/** - * fl_value_new_uint8_list_from_bytes: - * @value: a #GBytes. - * - * Creates an ordered list containing 8 bit unsigned integers. The data is - * copied. The equivalent Dart type is a Uint8List. - * - * Returns: a new #FlValue. - */ -FlValue* fl_value_new_uint8_list_from_bytes(GBytes* value); - -/** - * fl_value_new_int32_list: - * @value: an array of signed 32 bit integers. - * @value_length: number of elements in @value. - * - * Creates an ordered list containing 32 bit integers. The equivalent Dart type - * is a Int32List. - * - * Returns: a new #FlValue. - */ -FlValue* fl_value_new_int32_list(const int32_t* value, size_t value_length); - -/** - * fl_value_new_int64_list: - * @value: an array of signed 64 bit integers. - * @value_length: number of elements in @value. - * - * Creates an ordered list containing 64 bit integers. The equivalent Dart type - * is a Int64List. - * - * Returns: a new #FlValue. - */ -FlValue* fl_value_new_int64_list(const int64_t* value, size_t value_length); - -/** - * fl_value_new_float32_list: - * @value: an array of floating point numbers. - * @value_length: number of elements in @value. - * - * Creates an ordered list containing 32 bit floating point numbers. - * The equivalent Dart type is a Float32List. - * - * Returns: a new #FlValue. - */ -FlValue* fl_value_new_float32_list(const float* value, size_t value_length); - -/** - * fl_value_new_float_list: - * @value: an array of floating point numbers. - * @value_length: number of elements in @value. - * - * Creates an ordered list containing floating point numbers. The equivalent - * Dart type is a Float64List. - * - * Returns: a new #FlValue. - */ -FlValue* fl_value_new_float_list(const double* value, size_t value_length); - -/** - * fl_value_new_list: - * - * Creates an ordered list. Children can be added to the list using - * fl_value_append(). The children are accessed using fl_value_get_length() - * and fl_value_get_list_value(). The equivalent Dart type is a List. - * - * The following example shows a simple list of values: - * - * |[ - * g_autoptr(FlValue) value = fl_value_new_list (); - * fl_value_append_take (value, fl_value_new_string ("one"); - * fl_value_append_take (value, fl_value_new_int (2); - * fl_value_append_take (value, fl_value_new_double (3.0); - * ]| - * - * This value can be decoded using: - * - * |[ - * g_assert (fl_value_get_type (value) == FL_VALUE_TYPE_LIST); - * for (size_t i = 0; i < fl_value_get_length (value); i++) { - * FlValue *child = fl_value_get_list_value (value, i); - * process_value (child); - * } - * ]| - * - * Returns: a new #FlValue. - */ -FlValue* fl_value_new_list(); - -/** - * fl_value_new_list_from_strv: - * @value: a %NULL-terminated array of strings. - * - * Creates an ordered list containing #FlString values. - * - * Returns: a new #FlValue. - */ -FlValue* fl_value_new_list_from_strv(const gchar* const* value); - -/** - * fl_value_new_map: - * - * Creates an ordered associative array. Children can be added to the map - * using fl_value_set(), fl_value_set_take(), fl_value_set_string(), - * fl_value_set_string_take(). The children are accessed using - * fl_value_get_length(), fl_value_get_map_key(), fl_value_get_map_value(), - * fl_value_lookup() and fl_value_lookup_string(). The equivalent Dart type is a - * Map. - * - * The following example shows how to create a map of values keyed by strings: - * - * |[ - * g_autoptr(FlValue) value = fl_value_new_map (); - * fl_value_set_string_take (value, "name", fl_value_new_string ("Gandalf")); - * fl_value_set_string_take (value, "occupation", - * fl_value_new_string ("Wizard")); - * fl_value_set_string_take (value, "age", fl_value_new_int (2019)); - * ]| - * - * This value can be decoded using: - * |[ - * g_assert (fl_value_get_type (value) == FL_VALUE_TYPE_MAP); - * FlValue *name = fl_value_lookup_string (value, "name"); - * g_assert (fl_value_get_type (name) == FL_VALUE_TYPE_STRING); - * FlValue *age = fl_value_lookup_string (value, "age"); - * g_assert (fl_value_get_type (age) == FL_VALUE_TYPE_INT); - * g_message ("Next customer is %s (%d years old)", - * fl_value_get_string (name), - * fl_value_get_int (age)); - * ]| - * - * Returns: a new #FlValue. - */ -FlValue* fl_value_new_map(); - -/** - * fl_value_ref: - * @value: an #FlValue. - * - * Increases the reference count of an #FlValue. - * - * Returns: the value that was referenced. - */ -FlValue* fl_value_ref(FlValue* value); - -/** - * fl_value_unref: - * @value: an #FlValue. - * - * Decreases the reference count of an #FlValue. When the reference count hits - * zero @value is destroyed and no longer valid. - */ -void fl_value_unref(FlValue* value); - -/** - * fl_value_get_type: - * @value: an #FlValue. - * - * Gets the type of @value. - * - * Returns: an #FlValueType. - */ -FlValueType fl_value_get_type(FlValue* value); - -/** - * fl_value_equal: - * @a: an #FlValue. - * @b: an #FlValue. - * - * Compares two #FlValue to see if they are equivalent. Two values are - * considered equivalent if they are of the same type and their data is the same - * including any child values. For values of type #FL_VALUE_TYPE_MAP the order - * of the values does not matter. - * - * Returns: %TRUE if both values are equivalent. - */ -bool fl_value_equal(FlValue* a, FlValue* b); - -/** - * fl_value_append: - * @value: an #FlValue of type #FL_VALUE_TYPE_LIST. - * @child: an #FlValue. - * - * Adds @child to the end of @value. Calling this with an #FlValue that is not - * of type #FL_VALUE_TYPE_LIST is a programming error. - */ -void fl_value_append(FlValue* value, FlValue* child); - -/** - * fl_value_append_take: - * @value: an #FlValue of type #FL_VALUE_TYPE_LIST. - * @child: (transfer full): an #FlValue. - * - * Adds @child to the end of @value. Ownership of @child is taken by @value. - * Calling this with an #FlValue that is not of type #FL_VALUE_TYPE_LIST is a - * programming error. - */ -void fl_value_append_take(FlValue* value, FlValue* child); - -/** - * fl_value_set: - * @value: an #FlValue of type #FL_VALUE_TYPE_MAP. - * @key: an #FlValue. - * @child_value: an #FlValue. - * - * Sets @key in @value to @child_value. If an existing value was in the map with - * the same key it is replaced. Calling this with an #FlValue that is not of - * type #FL_VALUE_TYPE_MAP is a programming error. - */ -void fl_value_set(FlValue* value, FlValue* key, FlValue* child_value); - -/** - * fl_value_set_take: - * @value: an #FlValue of type #FL_VALUE_TYPE_MAP. - * @key: (transfer full): an #FlValue. - * @child_value: (transfer full): an #FlValue. - * - * Sets @key in @value to @child_value. Ownership of both @key and @child_value - * is taken by @value. If an existing value was in the map with the same key it - * is replaced. Calling this with an #FlValue that is not of type - * #FL_VALUE_TYPE_MAP is a programming error. - */ -void fl_value_set_take(FlValue* value, FlValue* key, FlValue* child_value); - -/** - * fl_value_set_string: - * @value: an #FlValue of type #FL_VALUE_TYPE_MAP. - * @key: a UTF-8 text key. - * @child_value: an #FlValue. - * - * Sets a value in the map with a text key. If an existing value was in the map - * with the same key it is replaced. Calling this with an #FlValue that is not - * of type #FL_VALUE_TYPE_MAP is a programming error. - */ -void fl_value_set_string(FlValue* value, - const gchar* key, - FlValue* child_value); - -/** - * fl_value_set_string_take: - * @value: an #FlValue of type #FL_VALUE_TYPE_MAP. - * @key: a UTF-8 text key. - * @child_value: (transfer full): an #FlValue. - * - * Sets a value in the map with a text key, taking ownership of the value. If an - * existing value was in the map with the same key it is replaced. Calling this - * with an #FlValue that is not of type #FL_VALUE_TYPE_MAP is a programming - * error. - */ -void fl_value_set_string_take(FlValue* value, - const gchar* key, - FlValue* child_value); - -/** - * fl_value_get_bool: - * @value: an #FlValue of type #FL_VALUE_TYPE_BOOL. - * - * Gets the boolean value of @value. Calling this with an #FlValue that is - * not of type #FL_VALUE_TYPE_BOOL is a programming error. - * - * Returns: a boolean value. - */ -bool fl_value_get_bool(FlValue* value); - -/** - * fl_value_get_int: - * @value: an #FlValue of type #FL_VALUE_TYPE_INT. - * - * Gets the integer number of @value. Calling this with an #FlValue that is - * not of type #FL_VALUE_TYPE_INT is a programming error. - * - * Returns: an integer number. - */ -int64_t fl_value_get_int(FlValue* value); - -/** - * fl_value_get_float: - * @value: an #FlValue of type #FL_VALUE_TYPE_FLOAT. - * - * Gets the floating point number of @value. Calling this with an #FlValue - * that is not of type #FL_VALUE_TYPE_FLOAT is a programming error. - * - * Returns: a floating point number. - */ -double fl_value_get_float(FlValue* value); - -/** - * fl_value_get_string: - * @value: an #FlValue of type #FL_VALUE_TYPE_STRING. - * - * Gets the UTF-8 text contained in @value. Calling this with an #FlValue - * that is not of type #FL_VALUE_TYPE_STRING is a programming error. - * - * Returns: a UTF-8 encoded string. - */ -const gchar* fl_value_get_string(FlValue* value); - -/** - * fl_value_get_length: - * @value: an #FlValue of type #FL_VALUE_TYPE_UINT8_LIST, - * #FL_VALUE_TYPE_INT32_LIST, #FL_VALUE_TYPE_INT64_LIST, - * #FL_VALUE_TYPE_FLOAT32_LIST, #FL_VALUE_TYPE_FLOAT_LIST, #FL_VALUE_TYPE_LIST - * or #FL_VALUE_TYPE_MAP. - * - * Gets the number of elements @value contains. This is only valid for list - * and map types. Calling this with other types is a programming error. - * - * Returns: the number of elements inside @value. - */ -size_t fl_value_get_length(FlValue* value); - -/** - * fl_value_get_uint8_list: - * @value: an #FlValue of type #FL_VALUE_TYPE_UINT8_LIST. - * - * Gets the array of unisigned 8 bit integers @value contains. The data - * contains fl_value_get_length() elements. Calling this with an #FlValue that - * is not of type #FL_VALUE_TYPE_UINT8_LIST is a programming error. - * - * Returns: an array of unsigned 8 bit integers. - */ -const uint8_t* fl_value_get_uint8_list(FlValue* value); - -/** - * fl_value_get_int32_list: - * @value: an #FlValue of type #FL_VALUE_TYPE_INT32_LIST. - * - * Gets the array of 32 bit integers @value contains. The data contains - * fl_value_get_length() elements. Calling this with an #FlValue that is not of - * type #FL_VALUE_TYPE_INT32_LIST is a programming error. - * - * Returns: an array of 32 bit integers. - */ -const int32_t* fl_value_get_int32_list(FlValue* value); - -/** - * fl_value_get_int64_list: - * @value: an #FlValue of type #FL_VALUE_TYPE_INT64_LIST. - * - * Gets the array of 64 bit integers @value contains. The data contains - * fl_value_get_length() elements. Calling this with an #FlValue that is not of - * type #FL_VALUE_TYPE_INT64_LIST is a programming error. - * - * Returns: an array of 64 bit integers. - */ -const int64_t* fl_value_get_int64_list(FlValue* value); - -/** - * fl_value_get_float32_list: - * @value: an #FlValue of type #FL_VALUE_TYPE_FLOAT32_LIST. - * - * Gets the array of floating point numbers @value contains. The data - * contains fl_value_get_length() elements. Calling this with an #FlValue that - * is not of type #FL_VALUE_TYPE_FLOAT32_LIST is a programming error. - * - * Returns: an array of floating point numbers. - */ -const float* fl_value_get_float32_list(FlValue* value); - -/** - * fl_value_get_float_list: - * @value: an #FlValue of type #FL_VALUE_TYPE_FLOAT_LIST. - * - * Gets the array of floating point numbers @value contains. The data - * contains fl_value_get_length() elements. Calling this with an #FlValue that - * is not of type #FL_VALUE_TYPE_FLOAT_LIST is a programming error. - * - * Returns: an array of floating point numbers. - */ -const double* fl_value_get_float_list(FlValue* value); - -/** - * fl_value_get_list_value: - * @value: an #FlValue of type #FL_VALUE_TYPE_LIST. - * @index: an index in the list. - * - * Gets a child element of the list. It is a programming error to request an - * index that is outside the size of the list as returned from - * fl_value_get_length(). Calling this with an #FlValue that is not of type - * #FL_VALUE_TYPE_LIST is a programming error. - * - * Returns: an #FlValue. - */ -FlValue* fl_value_get_list_value(FlValue* value, size_t index); - -/** - * fl_value_get_map_key: - * @value: an #FlValue of type #FL_VALUE_TYPE_MAP. - * @index: an index in the map. - * - * Gets a key from the map. It is a programming error to request an index that - * is outside the size of the list as returned from fl_value_get_length(). - * Calling this with an #FlValue that is not of type #FL_VALUE_TYPE_MAP is a - * programming error. - * - * Returns: an #FlValue. - */ -FlValue* fl_value_get_map_key(FlValue* value, size_t index); - -/** - * fl_value_get_map_value: - * @value: an #FlValue of type #FL_VALUE_TYPE_MAP. - * @index: an index in the map. - * - * Gets a value from the map. It is a programming error to request an index that - * is outside the size of the list as returned from fl_value_get_length(). - * Calling this with an #FlValue that is not of type #FL_VALUE_TYPE_MAP is a - * programming error. - * - * Returns: an #FlValue. - */ -FlValue* fl_value_get_map_value(FlValue* value, size_t index); - -/** - * fl_value_lookup: - * @value: an #FlValue of type #FL_VALUE_TYPE_MAP. - * @key: a key value. - * - * Gets the map entry that matches @key. Keys are checked using - * fl_value_equal(). Calling this with an #FlValue that is not of type - * #FL_VALUE_TYPE_MAP is a programming error. - * - * Map lookups are not optimized for performance - if you have a large map or - * need frequent access you should copy the data into another structure, e.g. - * #GHashTable. - * - * Returns: (allow-none): the value with this key or %NULL if not one present. - */ -FlValue* fl_value_lookup(FlValue* value, FlValue* key); - -/** - * fl_value_lookup_string: - * @value: an #FlValue of type #FL_VALUE_TYPE_MAP. - * @key: a key value. - * - * Gets the map entry that matches @key. Keys are checked using - * fl_value_equal(). Calling this with an #FlValue that is not of type - * #FL_VALUE_TYPE_MAP is a programming error. - * - * Map lookups are not optimized for performance - if you have a large map or - * need frequent access you should copy the data into another structure, e.g. - * #GHashTable. - * - * Returns: (allow-none): the value with this key or %NULL if not one present. - */ -FlValue* fl_value_lookup_string(FlValue* value, const gchar* key); - -/** - * fl_value_to_string: - * @value: an #FlValue. - * - * Converts an #FlValue to a text representation, suitable for logging purposes. - * The text is formatted to be the equivalent of Dart toString() methods. - * - * Returns: UTF-8 text. - */ -gchar* fl_value_to_string(FlValue* value); - -G_DEFINE_AUTOPTR_CLEANUP_FUNC(FlValue, fl_value_unref) - -G_END_DECLS - -#endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_VALUE_H_ diff --git a/packages/fl_query/example/linux/flutter/ephemeral/flutter_linux/fl_view.h b/packages/fl_query/example/linux/flutter/ephemeral/flutter_linux/fl_view.h deleted file mode 100644 index f93f385..0000000 --- a/packages/fl_query/example/linux/flutter/ephemeral/flutter_linux/fl_view.h +++ /dev/null @@ -1,61 +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. - -#ifndef FLUTTER_SHELL_PLATFORM_LINUX_FL_VIEW_H_ -#define FLUTTER_SHELL_PLATFORM_LINUX_FL_VIEW_H_ - -#if !defined(__FLUTTER_LINUX_INSIDE__) && !defined(FLUTTER_LINUX_COMPILATION) -#error "Only can be included directly." -#endif - -#include - -#include "fl_dart_project.h" -#include "fl_engine.h" - -G_BEGIN_DECLS - -G_DECLARE_FINAL_TYPE(FlView, fl_view, FL, VIEW, GtkContainer) - -/** - * FlView: - * - * #FlView is a GTK widget that is capable of displaying a Flutter application. - * - * The following example shows how to set up a view in a GTK application: - * |[ - * FlDartProject *project = fl_dart_project_new (); - * FlView *view = fl_view_new (project); - * gtk_widget_show (GTK_WIDGET (view)); - * gtk_container_add (GTK_CONTAINER (parent), view); - * - * FlBinaryMessenger *messenger = - * fl_engine_get_binary_messenger (fl_view_get_engine (view)); - * setup_channels_or_plugins (messenger); - * ]| - */ - -/** - * fl_view_new: - * @project: The project to show. - * - * Creates a widget to show Flutter application. - * - * Returns: a new #FlView. - */ -FlView* fl_view_new(FlDartProject* project); - -/** - * fl_view_get_engine: - * @view: an #FlView. - * - * Gets the engine being rendered in the view. - * - * Returns: an #FlEngine. - */ -FlEngine* fl_view_get_engine(FlView* view); - -G_END_DECLS - -#endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_VIEW_H_ diff --git a/packages/fl_query/example/linux/flutter/ephemeral/flutter_linux/flutter_linux.h b/packages/fl_query/example/linux/flutter/ephemeral/flutter_linux/flutter_linux.h deleted file mode 100644 index 2d9317d..0000000 --- a/packages/fl_query/example/linux/flutter/ephemeral/flutter_linux/flutter_linux.h +++ /dev/null @@ -1,37 +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. - -#ifndef FLUTTER_SHELL_PLATFORM_LINUX_FLUTTER_LINUX_H_ -#define FLUTTER_SHELL_PLATFORM_LINUX_FLUTTER_LINUX_H_ - -#define __FLUTTER_LINUX_INSIDE__ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#undef __FLUTTER_LINUX_INSIDE__ - -#endif // FLUTTER_SHELL_PLATFORM_LINUX_FLUTTER_LINUX_H_ diff --git a/packages/fl_query/example/linux/flutter/ephemeral/generated_config.cmake b/packages/fl_query/example/linux/flutter/ephemeral/generated_config.cmake deleted file mode 100644 index 1ede13b..0000000 --- a/packages/fl_query/example/linux/flutter/ephemeral/generated_config.cmake +++ /dev/null @@ -1,21 +0,0 @@ -# Generated code do not commit. -file(TO_CMAKE_PATH "/home/krtirtho/fvm/versions/3.3.5" FLUTTER_ROOT) -file(TO_CMAKE_PATH "/home/krtirtho/dev/fl-query/packages/fl_query/example" PROJECT_DIR) - -set(FLUTTER_VERSION "1.0.0+1" PARENT_SCOPE) -set(FLUTTER_VERSION_MAJOR 1 PARENT_SCOPE) -set(FLUTTER_VERSION_MINOR 0 PARENT_SCOPE) -set(FLUTTER_VERSION_PATCH 0 PARENT_SCOPE) -set(FLUTTER_VERSION_BUILD 1 PARENT_SCOPE) - -# Environment variables to pass to tool_backend.sh -list(APPEND FLUTTER_TOOL_ENVIRONMENT - "FLUTTER_ROOT=/home/krtirtho/fvm/versions/3.3.5" - "PROJECT_DIR=/home/krtirtho/dev/fl-query/packages/fl_query/example" - "DART_DEFINES=RkxVVFRFUl9XRUJfQVVUT19ERVRFQ1Q9dHJ1ZQ==" - "DART_OBFUSCATION=false" - "TRACK_WIDGET_CREATION=true" - "TREE_SHAKE_ICONS=false" - "PACKAGE_CONFIG=/home/krtirtho/dev/fl-query/packages/fl_query/example/.dart_tool/package_config.json" - "FLUTTER_TARGET=/home/krtirtho/dev/fl-query/packages/fl_query/example/lib/main.dart" -) diff --git a/packages/fl_query/example/linux/flutter/ephemeral/icudtl.dat b/packages/fl_query/example/linux/flutter/ephemeral/icudtl.dat deleted file mode 100644 index 720a5c7..0000000 Binary files a/packages/fl_query/example/linux/flutter/ephemeral/icudtl.dat and /dev/null differ diff --git a/packages/fl_query/example/linux/flutter/ephemeral/libflutter_linux_gtk.so b/packages/fl_query/example/linux/flutter/ephemeral/libflutter_linux_gtk.so deleted file mode 100644 index 2c78d56..0000000 Binary files a/packages/fl_query/example/linux/flutter/ephemeral/libflutter_linux_gtk.so and /dev/null differ diff --git a/packages/fl_query/example/macos/Flutter/GeneratedPluginRegistrant.swift b/packages/fl_query/example/macos/Flutter/GeneratedPluginRegistrant.swift index 79818f9..ec592a9 100644 --- a/packages/fl_query/example/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/packages/fl_query/example/macos/Flutter/GeneratedPluginRegistrant.swift @@ -5,8 +5,8 @@ import FlutterMacOS import Foundation -import connectivity_plus_macos -import path_provider_macos +import connectivity_plus +import path_provider_foundation func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { ConnectivityPlugin.register(with: registry.registrar(forPlugin: "ConnectivityPlugin")) diff --git a/packages/fl_query/example/macos/Flutter/ephemeral/Flutter-Generated.xcconfig b/packages/fl_query/example/macos/Flutter/ephemeral/Flutter-Generated.xcconfig deleted file mode 100644 index 579fc56..0000000 --- a/packages/fl_query/example/macos/Flutter/ephemeral/Flutter-Generated.xcconfig +++ /dev/null @@ -1,11 +0,0 @@ -// This is a generated file; do not edit or check into version control. -FLUTTER_ROOT=/home/krtirtho/fvm/versions/3.3.5 -FLUTTER_APPLICATION_PATH=/home/krtirtho/dev/fl-query/packages/fl_query/example -COCOAPODS_PARALLEL_CODE_SIGN=true -FLUTTER_BUILD_DIR=build -FLUTTER_BUILD_NAME=1.0.0 -FLUTTER_BUILD_NUMBER=1 -DART_OBFUSCATION=false -TRACK_WIDGET_CREATION=true -TREE_SHAKE_ICONS=false -PACKAGE_CONFIG=.dart_tool/package_config.json diff --git a/packages/fl_query/example/macos/Flutter/ephemeral/flutter_export_environment.sh b/packages/fl_query/example/macos/Flutter/ephemeral/flutter_export_environment.sh deleted file mode 100755 index 51e84e3..0000000 --- a/packages/fl_query/example/macos/Flutter/ephemeral/flutter_export_environment.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh -# This is a generated file; do not edit or check into version control. -export "FLUTTER_ROOT=/home/krtirtho/fvm/versions/3.3.5" -export "FLUTTER_APPLICATION_PATH=/home/krtirtho/dev/fl-query/packages/fl_query/example" -export "COCOAPODS_PARALLEL_CODE_SIGN=true" -export "FLUTTER_BUILD_DIR=build" -export "FLUTTER_BUILD_NAME=1.0.0" -export "FLUTTER_BUILD_NUMBER=1" -export "DART_OBFUSCATION=false" -export "TRACK_WIDGET_CREATION=true" -export "TREE_SHAKE_ICONS=false" -export "PACKAGE_CONFIG=.dart_tool/package_config.json" diff --git a/packages/fl_query/example/macos/Runner.xcodeproj/project.pbxproj b/packages/fl_query/example/macos/Runner.xcodeproj/project.pbxproj index c84862c..d9333e4 100644 --- a/packages/fl_query/example/macos/Runner.xcodeproj/project.pbxproj +++ b/packages/fl_query/example/macos/Runner.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 51; + objectVersion = 54; objects = { /* Begin PBXAggregateTarget section */ @@ -235,6 +235,7 @@ /* Begin PBXShellScriptBuildPhase section */ 3399D490228B24CF009A79C7 /* ShellScript */ = { isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; buildActionMask = 2147483647; files = ( ); @@ -344,7 +345,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.11; + MACOSX_DEPLOYMENT_TARGET = 10.14; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = macosx; SWIFT_COMPILATION_MODE = wholemodule; @@ -423,7 +424,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.11; + MACOSX_DEPLOYMENT_TARGET = 10.14; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = macosx; @@ -470,7 +471,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.11; + MACOSX_DEPLOYMENT_TARGET = 10.14; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = macosx; SWIFT_COMPILATION_MODE = wholemodule; diff --git a/packages/fl_query/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png b/packages/fl_query/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png index 3c4935a..82b6f9d 100644 Binary files a/packages/fl_query/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png and b/packages/fl_query/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png differ diff --git a/packages/fl_query/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png b/packages/fl_query/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png index ed4cc16..13b35eb 100644 Binary files a/packages/fl_query/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png and b/packages/fl_query/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png differ diff --git a/packages/fl_query/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png b/packages/fl_query/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png index 483be61..0a3f5fa 100644 Binary files a/packages/fl_query/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png and b/packages/fl_query/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png differ diff --git a/packages/fl_query/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png b/packages/fl_query/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png index bcbf36d..bdb5722 100644 Binary files a/packages/fl_query/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png and b/packages/fl_query/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png differ diff --git a/packages/fl_query/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png b/packages/fl_query/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png index 9c0a652..f083318 100644 Binary files a/packages/fl_query/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png and b/packages/fl_query/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png differ diff --git a/packages/fl_query/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png b/packages/fl_query/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png index e71a726..326c0e7 100644 Binary files a/packages/fl_query/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png and b/packages/fl_query/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png differ diff --git a/packages/fl_query/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png b/packages/fl_query/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png index 8a31fe2..2f1632c 100644 Binary files a/packages/fl_query/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png and b/packages/fl_query/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png differ diff --git a/packages/fl_query/example/macos/Runner/Configs/AppInfo.xcconfig b/packages/fl_query/example/macos/Runner/Configs/AppInfo.xcconfig index 8b42559..dda192b 100644 --- a/packages/fl_query/example/macos/Runner/Configs/AppInfo.xcconfig +++ b/packages/fl_query/example/macos/Runner/Configs/AppInfo.xcconfig @@ -11,4 +11,4 @@ PRODUCT_NAME = example PRODUCT_BUNDLE_IDENTIFIER = com.example.example // The copyright displayed in application information -PRODUCT_COPYRIGHT = Copyright © 2022 com.example. All rights reserved. +PRODUCT_COPYRIGHT = Copyright © 2023 com.example. All rights reserved. diff --git a/packages/fl_query/example/pubspec.lock b/packages/fl_query/example/pubspec.lock index 86b66bb..1fcd6d9 100644 --- a/packages/fl_query/example/pubspec.lock +++ b/packages/fl_query/example/pubspec.lock @@ -5,126 +5,104 @@ packages: dependency: transitive description: name: args - url: "https://pub.dartlang.org" + sha256: eef6c46b622e0494a36c5a12d10d77fb4e855501a91c1b9ef9339326e58f0596 + url: "https://pub.dev" source: hosted - version: "2.3.1" + version: "2.4.2" async: dependency: transitive description: name: async - url: "https://pub.dartlang.org" + sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" + url: "https://pub.dev" source: hosted - version: "2.9.0" + version: "2.11.0" boolean_selector: dependency: transitive description: name: boolean_selector - url: "https://pub.dartlang.org" + sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.1" characters: dependency: transitive description: name: characters - url: "https://pub.dartlang.org" + sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" + url: "https://pub.dev" source: hosted - version: "1.2.1" + version: "1.3.0" clock: dependency: transitive description: name: clock - url: "https://pub.dartlang.org" + sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf + url: "https://pub.dev" source: hosted version: "1.1.1" collection: dependency: transitive description: name: collection - url: "https://pub.dartlang.org" + sha256: f092b211a4319e98e5ff58223576de6c2803db36221657b46c82574721240687 + url: "https://pub.dev" source: hosted - version: "1.16.0" + version: "1.17.2" connectivity_plus: dependency: transitive description: name: connectivity_plus - url: "https://pub.dartlang.org" + sha256: "8599ae9edca5ff96163fca3e36f8e481ea917d1e71cdad912c084b5579913f34" + url: "https://pub.dev" source: hosted - version: "2.3.9" - connectivity_plus_linux: - dependency: transitive - description: - name: connectivity_plus_linux - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.1" - connectivity_plus_macos: - dependency: transitive - description: - name: connectivity_plus_macos - url: "https://pub.dartlang.org" - source: hosted - version: "1.2.4" + version: "4.0.1" connectivity_plus_platform_interface: dependency: transitive description: name: connectivity_plus_platform_interface - url: "https://pub.dartlang.org" + sha256: cf1d1c28f4416f8c654d7dc3cd638ec586076255d407cef3ddbdaf178272a71a + url: "https://pub.dev" source: hosted - version: "1.2.1" - connectivity_plus_web: - dependency: transitive - description: - name: connectivity_plus_web - url: "https://pub.dartlang.org" - source: hosted - version: "1.2.5" - connectivity_plus_windows: - dependency: transitive - description: - name: connectivity_plus_windows - url: "https://pub.dartlang.org" - source: hosted - version: "1.2.2" + version: "1.2.4" crypto: dependency: transitive description: name: crypto - url: "https://pub.dartlang.org" + sha256: aa274aa7774f8964e4f4f38cc994db7b6158dd36e9187aaceaddc994b35c6c67 + url: "https://pub.dev" source: hosted version: "3.0.2" - cupertino_icons: - dependency: "direct main" - description: - name: cupertino_icons - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.5" dbus: dependency: transitive description: name: dbus - url: "https://pub.dartlang.org" + sha256: "6f07cba3f7b3448d42d015bfd3d53fe12e5b36da2423f23838efc1d5fb31a263" + url: "https://pub.dev" source: hosted - version: "0.7.7" + version: "0.7.8" fake_async: dependency: transitive description: name: fake_async - url: "https://pub.dartlang.org" + sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" + url: "https://pub.dev" source: hosted version: "1.3.1" ffi: dependency: transitive description: name: ffi - url: "https://pub.dartlang.org" + sha256: a38574032c5f1dd06c4aee541789906c12ccaab8ba01446e800d9c5b79c4a978 + url: "https://pub.dev" source: hosted version: "2.0.1" file: dependency: transitive description: name: file - url: "https://pub.dartlang.org" + sha256: "1b92bec4fc2a72f59a8e15af5f52cd441e4a7860b49499d69dfa817af20e925d" + url: "https://pub.dev" source: hosted version: "6.1.4" fl_query: @@ -133,7 +111,21 @@ packages: path: ".." relative: true source: path - version: "0.3.1" + version: "1.0.0-alpha.4" + fl_query_connectivity_plus_adapter: + dependency: "direct main" + description: + path: "../../fl_query_connectivity_plus_adapter" + relative: true + source: path + version: "0.1.0-alpha.3" + fl_query_devtools: + dependency: "direct main" + description: + path: "../../fl_query_devtools" + relative: true + source: path + version: "0.1.0-alpha.2" flutter: dependency: "direct main" description: flutter @@ -143,7 +135,8 @@ packages: dependency: "direct dev" description: name: flutter_lints - url: "https://pub.dartlang.org" + sha256: aeb0b80a8b3709709c9cc496cdc027c5b3216796bc0af0ce1007eaf24464fd4c + url: "https://pub.dev" source: hosted version: "2.0.1" flutter_test: @@ -156,270 +149,315 @@ packages: description: flutter source: sdk version: "0.0.0" + go_router: + dependency: "direct main" + description: + name: go_router + sha256: "7a79232827c851f6b9f08c3c7254a1eaff7bc6aa147e103e51f951c5c10b0ccc" + url: "https://pub.dev" + source: hosted + version: "6.0.9" hive: dependency: transitive description: name: hive - url: "https://pub.dartlang.org" + sha256: "8dcf6db979d7933da8217edcec84e9df1bdb4e4edc7fc77dbd5aa74356d6d941" + url: "https://pub.dev" source: hosted version: "2.2.3" hive_flutter: dependency: transitive description: name: hive_flutter - url: "https://pub.dartlang.org" + sha256: dca1da446b1d808a51689fb5d0c6c9510c0a2ba01e22805d492c73b68e33eecc + url: "https://pub.dev" source: hosted version: "1.1.0" http: dependency: "direct main" description: name: http - url: "https://pub.dartlang.org" + sha256: "6aa2946395183537c8b880962d935877325d6a09a2867c3970c05c0fed6ac482" + url: "https://pub.dev" source: hosted version: "0.13.5" http_parser: dependency: transitive description: name: http_parser - url: "https://pub.dartlang.org" + sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b" + url: "https://pub.dev" source: hosted - version: "4.0.1" - infinite_scroll_pagination: - dependency: "direct main" - description: - name: infinite_scroll_pagination - url: "https://pub.dartlang.org" - source: hosted - version: "3.2.0" + version: "4.0.2" js: dependency: transitive description: name: js - url: "https://pub.dartlang.org" + sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3 + url: "https://pub.dev" source: hosted - version: "0.6.4" + version: "0.6.7" + json_view: + dependency: transitive + description: + name: json_view + sha256: a60ea6dae3a3fe7a94418bdbc9e66f990f7a4582e010b091d27db16ab6fb1a3e + url: "https://pub.dev" + source: hosted + version: "0.4.1" lints: dependency: transitive description: name: lints - url: "https://pub.dartlang.org" + sha256: "5e4a9cd06d447758280a8ac2405101e0e2094d2a1dbdd3756aec3fe7775ba593" + url: "https://pub.dev" source: hosted - version: "2.0.0" + version: "2.0.1" + logging: + dependency: transitive + description: + name: logging + sha256: "04094f2eb032cbb06c6f6e8d3607edcfcb0455e2bb6cbc010cb01171dcb64e6d" + url: "https://pub.dev" + source: hosted + version: "1.1.1" matcher: dependency: transitive description: name: matcher - url: "https://pub.dartlang.org" + sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e" + url: "https://pub.dev" source: hosted - version: "0.12.12" + version: "0.12.16" material_color_utilities: dependency: transitive description: name: material_color_utilities - url: "https://pub.dartlang.org" + sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41" + url: "https://pub.dev" source: hosted - version: "0.1.5" + version: "0.5.0" meta: dependency: transitive description: name: meta - url: "https://pub.dartlang.org" + sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" + url: "https://pub.dev" source: hosted - version: "1.8.0" + version: "1.9.1" + mutex: + dependency: transitive + description: + name: mutex + sha256: "03116a4e46282a671b46c12de649d72c0ed18188ffe12a8d0fc63e83f4ad88f4" + url: "https://pub.dev" + source: hosted + version: "3.0.1" nm: dependency: transitive description: name: nm - url: "https://pub.dartlang.org" + sha256: "2c9aae4127bdc8993206464fcc063611e0e36e72018696cd9631023a31b24254" + url: "https://pub.dev" source: hosted version: "0.5.0" path: dependency: transitive description: name: path - url: "https://pub.dartlang.org" + sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" + url: "https://pub.dev" source: hosted - version: "1.8.2" + version: "1.8.3" path_provider: dependency: transitive description: name: path_provider - url: "https://pub.dartlang.org" + sha256: dcea5feb97d8abf90cab9e9030b497fb7c3cbf26b7a1fe9e3ef7dcb0a1ddec95 + url: "https://pub.dev" source: hosted - version: "2.0.11" + version: "2.0.12" path_provider_android: dependency: transitive description: name: path_provider_android - url: "https://pub.dartlang.org" + sha256: a776c088d671b27f6e3aa8881d64b87b3e80201c64e8869b811325de7a76c15e + url: "https://pub.dev" source: hosted version: "2.0.22" - path_provider_ios: + path_provider_foundation: dependency: transitive description: - name: path_provider_ios - url: "https://pub.dartlang.org" + name: path_provider_foundation + sha256: "62a68e7e1c6c459f9289859e2fae58290c981ce21d1697faf54910fe1faa4c74" + url: "https://pub.dev" source: hosted - version: "2.0.11" + version: "2.1.1" path_provider_linux: dependency: transitive description: name: path_provider_linux - url: "https://pub.dartlang.org" + sha256: "2e32f1640f07caef0d3cb993680f181c79e54a3827b997d5ee221490d131fbd9" + url: "https://pub.dev" source: hosted - version: "2.1.7" - path_provider_macos: - dependency: transitive - description: - name: path_provider_macos - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.6" + version: "2.1.8" path_provider_platform_interface: dependency: transitive description: name: path_provider_platform_interface - url: "https://pub.dartlang.org" + sha256: f0abc8ebd7253741f05488b4813d936b4d07c6bae3e86148a09e342ee4b08e76 + url: "https://pub.dev" source: hosted version: "2.0.5" path_provider_windows: dependency: transitive description: name: path_provider_windows - url: "https://pub.dartlang.org" + sha256: bcabbe399d4042b8ee687e17548d5d3f527255253b4a639f5f8d2094a9c2b45c + url: "https://pub.dev" source: hosted version: "2.1.3" petitparser: dependency: transitive description: name: petitparser - url: "https://pub.dartlang.org" + sha256: cb3798bef7fc021ac45b308f4b51208a152792445cce0448c9a4ba5879dd8750 + url: "https://pub.dev" source: hosted - version: "5.0.0" + version: "5.4.0" platform: dependency: transitive description: name: platform - url: "https://pub.dartlang.org" + sha256: "4a451831508d7d6ca779f7ac6e212b4023dd5a7d08a27a63da33756410e32b76" + url: "https://pub.dev" source: hosted version: "3.1.0" plugin_platform_interface: dependency: transitive description: name: plugin_platform_interface - url: "https://pub.dartlang.org" + sha256: dbf0f707c78beedc9200146ad3cb0ab4d5da13c246336987be6940f026500d3a + url: "https://pub.dev" source: hosted - version: "2.1.2" + version: "2.1.3" process: dependency: transitive description: name: process - url: "https://pub.dartlang.org" + sha256: "53fd8db9cec1d37b0574e12f07520d582019cb6c44abf5479a01505099a34a09" + url: "https://pub.dev" source: hosted version: "4.2.4" - queue: - dependency: transitive - description: - name: queue - url: "https://pub.dartlang.org" - source: hosted - version: "3.1.0+2" sky_engine: dependency: transitive description: flutter source: sdk version: "0.0.99" - sliver_tools: - dependency: transitive - description: - name: sliver_tools - url: "https://pub.dartlang.org" - source: hosted - version: "0.2.7" source_span: dependency: transitive description: name: source_span - url: "https://pub.dartlang.org" + sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" + url: "https://pub.dev" source: hosted - version: "1.9.0" + version: "1.10.0" stack_trace: dependency: transitive description: name: stack_trace - url: "https://pub.dartlang.org" + sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 + url: "https://pub.dev" source: hosted - version: "1.10.0" + version: "1.11.0" + state_notifier: + dependency: transitive + description: + name: state_notifier + sha256: "8fe42610f179b843b12371e40db58c9444f8757f8b69d181c97e50787caed289" + url: "https://pub.dev" + source: hosted + version: "0.7.2+1" stream_channel: dependency: transitive description: name: stream_channel - url: "https://pub.dartlang.org" + sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.1" string_scanner: dependency: transitive description: name: string_scanner - url: "https://pub.dartlang.org" + sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" + url: "https://pub.dev" source: hosted - version: "1.1.1" + version: "1.2.0" term_glyph: dependency: transitive description: name: term_glyph - url: "https://pub.dartlang.org" + sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 + url: "https://pub.dev" source: hosted version: "1.2.1" test_api: dependency: transitive description: name: test_api - url: "https://pub.dartlang.org" + sha256: "75760ffd7786fffdfb9597c35c5b27eaeec82be8edfb6d71d32651128ed7aab8" + url: "https://pub.dev" source: hosted - version: "0.4.12" + version: "0.6.0" typed_data: dependency: transitive description: name: typed_data - url: "https://pub.dartlang.org" + sha256: "26f87ade979c47a150c9eaab93ccd2bebe70a27dc0b4b29517f2904f04eb11a5" + url: "https://pub.dev" source: hosted version: "1.3.1" - uuid: - dependency: transitive - description: - name: uuid - url: "https://pub.dartlang.org" - source: hosted - version: "3.0.6" vector_math: dependency: transitive description: name: vector_math - url: "https://pub.dartlang.org" + sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" + url: "https://pub.dev" source: hosted - version: "2.1.2" + version: "2.1.4" + web: + dependency: transitive + description: + name: web + sha256: dc8ccd225a2005c1be616fe02951e2e342092edf968cf0844220383757ef8f10 + url: "https://pub.dev" + source: hosted + version: "0.1.4-beta" win32: dependency: transitive description: name: win32 - url: "https://pub.dartlang.org" + sha256: c9ebe7ee4ab0c2194e65d3a07d8c54c5d00bb001b76081c4a04cdb8448b59e46 + url: "https://pub.dev" source: hosted - version: "3.1.2" + version: "3.1.3" xdg_directories: dependency: transitive description: name: xdg_directories - url: "https://pub.dartlang.org" + sha256: ee1505df1426458f7f60aac270645098d318a8b4766d85fde75f76f2e21807d1 + url: "https://pub.dev" source: hosted - version: "0.2.0+2" + version: "1.0.0" xml: dependency: transitive description: name: xml - url: "https://pub.dartlang.org" + sha256: "5bc72e1e45e941d825fd7468b9b4cc3b9327942649aeb6fc5cdbf135f0a86e84" + url: "https://pub.dev" source: hosted - version: "6.1.0" + version: "6.3.0" sdks: - dart: ">=2.17.1 <3.0.0" - flutter: ">=3.0.0" + dart: ">=3.1.0-185.0.dev <4.0.0" + flutter: ">=3.3.0" diff --git a/packages/fl_query/example/pubspec.yaml b/packages/fl_query/example/pubspec.yaml index 7a04d3f..9b0ee79 100644 --- a/packages/fl_query/example/pubspec.yaml +++ b/packages/fl_query/example/pubspec.yaml @@ -1,92 +1,24 @@ name: fl_query_example description: A new Flutter project. - -# The following line prevents the package from being accidentally published to -# pub.dev using `flutter pub publish`. This is preferred for private packages. -publish_to: 'none' # Remove this line if you wish to publish to pub.dev - -# The following defines the version and build number for your application. -# A version number is three numbers separated by dots, like 1.2.43 -# followed by an optional build number separated by a +. -# Both the version and the builder number may be overridden in flutter -# build by specifying --build-name and --build-number, respectively. -# In Android, build-name is used as versionName while build-number used as versionCode. -# Read more about Android versioning at https://developer.android.com/studio/publish/versioning -# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. -# Read more about iOS versioning at -# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 1.0.0+1 +publish_to: 'none' +version: 0.1.0 environment: - sdk: ">=2.17.1 <3.0.0" + sdk: '>=2.19.0 <3.0.0' -# Dependencies specify other packages that your package needs in order to work. -# To automatically upgrade your package dependencies to the latest versions -# consider running `flutter pub upgrade --major-versions`. Alternatively, -# dependencies can be manually updated by changing the version numbers below to -# the latest version available on pub.dev. To see which dependencies have newer -# versions available, run `flutter pub outdated`. dependencies: flutter: sdk: flutter - - - # The following adds the Cupertino Icons font to your application. - # Use with the CupertinoIcons class for iOS style icons. - cupertino_icons: ^1.0.2 - fl_query: ^0.2.0 + fl_query: ^1.0.0-alpha.5 + fl_query_connectivity_plus_adapter: ^0.1.0-alpha.4 + fl_query_devtools: ^0.1.0-alpha.3 + go_router: ^6.0.9 http: ^0.13.5 - infinite_scroll_pagination: ^3.2.0 dev_dependencies: flutter_test: sdk: flutter - - # The "flutter_lints" package below contains a set of recommended lints to - # encourage good coding practices. The lint set provided by the package is - # activated in the `analysis_options.yaml` file located at the root of your - # package. See that file for information about deactivating specific lint - # rules and activating additional ones. flutter_lints: ^2.0.0 -# For information on the generic Dart part of this file, see the -# following page: https://dart.dev/tools/pub/pubspec - -# The following section is specific to Flutter packages. flutter: - - # The following line ensures that the Material Icons font is - # included with your application, so that you can use the icons in - # the material Icons class. uses-material-design: true - - # To add assets to your application, add an assets section, like this: - # assets: - # - images/a_dot_burr.jpeg - # - images/a_dot_ham.jpeg - - # An image asset can refer to one or more resolution-specific "variants", see - # https://flutter.dev/assets-and-images/#resolution-aware - - # For details regarding adding assets from package dependencies, see - # https://flutter.dev/assets-and-images/#from-packages - - # To add custom fonts to your application, add a fonts section here, - # in this "flutter" section. Each entry in this list should have a - # "family" key with the font family name, and a "fonts" key with a - # list giving the asset and other descriptors for the font. For - # example: - # fonts: - # - family: Schyler - # fonts: - # - asset: fonts/Schyler-Regular.ttf - # - asset: fonts/Schyler-Italic.ttf - # style: italic - # - family: Trajan Pro - # fonts: - # - asset: fonts/TrajanPro.ttf - # - asset: fonts/TrajanPro_Bold.ttf - # weight: 700 - # - # For details regarding fonts from package dependencies, - # see https://flutter.dev/custom-fonts/#from-packages diff --git a/packages/fl_query/example/pubspec_overrides.yaml b/packages/fl_query/example/pubspec_overrides.yaml new file mode 100644 index 0000000..59e3f64 --- /dev/null +++ b/packages/fl_query/example/pubspec_overrides.yaml @@ -0,0 +1,8 @@ +# melos_managed_dependency_overrides: fl_query,fl_query_connectivity_plus_adapter,fl_query_devtools +dependency_overrides: + fl_query: + path: .. + fl_query_connectivity_plus_adapter: + path: ../../fl_query_connectivity_plus_adapter + fl_query_devtools: + path: ../../fl_query_devtools diff --git a/packages/fl_query/example/web/index.html b/packages/fl_query/example/web/index.html index 41b3bc3..be820e8 100644 --- a/packages/fl_query/example/web/index.html +++ b/packages/fl_query/example/web/index.html @@ -46,11 +46,12 @@ _flutter.loader.loadEntrypoint({ serviceWorker: { serviceWorkerVersion: serviceWorkerVersion, + }, + onEntrypointLoaded: function(engineInitializer) { + engineInitializer.initializeEngine().then(function(appRunner) { + appRunner.runApp(); + }); } - }).then(function(engineInitializer) { - return engineInitializer.initializeEngine(); - }).then(function(appRunner) { - return appRunner.runApp(); }); }); diff --git a/packages/fl_query/example/windows/flutter/ephemeral/.plugin_symlinks/connectivity_plus_windows b/packages/fl_query/example/windows/flutter/ephemeral/.plugin_symlinks/connectivity_plus_windows deleted file mode 120000 index f0db25a..0000000 --- a/packages/fl_query/example/windows/flutter/ephemeral/.plugin_symlinks/connectivity_plus_windows +++ /dev/null @@ -1 +0,0 @@ -/opt/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_windows-1.2.2/ \ No newline at end of file diff --git a/packages/fl_query/example/windows/flutter/generated_plugin_registrant.cc b/packages/fl_query/example/windows/flutter/generated_plugin_registrant.cc index 8083d74..8777c93 100644 --- a/packages/fl_query/example/windows/flutter/generated_plugin_registrant.cc +++ b/packages/fl_query/example/windows/flutter/generated_plugin_registrant.cc @@ -6,7 +6,7 @@ #include "generated_plugin_registrant.h" -#include +#include void RegisterPlugins(flutter::PluginRegistry* registry) { ConnectivityPlusWindowsPluginRegisterWithRegistrar( diff --git a/packages/fl_query/example/windows/flutter/generated_plugins.cmake b/packages/fl_query/example/windows/flutter/generated_plugins.cmake index 8cf5d42..cc1361d 100644 --- a/packages/fl_query/example/windows/flutter/generated_plugins.cmake +++ b/packages/fl_query/example/windows/flutter/generated_plugins.cmake @@ -3,7 +3,7 @@ # list(APPEND FLUTTER_PLUGIN_LIST - connectivity_plus_windows + connectivity_plus ) list(APPEND FLUTTER_FFI_PLUGIN_LIST diff --git a/packages/fl_query/example/windows/runner/CMakeLists.txt b/packages/fl_query/example/windows/runner/CMakeLists.txt index b9e550f..394917c 100644 --- a/packages/fl_query/example/windows/runner/CMakeLists.txt +++ b/packages/fl_query/example/windows/runner/CMakeLists.txt @@ -20,12 +20,20 @@ add_executable(${BINARY_NAME} WIN32 # that need different build settings. apply_standard_settings(${BINARY_NAME}) +# Add preprocessor definitions for the build version. +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"") +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}") +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}") +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}") +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}") + # Disable Windows macros that collide with C++ standard library functions. target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") # Add dependency libraries and include directories. Add any application-specific # dependencies here. target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) +target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib") target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") # Run the Flutter tool portions of the build. This must not be removed. diff --git a/packages/fl_query/example/windows/runner/Runner.rc b/packages/fl_query/example/windows/runner/Runner.rc index 5fdea29..aecaa2b 100644 --- a/packages/fl_query/example/windows/runner/Runner.rc +++ b/packages/fl_query/example/windows/runner/Runner.rc @@ -60,14 +60,14 @@ IDI_APP_ICON ICON "resources\\app_icon.ico" // Version // -#ifdef FLUTTER_BUILD_NUMBER -#define VERSION_AS_NUMBER FLUTTER_BUILD_NUMBER +#if defined(FLUTTER_VERSION_MAJOR) && defined(FLUTTER_VERSION_MINOR) && defined(FLUTTER_VERSION_PATCH) && defined(FLUTTER_VERSION_BUILD) +#define VERSION_AS_NUMBER FLUTTER_VERSION_MAJOR,FLUTTER_VERSION_MINOR,FLUTTER_VERSION_PATCH,FLUTTER_VERSION_BUILD #else -#define VERSION_AS_NUMBER 1,0,0 +#define VERSION_AS_NUMBER 1,0,0,0 #endif -#ifdef FLUTTER_BUILD_NAME -#define VERSION_AS_STRING #FLUTTER_BUILD_NAME +#if defined(FLUTTER_VERSION) +#define VERSION_AS_STRING FLUTTER_VERSION #else #define VERSION_AS_STRING "1.0.0" #endif @@ -93,7 +93,7 @@ BEGIN VALUE "FileDescription", "example" "\0" VALUE "FileVersion", VERSION_AS_STRING "\0" VALUE "InternalName", "example" "\0" - VALUE "LegalCopyright", "Copyright (C) 2022 com.example. All rights reserved." "\0" + VALUE "LegalCopyright", "Copyright (C) 2023 com.example. All rights reserved." "\0" VALUE "OriginalFilename", "example.exe" "\0" VALUE "ProductName", "example" "\0" VALUE "ProductVersion", VERSION_AS_STRING "\0" diff --git a/packages/fl_query/example/windows/runner/flutter_window.cpp b/packages/fl_query/example/windows/runner/flutter_window.cpp index b43b909..b25e363 100644 --- a/packages/fl_query/example/windows/runner/flutter_window.cpp +++ b/packages/fl_query/example/windows/runner/flutter_window.cpp @@ -26,6 +26,11 @@ bool FlutterWindow::OnCreate() { } RegisterPlugins(flutter_controller_->engine()); SetChildContent(flutter_controller_->view()->GetNativeWindow()); + + flutter_controller_->engine()->SetNextFrameCallback([&]() { + this->Show(); + }); + return true; } diff --git a/packages/fl_query/example/windows/runner/main.cpp b/packages/fl_query/example/windows/runner/main.cpp index bcb57b0..a61bf80 100644 --- a/packages/fl_query/example/windows/runner/main.cpp +++ b/packages/fl_query/example/windows/runner/main.cpp @@ -27,7 +27,7 @@ int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, FlutterWindow window(project); Win32Window::Point origin(10, 10); Win32Window::Size size(1280, 720); - if (!window.CreateAndShow(L"example", origin, size)) { + if (!window.Create(L"example", origin, size)) { return EXIT_FAILURE; } window.SetQuitOnClose(true); diff --git a/packages/fl_query/example/windows/runner/runner.exe.manifest b/packages/fl_query/example/windows/runner/runner.exe.manifest index c977c4a..a42ea76 100644 --- a/packages/fl_query/example/windows/runner/runner.exe.manifest +++ b/packages/fl_query/example/windows/runner/runner.exe.manifest @@ -7,7 +7,7 @@ - + diff --git a/packages/fl_query/example/windows/runner/win32_window.cpp b/packages/fl_query/example/windows/runner/win32_window.cpp index c10f08d..041a385 100644 --- a/packages/fl_query/example/windows/runner/win32_window.cpp +++ b/packages/fl_query/example/windows/runner/win32_window.cpp @@ -1,13 +1,31 @@ #include "win32_window.h" +#include #include #include "resource.h" namespace { +/// Window attribute that enables dark mode window decorations. +/// +/// Redefined in case the developer's machine has a Windows SDK older than +/// version 10.0.22000.0. +/// See: https://docs.microsoft.com/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattribute +#ifndef DWMWA_USE_IMMERSIVE_DARK_MODE +#define DWMWA_USE_IMMERSIVE_DARK_MODE 20 +#endif + constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW"; +/// Registry key for app theme preference. +/// +/// A value of 0 indicates apps should use dark mode. A non-zero or missing +/// value indicates apps should use light mode. +constexpr const wchar_t kGetPreferredBrightnessRegKey[] = + L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize"; +constexpr const wchar_t kGetPreferredBrightnessRegValue[] = L"AppsUseLightTheme"; + // The number of Win32Window objects that currently exist. static int g_active_window_count = 0; @@ -31,8 +49,8 @@ void EnableFullDpiSupportIfAvailable(HWND hwnd) { GetProcAddress(user32_module, "EnableNonClientDpiScaling")); if (enable_non_client_dpi_scaling != nullptr) { enable_non_client_dpi_scaling(hwnd); - FreeLibrary(user32_module); } + FreeLibrary(user32_module); } } // namespace @@ -102,9 +120,9 @@ Win32Window::~Win32Window() { Destroy(); } -bool Win32Window::CreateAndShow(const std::wstring& title, - const Point& origin, - const Size& size) { +bool Win32Window::Create(const std::wstring& title, + const Point& origin, + const Size& size) { Destroy(); const wchar_t* window_class = @@ -117,7 +135,7 @@ bool Win32Window::CreateAndShow(const std::wstring& title, double scale_factor = dpi / 96.0; HWND window = CreateWindow( - window_class, title.c_str(), WS_OVERLAPPEDWINDOW | WS_VISIBLE, + window_class, title.c_str(), WS_OVERLAPPEDWINDOW, Scale(origin.x, scale_factor), Scale(origin.y, scale_factor), Scale(size.width, scale_factor), Scale(size.height, scale_factor), nullptr, nullptr, GetModuleHandle(nullptr), this); @@ -126,9 +144,15 @@ bool Win32Window::CreateAndShow(const std::wstring& title, return false; } + UpdateTheme(window); + return OnCreate(); } +bool Win32Window::Show() { + return ShowWindow(window_handle_, SW_SHOWNORMAL); +} + // static LRESULT CALLBACK Win32Window::WndProc(HWND const window, UINT const message, @@ -188,6 +212,10 @@ Win32Window::MessageHandler(HWND hwnd, SetFocus(child_content_); } return 0; + + case WM_DWMCOLORIZATIONCOLORCHANGED: + UpdateTheme(hwnd); + return 0; } return DefWindowProc(window_handle_, message, wparam, lparam); @@ -243,3 +271,18 @@ bool Win32Window::OnCreate() { void Win32Window::OnDestroy() { // No-op; provided for subclasses. } + +void Win32Window::UpdateTheme(HWND const window) { + DWORD light_mode; + DWORD light_mode_size = sizeof(light_mode); + LSTATUS result = RegGetValue(HKEY_CURRENT_USER, kGetPreferredBrightnessRegKey, + kGetPreferredBrightnessRegValue, + RRF_RT_REG_DWORD, nullptr, &light_mode, + &light_mode_size); + + if (result == ERROR_SUCCESS) { + BOOL enable_dark_mode = light_mode == 0; + DwmSetWindowAttribute(window, DWMWA_USE_IMMERSIVE_DARK_MODE, + &enable_dark_mode, sizeof(enable_dark_mode)); + } +} diff --git a/packages/fl_query/example/windows/runner/win32_window.h b/packages/fl_query/example/windows/runner/win32_window.h index 17ba431..c86632d 100644 --- a/packages/fl_query/example/windows/runner/win32_window.h +++ b/packages/fl_query/example/windows/runner/win32_window.h @@ -28,15 +28,16 @@ class Win32Window { Win32Window(); virtual ~Win32Window(); - // Creates and shows a win32 window with |title| and position and size using + // Creates a win32 window with |title| that is positioned and sized using // |origin| and |size|. New windows are created on the default monitor. Window // sizes are specified to the OS in physical pixels, hence to ensure a - // consistent size to will treat the width height passed in to this function - // as logical pixels and scale to appropriate for the default monitor. Returns - // true if the window was created successfully. - bool CreateAndShow(const std::wstring& title, - const Point& origin, - const Size& size); + // consistent size this function will scale the inputted width and height as + // as appropriate for the default monitor. The window is invisible until + // |Show| is called. Returns true if the window was created successfully. + bool Create(const std::wstring& title, const Point& origin, const Size& size); + + // Show the current window. Returns true if the window was successfully shown. + bool Show(); // Release OS resources associated with window. void Destroy(); @@ -86,6 +87,9 @@ class Win32Window { // Retrieves a class instance pointer for |window| static Win32Window* GetThisFromHandle(HWND const window) noexcept; + // Update the window frame's theme to match the system theme. + static void UpdateTheme(HWND const window); + bool quit_on_close_ = false; // window handle for top level window. diff --git a/packages/fl_query/lib/fl_query.dart b/packages/fl_query/lib/fl_query.dart index 8b38056..2ef1e4f 100644 --- a/packages/fl_query/lib/fl_query.dart +++ b/packages/fl_query/lib/fl_query.dart @@ -1,59 +1,23 @@ library fl_query; -import 'package:flutter/cupertino.dart'; -import 'package:flutter/foundation.dart'; -import 'package:hive_flutter/hive_flutter.dart'; -import 'package:path/path.dart' - if (dart.library.html) 'package:hive_flutter/src/stub/path.dart' - as path_helper; +export 'src/collections/default_configs.dart'; +export 'src/collections/json_config.dart'; +export 'src/collections/refresh_config.dart'; +export 'src/collections/retry_config.dart'; +export 'src/collections/connectivity_adapter.dart'; -export 'src/infinite_query.dart'; -export 'src/infinite_query_builder.dart'; -export 'src/query.dart'; -export 'src/query_bowl.dart'; -export 'src/query_builder.dart'; -export 'src/mutation.dart'; -export 'src/mutation_builder.dart'; -export 'src/always_online_connectivity.dart'; -export 'src/models/infinite_query_job.dart'; -export 'src/models/query_job.dart'; -export 'src/models/mutation_job.dart'; -import 'package:path_provider/path_provider.dart'; -export 'src/utils.dart' show isShallowEqual, getVariable; +export 'src/core/cache.dart'; +export 'src/core/client.dart'; +export 'src/core/infinite_query.dart'; +export 'src/core/provider.dart'; +export 'src/core/query.dart'; +export 'src/core/mutation.dart'; -late final kFlQueryBoxKey; - -/// `cacheKey`: An unique key to identify the cache of fl_query for this -/// application -/// -/// `cacheSubDirectory`: The sub directory to store the cache file -/// -/// `encryptionKey`: The encryption key to encrypt the cache of fl_query -/// -/// If not provided then the cache won't be encrypted. -/// The encryption key must be a list of 32 integers -/// -/// You can use [Random.secure().nextBytes(32)] to generate a random encryption key. -/// And store that key in a secure storage like -/// [flutter_secure_storage](https://pub.dev/packages/flutter_secure_storage) -/// for securely storing the encryption key when your application is closed. -Future initializeFlQuery({ - required String cacheKey, - List? encryptionKey, - String? cacheSubDirectory, -}) async { - WidgetsFlutterBinding.ensureInitialized(); - if (kIsWeb) return; - - final appDir = await getApplicationDocumentsDirectory(); - Hive.init( - path_helper.join(appDir.path, cacheSubDirectory), - backendPreference: HiveStorageBackendPreference.webWorker, - ); - kFlQueryBoxKey = cacheKey + "-fl_query"; - await Hive.openLazyBox( - kFlQueryBoxKey, - encryptionCipher: - encryptionKey != null ? HiveAesCipher(encryptionKey) : null, - ); -} +export 'src/widgets/query_builder.dart'; +export 'src/widgets/query_listenable.dart'; +export 'src/widgets/infinite_query_builder.dart'; +export 'src/widgets/infinite_query_listenable.dart'; +export 'src/widgets/mutation_builder.dart'; +export 'src/widgets/state_resolvers/query_state.dart'; +export 'src/widgets/state_resolvers/infinite_query_state.dart'; +export 'src/widgets/state_resolvers/mutation_state.dart'; diff --git a/packages/fl_query/lib/src/always_online_connectivity.dart b/packages/fl_query/lib/src/always_online_connectivity.dart deleted file mode 100644 index 1ebf35d..0000000 --- a/packages/fl_query/lib/src/always_online_connectivity.dart +++ /dev/null @@ -1,20 +0,0 @@ -import 'package:connectivity_plus/connectivity_plus.dart'; - -final _alwaysOnlineConnectivity = AlwaysOnlineConnectivity._(); - -/// make this singleton -class AlwaysOnlineConnectivity implements Connectivity { - AlwaysOnlineConnectivity._(); - - factory AlwaysOnlineConnectivity() { - return _alwaysOnlineConnectivity; - } - - @override - Future checkConnectivity() { - return Future.value(ConnectivityResult.ethernet); - } - - @override - Stream get onConnectivityChanged => Stream.empty(); -} diff --git a/packages/fl_query/lib/src/base_operation.dart b/packages/fl_query/lib/src/base_operation.dart deleted file mode 100644 index b81c071..0000000 --- a/packages/fl_query/lib/src/base_operation.dart +++ /dev/null @@ -1,86 +0,0 @@ -import 'package:connectivity_plus/connectivity_plus.dart'; -import 'package:fl_query/src/utils.dart'; -import 'package:flutter/widgets.dart'; - -abstract class BaseOperation extends ChangeNotifier { - /// The number of times the query should refetch in the time of error - /// before giving up - final int retries; - final Duration retryDelay; - - // got from global options - @protected - Duration cacheTime; - - Connectivity _connectivity; - - // all properties - Data? data; - Error? error; - - /// total count of how many times the query retried to get a successful - /// result - int retryAttempts = 0; - DateTime updatedAt; - - bool fetched = false; - - /// used for keeping track of query activity. If the are no mounts & - /// the passed cached time is over than the query is removed from - /// storage/cache - Set> _mounts = {}; - - BaseOperation({ - required this.cacheTime, - required this.retries, - required this.retryDelay, - this.data, - Connectivity? connectivity, - }) : updatedAt = DateTime.now(), - _connectivity = connectivity ?? Connectivity(); - - void mount(ValueKey uKey) { - _mounts.add(uKey); - } - - void unmount(ValueKey uKey) { - if (_mounts.length == 1) { - Future.delayed(cacheTime, () { - _mounts.remove(uKey); - // for letting know QueryBowl that this one's time has come for - // getting crushed - notifyListeners(); - }); - } else { - _mounts.remove(uKey); - } - } - - Set> get mounts => _mounts; - - /// checks if the application is connected to internet in any mean - /// - /// It's true when any one this is connected - - /// - ethernet - /// - mobile - /// - wifi - /// - /// Deprecated: Use [isNetworkOnline] instead - @deprecated - Future isInternetConnected() async { - return isNetworkOnline; - } - - /// checks if the application is connected to internet in any mean - /// - /// It's true when any one this is connected - - /// - ethernet - /// - mobile - /// - wifi - Future get isNetworkOnline => - _connectivity.checkConnectivity().then((v) => isConnectedToInternet(v)); - - bool get isInactive => mounts.isEmpty; - bool get hasData => data != null; - bool get hasError => error != null; -} diff --git a/packages/fl_query/lib/src/base_query.dart b/packages/fl_query/lib/src/base_query.dart deleted file mode 100644 index 7506e7b..0000000 --- a/packages/fl_query/lib/src/base_query.dart +++ /dev/null @@ -1,410 +0,0 @@ -import 'dart:async'; - -import 'package:fl_query/fl_query.dart'; -import 'package:fl_query/src/base_operation.dart'; -import 'package:fl_query/src/mixins/autocast.dart'; -import 'package:flutter/widgets.dart'; -import 'package:hive/hive.dart'; - -abstract class BaseQuery - extends BaseOperation with AutoCast { -// all params - final String queryKey; - bool? refetchOnMount; - bool? refetchOnReconnect; - - final T? _initialData; - - // got from global options - Duration _staleTime; - - /// total count of how many times the query retried to get a successful - /// result - int refetchCount = 0; - bool enabled; - - QueryStatus status; - - @protected - final Set onDataListeners = Set(); - @protected - final Set onErrorListeners = Set(); - - // externalData will always be passed to the task Callback - // it will change based on the presence of QueryBuilder - Outside _externalData; - - Outside? _prevUsedExternalData; - - Duration? refetchInterval; - - Timer? _refetchIntervalTimer; - - bool? refetchOnApplicationResume; - bool? refetchOnWindowFocus; - - T? _previousData; - - BaseQuery({ - required this.queryKey, - required Duration staleTime, - required super.cacheTime, - required Outside externalData, - required super.retries, - required super.retryDelay, - required this.status, - super.connectivity, - this.refetchOnMount, - this.refetchOnReconnect, - this.refetchInterval, - this.refetchOnApplicationResume, - this.refetchOnWindowFocus, - this.enabled = true, - T? previousData, - T? initialData, - onData, - onError, - }) : _staleTime = staleTime, - _initialData = initialData, - _externalData = externalData, - _previousData = previousData, - super(data: previousData ?? initialData) { - if (onData != null) onDataListeners.add(onData); - if (onError != null) onErrorListeners.add(onError); - - if (refetchInterval != null && refetchInterval != Duration.zero) { - _refetchIntervalTimer = createRefetchTimer(); - } - if (canCacheToDisk) { - loadFromDisk(); - } - } - // all getters & setters - - Outside get externalData => _externalData; - Outside? get prevUsedExternalData => _prevUsedExternalData; - - @protected - Timer createRefetchTimer(); - - @protected - Future loadFromDisk() async { - final box = await Hive.lazyBox(kFlQueryBoxKey); - final rawData = await box.get(queryKey); - if (rawData == null) return; - data = deserialize(rawData); - if (!isLoading && !isRefetching) { - status = QueryStatus.cached; - } - updatedAt = DateTime.now(); - await notifyDataListeners(); - notifyListeners(); - } - - Future saveToDisk({bool delete = false}) async { - if (!canCacheToDisk) return; - if (!hasData) { - if (delete) { - final box = await Hive.lazyBox(kFlQueryBoxKey); - await box.delete(queryKey); - } - return; - } - final box = await Hive.lazyBox(kFlQueryBoxKey); - await box.put(queryKey, serialize(data!)!); - } - - /// Calls the task function & doesn't check if there's already - /// cached data available - @protected - Future execute() async { - try { - retryAttempts = 0; - await setData(); - await saveToDisk(); - _prevUsedExternalData = _externalData; - updatedAt = DateTime.now(); - status = QueryStatus.success; - await notifyDataListeners(); - notifyListeners(); - } catch (e) { - if (retries == 0) { - status = QueryStatus.error; - setError(e); - await notifyErrorListeners(); - notifyListeners(); - } else { - // retrying for retry count if failed for the first time - while (retryAttempts <= retries) { - await Future.delayed(retryDelay); - try { - await setData(); - await saveToDisk(); - _prevUsedExternalData = _externalData; - status = QueryStatus.success; - await notifyDataListeners(); - notifyListeners(); - break; - } catch (e) { - if (retryAttempts == retries) { - status = QueryStatus.error; - setError(e); - await notifyErrorListeners(); - notifyListeners(); - break; - } - retryAttempts++; - } - } - } - } - } - - void addDataListener(listener) { - onDataListeners.add(listener); - } - - void addErrorListener(listener) { - onErrorListeners.add(listener); - } - - void removeDataListener(listener) { - onDataListeners.remove(listener); - } - - void removeErrorListener(listener) { - onErrorListeners.remove(listener); - } - - /// fetches data or runs the provided task initially - /// - /// Once [data] is available it won't run the [task] ever again - /// and will only return the available data - /// - /// If a [fetch] is already running in the background it'll just return - /// the current available [data] (which can be nul if no [initialPage] - /// was provided) instead of running the task to prevent race conditions - Future fetch() async { - if (!enabled) return null; - - if (isCachedData) { - status = QueryStatus.loading; - await execute().then((_) { - fetched = true; - }); - notifyListeners(); - return data; - } - final x = hasData && !isPreviousData; - var isOnline = await isNetworkOnline; - - /// if isLoading/isRefetching is true that means its already fetching/ - /// refetching. So [_execute] again can create a race condition - if (isLoading || isRefetching || !isOnline || (hasData && !isPreviousData)) - return data; - status = QueryStatus.loading; - notifyListeners(); - return execute().then((_) { - fetched = true; - return data; - }); - } - - /// refetches a valid or invalid [Query] - /// - /// When called before calling [fetch] in a [Query] it'll - /// automatically run [fetch] - /// - /// But if it's used to fetch the first data of a non-enabled [Query] - /// aka `LazyQuery`, it'll execute the task & will set the status - /// `enabled=true` - /// - /// If a [refetch] is already running in the background it'll just return - /// the current available [data] instead of running the task to prevent - /// race conditions - Future refetch() async { - /// if isLoading/isRefetching is true that means its already fetching/ - /// refetching. So [_execute] again can create a race condition - if (isRefetching || isLoading || !(await isNetworkOnline)) return data; - if (enabled && !fetched) return await fetch(); - status = QueryStatus.refetching; - refetchCount++; - // disabling the lazy query bound when query was actually called - if (!enabled) enabled = true; - notifyListeners(); - return await execute().then((_) => data); - } - - @protected - String? serialize(T data); - - @protected - T? deserialize(String rawData); - - @protected - bool get canCacheToDisk; - - @protected - FutureOr setData(); - @protected - void setError(dynamic); - @protected - FutureOr notifyDataListeners() async { - for (final onData in onDataListeners) { - await onData(data); - } - } - - @protected - FutureOr notifyErrorListeners() async { - for (final onError in onErrorListeners) { - await onError(error); - } - } - - /// Sets the [externalData] from outside of the query - /// - /// Remember, it's for the very instance of [Query] - /// So this won't persist through later UI/[Query] updates - void setExternalData(Outside externalData) { - _prevUsedExternalData = _externalData; - _externalData = externalData; - } - - /// Resets the query - /// - /// The values of internal state of the query are reset to the - /// initial ones - void reset() { - refetchCount = 0; - data = _previousData ?? _initialData; - saveToDisk(delete: true); - error = null; - fetched = false; - status = QueryStatus.idle; - retryAttempts = 0; - onDataListeners.clear(); - onErrorListeners.clear(); - mounts.clear(); - } - - @override - void dispose() async { - await Hive.openLazyBox(kFlQueryBoxKey).then((box) => box.delete(queryKey)); - super.dispose(); - } - - /// Update configurations of the query - /// after already creating the Query instance - /// - /// Remember, it's just for the single query instance - /// In the next UI update/render the options will get reset - /// to the default ones defined in the [QueryJob] or [QueryBowlScope] - void updateDefaultOptions({ - Duration? refetchInterval, - Duration? staleTime, - Duration? cacheTime, - bool? refetchOnMount, - bool? refetchOnReconnect, - bool? refetchOnApplicationResume, - bool? refetchOnWindowFocus, - }) { - bool updated = false; - if (this.refetchInterval == null && - refetchInterval != null && - refetchInterval != Duration.zero) { - this.refetchInterval = refetchInterval; - _refetchIntervalTimer?.cancel(); - _refetchIntervalTimer = createRefetchTimer(); - updated = true; - } - if (this.cacheTime == Duration(minutes: 5) && cacheTime != null) { - this.cacheTime = cacheTime; - updated = true; - } - if (this._staleTime == const Duration(milliseconds: 500) && - staleTime != null) { - this._staleTime = staleTime; - updated = true; - } - if (this.refetchOnMount == null && refetchOnMount != null) { - this.refetchOnMount = refetchOnMount; - updated = true; - } - if (this.refetchOnReconnect == null && refetchOnReconnect != null) { - this.refetchOnReconnect = refetchOnReconnect; - updated = true; - } - if (this.refetchOnApplicationResume == null && - refetchOnApplicationResume != null) { - this.refetchOnApplicationResume = refetchOnApplicationResume; - updated = true; - } - if (this.refetchOnWindowFocus == null && refetchOnWindowFocus != null) { - this.refetchOnWindowFocus = refetchOnWindowFocus; - updated = true; - } - if (updated) notifyListeners(); - } - - /// can be used to update the data manually. Can be useful when used - /// together with mutations to perform optimistic updates or manual data - /// updates - /// For updating particular queries after a mutation using the - /// `QueryBowl.refetchQueries` is more appropriate. But this one can be - /// used when only 1 query needs get updated - /// - /// Every time a new instance of data should be returned because of - /// immutability - void setQueryData(QueryUpdateFunction updateFn) async { - final newData = await updateFn(data); - if (data == newData) return; - data = newData; - await saveToDisk(); - status = QueryStatus.success; - notifyListeners(); - } - - /// invalidates the query - /// - /// Forcefully makes the query stale & expired which results in a refetch - /// when met conditions - void invalidate() { - /// subtracting [staleTime] from [updatedAt] as staleTime=Duration.zero - /// indicates the query must never become stale but subtracting the - /// [staleTime] will always revert the updatedAt time to the default - /// time whenever isStale is called - updatedAt = updatedAt.subtract(_staleTime); - notifyListeners(); - } - - bool get isStale { - /// when [_staleTime] is [Duration.zero], the query will always be - /// stale & will never refetch in the background. But can be inactive - /// if [mounts.length] become zero - if (_staleTime == Duration.zero) return false; - - // when [DateTime.now()] is after [update_at + stale_time] it means - // the data has become stale - return DateTime.now().isAfter(updatedAt.add(_staleTime)); - } - - bool get isError => status == QueryStatus.error; - bool get isIdle => status == QueryStatus.idle; - bool get isLoading => status == QueryStatus.loading; - bool get isRefetching => status == QueryStatus.refetching; - bool get isSuccess => status == QueryStatus.success; - bool get isCachedData => status == QueryStatus.cached; - bool get isPreviousData { - return _previousData != null ? _previousData == data : false; - } - - String get debugLabel; - - @override - String toString() { - return debugLabel; - } - - operator ==(other); -} diff --git a/packages/fl_query/lib/src/collections/connectivity_adapter.dart b/packages/fl_query/lib/src/collections/connectivity_adapter.dart new file mode 100644 index 0000000..5e97628 --- /dev/null +++ b/packages/fl_query/lib/src/collections/connectivity_adapter.dart @@ -0,0 +1,24 @@ +abstract class ConnectivityAdapter { + bool _isConnectedSync; + + ConnectivityAdapter() : _isConnectedSync = true { + isConnected.then((c) => _isConnectedSync = c); + onConnectivityChanged.listen((isConnected) { + _isConnectedSync = isConnected; + }); + } + + bool get isConnectedSync => _isConnectedSync; + + Future get isConnected; + + Stream get onConnectivityChanged; +} + +class NoOpConnectivityAdapter extends ConnectivityAdapter { + @override + Future get isConnected => Future.value(true); + + @override + Stream get onConnectivityChanged => Stream.empty(); +} diff --git a/packages/fl_query/lib/src/collections/default_configs.dart b/packages/fl_query/lib/src/collections/default_configs.dart new file mode 100644 index 0000000..35eb39a --- /dev/null +++ b/packages/fl_query/lib/src/collections/default_configs.dart @@ -0,0 +1,25 @@ +import 'package:fl_query/src/collections/refresh_config.dart'; +import 'package:fl_query/src/collections/retry_config.dart'; +import 'package:flutter/material.dart'; + +/// Default configurations for [RetryConfig], [RefreshConfig] and [Duration] +/// +/// This are opinionated defaults and can be overridden +@immutable +abstract class DefaultConstants { + static const RetryConfig retryConfig = RetryConfig( + maxRetries: 3, + retryDelay: Duration(seconds: 1), + cancelWhenOffline: true, + ); + + static const RefreshConfig refreshConfig = RefreshConfig( + staleDuration: Duration(minutes: 2, milliseconds: 250), + refreshInterval: Duration.zero, + refreshOnMount: false, + refreshOnQueryFnChange: false, + refreshOnNetworkStateChange: true, + ); + + static const Duration cacheDuration = Duration(minutes: 5); +} diff --git a/packages/fl_query/lib/src/collections/json_config.dart b/packages/fl_query/lib/src/collections/json_config.dart new file mode 100644 index 0000000..762b80d --- /dev/null +++ b/packages/fl_query/lib/src/collections/json_config.dart @@ -0,0 +1,9 @@ +class JsonConfig { + final Map Function(T data) toJson; + final T Function(Map json) fromJson; + + const JsonConfig({ + required this.toJson, + required this.fromJson, + }); +} diff --git a/packages/fl_query/lib/src/collections/refresh_config.dart b/packages/fl_query/lib/src/collections/refresh_config.dart new file mode 100644 index 0000000..16b75b3 --- /dev/null +++ b/packages/fl_query/lib/src/collections/refresh_config.dart @@ -0,0 +1,75 @@ +import 'package:fl_query/src/collections/default_configs.dart'; +import 'package:fl_query/src/core/client.dart'; +import 'package:flutter/material.dart'; + +class RefreshConfig { + final Duration staleDuration; + final Duration refreshInterval; + final bool refreshOnMount; + final bool refreshOnQueryFnChange; + final bool refreshOnNetworkStateChange; + + const RefreshConfig({ + required this.staleDuration, + required this.refreshInterval, + required this.refreshOnMount, + required this.refreshOnQueryFnChange, + required this.refreshOnNetworkStateChange, + }); + + factory RefreshConfig.withDefaults( + BuildContext context, { + Duration? staleDuration, + Duration? refreshInterval, + bool? refreshOnMount, + bool? refreshOnQueryFnChange, + }) { + return QueryClient.of(context).refreshConfig.copyWith( + staleDuration: staleDuration, + refreshInterval: refreshInterval, + refreshOnMount: refreshOnMount, + refreshOnQueryFnChange: refreshOnQueryFnChange, + ); + } + + factory RefreshConfig.withConstantDefaults({ + Duration? staleDuration, + Duration? refreshInterval, + bool? refreshOnMount, + bool? refreshOnQueryFnChange, + }) { + return DefaultConstants.refreshConfig.copyWith( + staleDuration: staleDuration, + refreshInterval: refreshInterval, + refreshOnMount: refreshOnMount, + refreshOnQueryFnChange: refreshOnQueryFnChange, + ); + } + + RefreshConfig copyWith({ + Duration? staleDuration, + Duration? refreshInterval, + bool? refreshOnMount, + bool? refreshOnQueryFnChange, + bool? refreshOnNetworkStateChange, + }) { + return RefreshConfig( + staleDuration: staleDuration ?? this.staleDuration, + refreshInterval: refreshInterval ?? this.refreshInterval, + refreshOnMount: refreshOnMount ?? this.refreshOnMount, + refreshOnQueryFnChange: + refreshOnQueryFnChange ?? this.refreshOnQueryFnChange, + refreshOnNetworkStateChange: + refreshOnNetworkStateChange ?? this.refreshOnNetworkStateChange, + ); + } + + Map toJson() { + return { + 'staleDuration': staleDuration.toString(), + 'refreshInterval': refreshInterval.toString(), + 'refreshOnMount': refreshOnMount, + 'refreshOnQueryFnChange': refreshOnQueryFnChange, + }; + } +} diff --git a/packages/fl_query/lib/src/collections/retry_config.dart b/packages/fl_query/lib/src/collections/retry_config.dart new file mode 100644 index 0000000..7ec92ac --- /dev/null +++ b/packages/fl_query/lib/src/collections/retry_config.dart @@ -0,0 +1,55 @@ +import 'package:fl_query/src/collections/default_configs.dart'; +import 'package:fl_query/src/core/client.dart'; +import 'package:flutter/material.dart'; + +class RetryConfig { + final int maxRetries; + final Duration retryDelay; + final bool cancelWhenOffline; + + const RetryConfig({ + required this.maxRetries, + required this.retryDelay, + required this.cancelWhenOffline, + }); + + factory RetryConfig.withDefaults( + BuildContext context, { + int? maxRetries, + Duration? retryDelay, + }) { + return QueryClient.of(context).retryConfig.copyWith( + maxRetries: maxRetries, + retryDelay: retryDelay, + ); + } + + factory RetryConfig.withConstantDefaults({ + int? maxRetries, + Duration? retryDelay, + }) { + return DefaultConstants.retryConfig.copyWith( + maxRetries: maxRetries, + retryDelay: retryDelay, + ); + } + + RetryConfig copyWith({ + int? maxRetries, + Duration? retryDelay, + bool? cancelWhenOffline, + }) { + return RetryConfig( + maxRetries: maxRetries ?? this.maxRetries, + retryDelay: retryDelay ?? this.retryDelay, + cancelWhenOffline: cancelWhenOffline ?? this.cancelWhenOffline, + ); + } + + Map toJson() { + return { + 'maxRetries': maxRetries, + 'retryDelay': retryDelay.toString(), + }; + } +} diff --git a/packages/fl_query/lib/src/core/cache.dart b/packages/fl_query/lib/src/core/cache.dart new file mode 100644 index 0000000..c3dc1e8 --- /dev/null +++ b/packages/fl_query/lib/src/core/cache.dart @@ -0,0 +1,137 @@ +import 'dart:async'; + +import 'package:collection/collection.dart'; +import 'package:fl_query/src/core/client.dart'; +import 'package:fl_query/src/core/infinite_query.dart'; +import 'package:fl_query/src/core/mutation.dart'; +import 'package:fl_query/src/core/query.dart'; +import 'package:flutter/material.dart'; +import 'package:hive_flutter/hive_flutter.dart'; + +enum QueryCacheEventType { + addQuery, + addInfiniteQuery, + addMutation, + removeQuery, + removeInfiniteQuery, + removeMutation, +} + +/// A event triggered by the [QueryCache] cache modifications +@immutable +class QueryCacheEvent { + final QueryCacheEventType type; + final Object data; + + QueryCacheEvent(this.type, this.data); +} + +/// Cache for storing [Query], [InfiniteQuery] and [Mutation] objects +/// and triggering events when they are added or removed +/// +/// The cache can't be modified from outside directly +class QueryCache { + final Set _queries; + final Set _infiniteQueries; + final Set _mutations; + + final Duration cacheDuration; + + final StreamController _eventController; + + QueryCache({ + required this.cacheDuration, + }) : _queries = Set(), + _infiniteQueries = Set(), + _mutations = Set(), + _eventController = StreamController.broadcast() { + // Invalidate inactive queries and mutations every [cacheDuration] + Timer.periodic(cacheDuration, (timer) { + _queries.removeWhere((query) { + if (query.isInactive) { + _eventController.add( + QueryCacheEvent(QueryCacheEventType.removeQuery, query), + ); + } + return query.isInactive; + }); + _infiniteQueries.removeWhere((query) { + if (query.isInactive) { + _eventController.add( + QueryCacheEvent(QueryCacheEventType.removeInfiniteQuery, query), + ); + } + return query.isInactive; + }); + _mutations.removeWhere((mutation) { + if (mutation.isInactive) { + _eventController.add( + QueryCacheEvent(QueryCacheEventType.removeMutation, mutation), + ); + } + return mutation.isInactive; + }); + }); + } + + UnmodifiableSetView get queries => UnmodifiableSetView(_queries); + UnmodifiableSetView get infiniteQueries => + UnmodifiableSetView(_infiniteQueries); + UnmodifiableSetView get mutations => + UnmodifiableSetView(_mutations); + + Stream get events => _eventController.stream; + + void addQuery(Query query) { + _queries.add(query); + _eventController.add( + QueryCacheEvent(QueryCacheEventType.addQuery, query), + ); + } + + void addInfiniteQuery(InfiniteQuery query) { + _infiniteQueries.add(query); + _eventController.add( + QueryCacheEvent(QueryCacheEventType.addInfiniteQuery, query), + ); + } + + void removeQuery(Query query) { + _queries.remove(query); + _eventController.add( + QueryCacheEvent(QueryCacheEventType.removeQuery, query), + ); + } + + void removeInfiniteQuery(InfiniteQuery query) { + _infiniteQueries.remove(query); + _eventController.add( + QueryCacheEvent(QueryCacheEventType.removeInfiniteQuery, query), + ); + } + + void addMutation(Mutation mutation) { + _mutations.add(mutation); + _eventController.add( + QueryCacheEvent(QueryCacheEventType.addMutation, mutation), + ); + } + + void removeMutation(Mutation mutation) { + _mutations.remove(mutation); + _eventController.add( + QueryCacheEvent(QueryCacheEventType.removeMutation, mutation), + ); + } + + /// Clears everything from cache + void clear() { + _queries.clear(); + _infiniteQueries.clear(); + _mutations.clear(); + } + + LazyBox get queryHiveBox => Hive.lazyBox(QueryClient.queryCachePrefix); + LazyBox get infiniteQueryHiveBox => + Hive.lazyBox(QueryClient.infiniteQueryCachePrefix); +} diff --git a/packages/fl_query/lib/src/core/client.dart b/packages/fl_query/lib/src/core/client.dart new file mode 100644 index 0000000..44049ee --- /dev/null +++ b/packages/fl_query/lib/src/core/client.dart @@ -0,0 +1,532 @@ +import 'dart:async'; + +import 'package:collection/collection.dart'; +import 'package:fl_query/src/collections/connectivity_adapter.dart'; +import 'package:fl_query/src/collections/default_configs.dart'; +import 'package:fl_query/src/collections/json_config.dart'; +import 'package:fl_query/src/collections/refresh_config.dart'; +import 'package:fl_query/src/collections/retry_config.dart'; +import 'package:fl_query/src/core/cache.dart'; +import 'package:fl_query/src/core/infinite_query.dart'; +import 'package:fl_query/src/core/mutation.dart'; +import 'package:fl_query/src/core/provider.dart'; +import 'package:fl_query/src/core/query.dart'; +import 'package:flutter/material.dart'; +import 'package:hive_flutter/adapters.dart'; + +/// Base Client for managing [Query], [InfiniteQuery] and [Mutation] objects +/// and all related configuration +/// +/// [QueryClient] is the basic imperative API to handle and manage Queries and +/// Mutations and used internally by the Declarative wrapper widgets and hooks +/// +/// Usually, it can be helpful to use when only data modification is needed +/// without any UI changes e.g. after completing an action +/// +/// It can be accessed anywhere in the widget tree using [QueryClient.of] or +/// [QueryClient.maybeOf] +/// +/// ```dart +/// final queryClient = QueryClient.of(context); +/// +/// await queryClient.refreshQuery('todos'); +/// ``` +/// +/// If you don't have access to [BuildContext] e.g. in a [Provider] or [BLoC] +/// you can initialize your own [QueryClient] globally and pass it [QueryClientProvider] +/// and use it anywhere in the widget tree +/// +/// ```dart +/// final queryClient = QueryClient(); +/// +/// QueryClientProvider( +/// client: queryClient, +/// child: (....) +/// ) +/// +/// // Somewhere else in the project +/// import 'package:example/config/query_client.dart'; +/// +/// class TodoListNotifier extends ChangeNotifier { +/// void addTodo(Todo todo) async { +/// final res = post(api, todo); +/// +/// await queryClient.refreshQuery('todos'); +/// } +/// } +/// ``` +/// +/// * The above can be also implemented using just by [Mutation] + +@immutable +class QueryClient { + final QueryCache cache; + + final RetryConfig retryConfig; + final RefreshConfig refreshConfig; + final Duration cacheDuration; + + QueryClient({ + QueryCache? cache, + this.cacheDuration = DefaultConstants.cacheDuration, + int? maxRetries, + Duration? retryDelay, + Duration? staleDuration, + Duration? refreshInterval, + bool? refreshOnMount, + bool? refreshOnQueryFnChange, + }) : this.cache = cache ?? QueryCache(cacheDuration: cacheDuration), + this.retryConfig = DefaultConstants.retryConfig.copyWith( + maxRetries: maxRetries, + retryDelay: retryDelay, + ), + this.refreshConfig = DefaultConstants.refreshConfig.copyWith( + staleDuration: staleDuration, + refreshInterval: refreshInterval, + refreshOnMount: refreshOnMount, + refreshOnQueryFnChange: refreshOnQueryFnChange, + ); + + /// Imperatively creates a [Query] + /// + /// If a query with the same key already exists, it will be returned + /// and the properties will be updated (if changed) + Query createQuery( + String key, + QueryFn queryFn, { + DataType? initial, + RetryConfig? retryConfig, + RefreshConfig? refreshConfig, + JsonConfig? jsonConfig, + }) { + final query = cache.queries + .firstWhere( + (query) => query.key == key, + orElse: () => Query( + key, + queryFn, + initial: initial, + retryConfig: retryConfig ?? this.retryConfig, + refreshConfig: refreshConfig ?? this.refreshConfig, + jsonConfig: jsonConfig, + ), + ) + .cast(); + query.updateQueryFn(queryFn); + cache.addQuery(query); + return query; + } + + /// Creates + stores a [Query] and runs the [queryFn] immediately + /// and returns the result + /// + /// - If fails, returns with `null` + /// - If [Query] already exists, it'll run the [Query.fetch] anyway + Future fetchQuery( + String key, + QueryFn queryFn, { + DataType? initial, + RetryConfig? retryConfig, + RefreshConfig? refreshConfig, + JsonConfig? jsonConfig, + }) async { + try { + DataType? result; + final completer = Completer(); + final query = createQuery( + key, + queryFn, + initial: initial, + retryConfig: retryConfig, + refreshConfig: refreshConfig, + jsonConfig: jsonConfig, + ); + + final subscription = query.dataStream.listen((data) { + if (!completer.isCompleted) completer.complete(data); + }); + + final errorSubscription = query.errorStream.listen((error) { + if (!completer.isCompleted) + completer.completeError(error != null ? error : ""); + }); + + result = await query.fetch(); + result ??= await completer.future; + + errorSubscription.cancel(); + subscription.cancel(); + return result; + } catch (e) { + return null; + } + } + + /// Finds the [Query] with the given [key] and returns it + /// + /// [exact] can be used to match the key exactly or by prefix + Query? getQuery( + String key, { + bool exact = true, + }) { + return cache.queries + .firstWhereOrNull( + (query) => exact ? query.key == key : query.key.startsWith(key), + ) + ?.cast(); + } + + List getQueries(List keys) { + return cache.queries.where((query) => keys.contains(query.key)).toList(); + } + + /// Finds all the [Query] that starts with the given [prefix] + List getQueriesWithPrefix(String prefix) { + return cache.queries + .where((query) => query.key.startsWith(prefix)) + .toList(); + } + + /// Finds the [Query] with the given [key] and refreshes using [Query.refresh] + /// + /// [exact] can be used to match the key exactly or by prefix + Future refreshQuery( + String key, { + bool exact = true, + }) async { + final query = getQuery(key, exact: exact); + if (query == null) return null; + return await query.refresh(); + } + + Future refreshQueries(List keys) async { + final queries = getQueries(keys); + return await Future.wait(queries.map((query) => query.refresh())); + } + + /// Finds all the [Query] that starts with the given [prefix] + /// and refreshes + Future refreshQueriesWithPrefix(String prefix) async { + final queries = getQueriesWithPrefix(prefix); + return await Future.wait(queries.map((query) => query.refresh())); + } + + /// Creates + stores an [InfiniteQuery] + /// + /// If [InfinityQuery] already exists, it'll return the existing one + /// and update the configuration if changed + InfiniteQuery + createInfiniteQuery( + String key, + InfiniteQueryFn queryFn, { + required InfiniteQueryNextPage nextPage, + required PageType initialParam, + RetryConfig? retryConfig, + RefreshConfig? refreshConfig, + JsonConfig? jsonConfig, + }) { + final query = cache.infiniteQueries + .firstWhere( + (query) => query.key == key, + orElse: () => InfiniteQuery( + key, + queryFn, + nextPage: nextPage, + initialParam: initialParam, + retryConfig: retryConfig ?? this.retryConfig, + refreshConfig: refreshConfig ?? this.refreshConfig, + jsonConfig: jsonConfig, + ), + ) + .cast(); + query.updateQueryFn(queryFn); + query.updateNextPageFn(nextPage); + cache.addInfiniteQuery(query); + return query; + } + + /// Creates + stores an [InfiniteQuery] and fetches the first page + /// immediately and returns the result + /// + /// - If fails, returns with `null` + /// - If [InfiniteQuery] already exists, it'll run the [InfiniteQuery.fetch] anyway + Future fetchInfiniteQuery( + String key, + InfiniteQueryFn queryFn, { + required InfiniteQueryNextPage nextPage, + required PageType initialParam, + RetryConfig? retryConfig, + RefreshConfig? refreshConfig, + JsonConfig? jsonConfig, + }) async { + try { + DataType? result; + final completer = Completer(); + final query = createInfiniteQuery( + key, + queryFn, + nextPage: nextPage, + initialParam: initialParam, + retryConfig: retryConfig, + refreshConfig: refreshConfig, + jsonConfig: jsonConfig, + ); + + final subscription = query.dataStream.listen((event) { + if (!completer.isCompleted) completer.complete(event.data); + }); + + final errorSubscription = query.errorStream.listen((event) { + if (!completer.isCompleted) + completer.completeError(event.data != null ? event.data! : ""); + }); + + result = await query.fetch(); + result ??= await completer.future; + + errorSubscription.cancel(); + subscription.cancel(); + return result; + } catch (e) { + return null; + } + } + + /// Finds the [InfiniteQuery] with the given [key] + /// + /// [exact] can be used to match the key exactly or by prefix + InfiniteQuery? + getInfiniteQuery( + String key, { + bool exact = true, + }) { + return cache.infiniteQueries + .firstWhereOrNull( + (query) => exact ? query.key == key : query.key.startsWith(key)) + ?.cast(); + } + + List getInfiniteQueries(List keys) { + return cache.infiniteQueries + .where((query) => keys.contains(query.key)) + .toList(); + } + + /// Finds all the [InfiniteQuery] that starts with the given [prefix] + List getInfiniteQueriesWithPrefix(String prefix) { + return cache.infiniteQueries + .where((query) => query.key.startsWith(prefix)) + .toList(); + } + + /// Finds the [InfiniteQuery] with the given [key] and refreshes + /// using [InfiniteQuery.refresh] + /// + /// It'll return the refreshed data and will return `null` if fails + /// + /// - [exact] can be used to match the key exactly or by prefix + /// - [page] can be used to only refresh a specific page or else it'll + /// refresh the lastPage + /// + Future refreshInfiniteQuery( + String key, { + PageType? page, + bool exact = true, + }) async { + final query = + getInfiniteQuery(key, exact: exact); + if (query == null) return null; + return await query.refresh(page); + } + + /// Finds the [InfiniteQuery] with the given [key] and refreshes all pages + /// using [InfiniteQuery.refreshAll] + /// + /// It'll return the refreshed data and will return `null` if fails + /// + /// - [exact] can be used to match the key exactly or by prefix + Future?> + refreshInfiniteQueryAllPages( + String key, { + bool exact = true, + }) async { + final query = + getInfiniteQuery(key, exact: exact); + if (query == null) return []; + return await query.refreshAll(); + } + + Future refreshInfiniteQueries(List keys) async { + final queries = getInfiniteQueries(keys); + return await Future.wait(queries.map((query) => query.refresh())); + } + + /// Finds all the [InfiniteQuery] that starts with the given [prefix] + /// and refreshes using [InfiniteQuery.refresh] + /// + /// It'll return the refreshed data and will return `null` if fails + Future refreshInfiniteQueriesWithPrefix(String prefix) async { + final queries = getInfiniteQueriesWithPrefix(prefix); + return await Future.wait(queries.map((query) => query.refresh())); + } + + Future> refreshInfiniteQueriesAllPages( + List keys, + ) async { + final queries = getInfiniteQueries(keys); + return await Future.wait(queries.map( + (query) async => MapEntry(query.key, await query.refreshAll()))) + .then((qs) => Map.fromEntries(qs)); + } + + /// Finds all the [InfiniteQuery] that starts with the given [prefix] + /// and refreshes all pages using [InfiniteQuery.refreshAll] + /// + /// It returns a Map with the key as the matched query key and the value + /// as the refreshed data + /// + /// It'll return the refreshed data and will return `null` if fails + Future> refreshInfiniteQueriesAllPagesWithPrefix( + String prefix, + ) async { + final queries = getInfiniteQueriesWithPrefix(prefix); + return await Future.wait(queries.map( + (query) async => MapEntry(query.key, await query.refreshAll()))) + .then((qs) => Map.fromEntries(qs)); + } + + /// Creates a new [Mutation] + /// + /// If a [Mutation] with the same [key] already exists, it'll return the + /// existing [Mutation] and update the properties of the existing [Mutation] + Mutation + createMutation( + String key, + MutationFn mutationFn, { + RetryConfig? retryConfig, + }) { + final mutation = cache.mutations + .firstWhere( + (query) => query.key == key, + orElse: () => Mutation( + key, + mutationFn, + retryConfig: retryConfig ?? this.retryConfig, + ), + ) + .cast(); + + mutation.updateMutationFn(mutationFn); + cache.addMutation(mutation); + return mutation; + } + + /// Finds the [Mutation] with the given [key] and runs [Mutation.mutate] + /// + /// It'll return the mutation result and will return `null` if fails + /// + /// Optionally takes an [mutationFn] to override the existing [mutationFn] + /// or create a completely new [Mutation] if doesn't exist + /// Same situation for [retryConfig] + /// + /// - [refreshQueries] can be used to refresh queries after mutation + /// - [refreshInfiniteQueries] can be used to refresh infinite queries + /// after mutation + Future mutateMutation( + String key, + VariablesType variables, { + MutationFn? mutationFn, + RetryConfig? retryConfig, + List refreshQueries = const [], + List refreshInfiniteQueries = const [], + }) async { + try { + DataType? result; + final completer = Completer(); + final mutation = getMutation( + key, + ) ?? + (mutationFn != null + ? createMutation( + key, + mutationFn, + retryConfig: retryConfig, + ) + : null); + + final subscription = mutation?.dataStream.listen((data) { + if (!completer.isCompleted) completer.complete(data); + }); + + final errorSubscription = mutation?.errorStream.listen((error) { + if (!completer.isCompleted) + completer.completeError(error != null ? error : ""); + }); + + result = await mutation?.mutate(variables); + result ??= await completer.future; + + errorSubscription?.cancel(); + subscription?.cancel(); + + await this.refreshQueries(refreshQueries); + await refreshInfiniteQueriesAllPages(refreshInfiniteQueries); + return result; + } catch (e) { + return null; + } + } + + /// Finds the [Mutation] + /// + /// - [exact] can be used to match the key exactly or by prefix + Mutation? + getMutation( + String key, { + bool exact = true, + }) { + return cache.mutations + .firstWhereOrNull( + (query) => exact ? query.key == key : query.key.startsWith(key)) + ?.cast(); + } + + /// Gets the [QueryClient] from the [BuildContext] if available + /// + /// This can throw an error if the [QueryClient] is not available + static QueryClient of(BuildContext context) { + return context + .dependOnInheritedWidgetOfExactType()! + .client; + } + + /// Gets the [QueryClient] from the [BuildContext] if available + static QueryClient? maybeOf(BuildContext context) { + return context + .dependOnInheritedWidgetOfExactType() + ?.client; + } + + static String _cachePrefix = 'fl_query'; + + static String get queryCachePrefix => '$_cachePrefix.cache.queries'; + static String get infiniteQueryCachePrefix => + '$_cachePrefix.cache.infinite_queries'; + + static late final ConnectivityAdapter connectivity; + + /// Initializes the [QueryClient] + /// + /// This sets up all [Hive] boxes and cache directories + static Future initialize({ + required String cachePrefix, + ConnectivityAdapter? connectivity, + String? cacheDir, + }) async { + QueryClient.connectivity = connectivity ?? NoOpConnectivityAdapter(); + await Hive.initFlutter(cacheDir); + _cachePrefix = cachePrefix; + await Hive.openLazyBox(queryCachePrefix); + await Hive.openLazyBox(infiniteQueryCachePrefix); + } +} diff --git a/packages/fl_query/lib/src/core/infinite_query.dart b/packages/fl_query/lib/src/core/infinite_query.dart new file mode 100644 index 0000000..adbbac7 --- /dev/null +++ b/packages/fl_query/lib/src/core/infinite_query.dart @@ -0,0 +1,542 @@ +import 'dart:async'; + +import 'package:async/async.dart'; +import 'package:collection/collection.dart'; +import 'package:fl_query/src/collections/json_config.dart'; +import 'package:fl_query/src/collections/refresh_config.dart'; +import 'package:fl_query/src/collections/retry_config.dart'; +import 'package:fl_query/src/core/client.dart'; +import 'package:fl_query/src/core/mixins/retryer.dart'; +import 'package:fl_query/src/core/mixins/validation.dart'; +import 'package:fl_query/src/widgets/state_resolvers/infinite_query_state.dart'; +import 'package:flutter/widgets.dart' hide Listener; +import 'package:hive_flutter/adapters.dart'; +import 'package:mutex/mutex.dart'; +import 'package:state_notifier/state_notifier.dart'; + +typedef InfiniteQueryFn = FutureOr Function( + PageType page); +typedef InfiniteQueryNextPage = PageType? Function( + PageType lastPage, + DataType lastPageData, +); + +/// A page holding all the data for a given page +class InfiniteQueryPage with Invalidation { + final PageType page; + final DataType? data; + final ErrorType? error; + + final DateTime updatedAt; + final Duration staleDuration; + + final bool _loading; + + const InfiniteQueryPage({ + required this.page, + this.data, + this.error, + required this.updatedAt, + required this.staleDuration, + bool loading = false, + }) : _loading = loading; + + InfiniteQueryPage copyWith({ + DataType? data, + ErrorType? error, + bool? loading, + }) { + return InfiniteQueryPage( + page: page, + updatedAt: DateTime.now(), + staleDuration: staleDuration, + data: data ?? this.data, + error: error ?? this.error, + loading: loading ?? _loading, + ); + } + + @override + bool operator ==(Object other) { + if (identical(this, other)) return true; + + return other is InfiniteQueryPage && + other.page == page; + } + + @override + int get hashCode => page.hashCode; +} + +class InfiniteQueryState { + final Set> pages; + + InfiniteQueryState({ + required this.pages, + }); + + PageType get lastPage { + final fetchedPages = + pages.whereNot((e) => e.data == null && e.error == null); + + if (fetchedPages.isEmpty && pages.length == 1) { + return pages.last.page; + } + + return fetchedPages.last.page; + } + + InfiniteQueryState copyWith( + {Set>? pages}) { + return InfiniteQueryState( + pages: pages ?? this.pages, + ); + } +} + +/// Event fired with data and error by the [InfiniteQuery] fetchPage operation +@immutable +class PageEvent { + final P page; + final T data; + const PageEvent(this.page, this.data); + + factory PageEvent.fromPage( + InfiniteQueryPage page, + ) { + return PageEvent(page.page as P, page.data as T); + } +} + +/// A specialized Query that can retrieve + hold paginated/segmented data +/// +/// - [nextPage] provides the next page param for fetching +/// - [initialParam] provides the initial page param for fetching +/// +/// Use the [InfiniteQueryBuilder] create and use an [InfiniteQuery] +class InfiniteQuery + extends StateNotifier> + with Retryer { + final String key; + final RetryConfig retryConfig; + final RefreshConfig refreshConfig; + final JsonConfig? jsonConfig; + + final PageType _initialParam; + + InfiniteQueryFn _queryFn; + InfiniteQueryNextPage _nextPage; + + InfiniteQuery( + this.key, + InfiniteQueryFn queryFn, { + required InfiniteQueryNextPage nextPage, + required PageType initialParam, + required this.retryConfig, + required this.refreshConfig, + this.jsonConfig, + }) : _initialParam = initialParam, + _dataController = StreamController.broadcast(), + _errorController = StreamController.broadcast(), + _box = Hive.lazyBox(QueryClient.infiniteQueryCachePrefix), + _queryFn = queryFn, + _nextPage = nextPage, + super(InfiniteQueryState( + pages: { + InfiniteQueryPage( + page: initialParam, + updatedAt: DateTime.now(), + staleDuration: refreshConfig.staleDuration, + ), + }, + )) { + if (jsonConfig != null) { + _mutex.protect(() async { + final Map? json = await _box.get(key); + if (json != null) { + state = state.copyWith( + pages: json.entries + .map( + (entry) => InfiniteQueryPage( + page: entry.key as PageType, + data: jsonConfig!.fromJson( + Map.castFrom( + entry.value, + )), + // this makes the page loaded from cache `stale` + updatedAt: + DateTime.now().subtract(refreshConfig.staleDuration), + staleDuration: refreshConfig.staleDuration, + ), + ) + .toSet(), + ); + } + }).then((_) { + if (hasListeners) { + return fetch(); + } + }); + } + if (refreshConfig.refreshInterval > Duration.zero) + Timer.periodic(refreshConfig.refreshInterval, (_) async { + await Future.wait( + state.pages.map((page) async { + if (page.isStale) { + return await refresh(page.page); + } + }), + ); + }); + + // Listen to network changes and cancel any ongoing operations + + bool wasConnected = true; + _connectivitySubscription = QueryClient.connectivity.onConnectivityChanged + .listen((isConnected) async { + try { + if (isConnected && + !wasConnected && + refreshConfig.refreshOnNetworkStateChange) { + for (final page in state.pages) { + if (page.isStale) { + await refresh(page.page); + } + } + } else if (!isConnected && + _mutex.isLocked && + retryConfig.cancelWhenOffline) { + await _operation?.cancel(); + } + } finally { + wasConnected = isConnected; + } + }); + } + + final _mutex = Mutex(); + final LazyBox _box; + final StreamController> _dataController; + final StreamController> _errorController; + StreamSubscription? _connectivitySubscription; + + CancelableOperation? _operation; + + /// All the pages that has been successfully fetched + List get pages => + state.pages.map((e) => e.data).whereType().toList(); + + /// All the errors of pages that has failed to fetch + List get errors => + state.pages.map((e) => e.error).whereType().toList(); + + /// The last page that has been fetched + PageType get lastPage => state.lastPage; + + /// Stream of data events + /// + /// Subscribe to it to get notified when a page data is + /// fetched/refreshed/retried + Stream> get dataStream => + _dataController.stream; + + /// Stream of error events + /// + /// Subscribe to it to get notified when a page has failed + Stream> get errorStream => + _errorController.stream; + + /// The next page param that will be used to fetch the next page + PageType? get getNextPage { + final lastPageData = state.pages + .firstWhereOrNull((e) => e.data is DataType && e.page == lastPage) + ?.data; + + if (lastPageData == null) return null; + + return _nextPage(lastPage, lastPageData); + } + + bool get isLoadingNextPage { + final nextPage = state.pages.firstWhereOrNull((p) => p.page == getNextPage); + return nextPage?._loading == true; + } + + bool get isRefreshingPage { + final currentPage = state.pages.firstWhereOrNull((p) => p.page == lastPage); + return currentPage?._loading == true; + } + + bool get isInactive => !hasListeners; + + bool get hasPages => pages.isNotEmpty; + bool get hasErrors => errors.isNotEmpty; + + bool get hasPageData => !hasPages ? false : state.pages.last.data != null; + bool get hasPageError => !hasPages ? false : state.pages.last.error != null; + + bool get hasNextPage => getNextPage != null; + + Future _operate(PageType page) async { + if (!await QueryClient.connectivity.isConnected && + retryConfig.cancelWhenOffline) { + return; + } + return _mutex.protect(() async { + final storedPage = state.pages.firstWhere( + (e) => e.page == page, + orElse: () => InfiniteQueryPage( + page: page, + updatedAt: DateTime.now(), + staleDuration: refreshConfig.staleDuration, + loading: true, + ), + ); + state = state.copyWith( + pages: { + ...state.pages..remove(storedPage), + storedPage, + }, + ); + _operation = cancellableRetryOperation( + () => _queryFn(page), + config: retryConfig, + onSuccessful: (data) async { + final dataPage = + storedPage.copyWith(data: data, error: null, loading: false); + state = state.copyWith( + pages: {...state.pages..remove(dataPage), dataPage}, + ); + if (dataPage.data is DataType) { + _dataController.add(PageEvent.fromPage(dataPage)); + if (jsonConfig != null) { + await _box.put( + key, + Map.fromEntries( + state.pages.map( + (e) => MapEntry( + e.page, + e.data != null ? jsonConfig!.toJson(e.data!) : null, + ), + ), + ), + ); + } + } + }, + onFailed: (error) { + final errorPage = storedPage.copyWith(error: error, loading: false); + state = state.copyWith( + pages: { + ...state.pages..remove(errorPage), + errorPage, + }, + ); + if (errorPage.error is ErrorType) + _errorController.add(PageEvent.fromPage(errorPage)); + }, + ); + }); + } + + /// Fetch current non-fetched page + /// + /// If page is already done fetching. It'll simply returns the old data + Future fetch() async { + final lastPage = state.lastPage; + if (_mutex.isLocked || hasPageData || hasPageError) + return state.pages.last.data; + return await _operate(lastPage).then((_) => state.pages.last.data); + } + + /// Refresh a page that has or has not been fetched + /// + /// - [page] The page to refresh. If null, it'll refresh the last page + Future refresh([PageType? page]) async { + page ??= lastPage; + if (_mutex.isLocked) + return state.pages.firstWhereOrNull((e) => e.page == page)?.data; + return await _operate(page!).then((_) { + return state.pages.firstWhereOrNull((e) => e.page == page)?.data; + }); + } + + /// Refresh all the pages that has been fetched + Future?> refreshAll() async { + if (_mutex.isLocked) return pages; + return await Future.wait( + state.pages.map((e) => _operate(e.page)), + ).then((_) => pages); + } + + /// Fetch the next page + /// + /// If there's no next page, it'll simply return the last page data + Future fetchNext() async { + final nextPage = getNextPage; + if (_mutex.isLocked || nextPage == null) { + return state.pages.lastOrNull?.data; + } + return await _operate(nextPage).then((_) { + return state.pages.firstWhereOrNull((e) => e.page == nextPage)?.data; + }); + } + + /// Replace the currently [queryFn] with new [queryFn] + /// + /// This is internally used to update queryFn when external data + /// has changed. Used by [InfiniteQueryBuilder] and [QueryClient] + /// + /// This can also refresh if [RefreshConfig.refreshOnQueryFnChange] is true + void updateQueryFn(InfiniteQueryFn queryFn) { + if (_queryFn == queryFn) return; + _queryFn = queryFn; + if (refreshConfig.refreshOnQueryFnChange) { + refreshAll(); + } else { + Future.wait( + state.pages.map((page) async { + if (page.isStale && page.error == null) { + return await refresh(page.page); + } + }), + ); + } + } + + /// Replace the currently [nextPage] with new [nextPage] + void updateNextPageFn(InfiniteQueryNextPage nextPage) { + if (_nextPage == nextPage) return; + _nextPage = nextPage; + } + + /// Manually set the data of a page + /// + /// If there's no page with the given [page], it'll create a new page + /// and set the data as the given [data] + /// + /// The new page will be added to the end of the list so it becomes [lastPage] + void setPageData(PageType page, DataType data) { + final newPage = state.pages + .firstWhere( + (e) => e.page == page, + orElse: () => InfiniteQueryPage( + page: page, + updatedAt: DateTime.now(), + staleDuration: refreshConfig.staleDuration, + ), + ) + .copyWith(data: data, loading: false); + + state = state.copyWith( + pages: { + ...state.pages..remove(newPage), + newPage, + }, + ); + } + + Widget resolve( + Widget Function(List data) data, { + required Widget Function(List errors) error, + required Widget Function() loading, + Widget Function()? offline, + }) { + if (hasPages) { + return data(this.pages); + } else if (!QueryClient.connectivity.isConnectedSync) { + return offline != null ? offline() : loading(); + } else if (hasErrors) { + return error(this.errors); + } else { + return loading(); + } + } + + Widget resolveWith( + BuildContext context, + Widget Function(List data) data, { + required Widget Function(List error)? error, + required Widget Function()? loading, + Widget Function()? offline, + }) { + final resolvents = InfiniteQueryStateResolverProvider.of(context); + + assert( + resolvents.error != null || error != null, + 'You must provide an error widget or an error resolver using `InfiniteQueryStateResolverProvider`', + ); + + assert( + resolvents.loading != null || loading != null, + 'You must provide a loading widget or a loading resolver using `InfiniteQueryStateResolverProvider`', + ); + + return resolve( + data, + error: resolvents.error != null + ? (e) => resolvents.error!(e.cast()) + : error!, + loading: (resolvents.loading ?? loading)!, + offline: resolvents.offline ?? offline, + ); + } + + /// Reset all data, pages, error, events of this query + /// + /// This will also remove every data of this [InfiniteQuery] from + /// persistent cache + Future reset() async { + await _operation?.cancel(); + state = state.copyWith(pages: { + InfiniteQueryPage( + page: _initialParam, + updatedAt: DateTime.now(), + staleDuration: refreshConfig.staleDuration, + ) + }); + _box.delete(key); + } + + @override + RemoveListener addListener( + Listener> listener, { + bool fireImmediately = true, + }) { + Future.microtask(() async { + if (refreshConfig.refreshOnMount) { + await refreshAll(); + } else { + await Future.wait( + state.pages.map((page) async { + if (page.isStale) { + return await refresh(page.page); + } + }), + ); + } + }); + return super.addListener(listener, fireImmediately: fireImmediately); + } + + @override + void dispose() { + _operation?.cancel(); + _connectivitySubscription?.cancel(); + _errorController.close(); + _dataController.close(); + super.dispose(); + } + + @override + operator ==(Object other) => + identical(this, other) || other is InfiniteQuery && key == other.key; + + @override + int get hashCode => key.hashCode; + + InfiniteQuery + cast() { + return this as InfiniteQuery; + } +} diff --git a/packages/fl_query/lib/src/core/mixins/retryer.dart b/packages/fl_query/lib/src/core/mixins/retryer.dart new file mode 100644 index 0000000..c3bcc58 --- /dev/null +++ b/packages/fl_query/lib/src/core/mixins/retryer.dart @@ -0,0 +1,58 @@ +import 'dart:async'; + +import 'package:async/async.dart'; +import 'package:fl_query/src/collections/retry_config.dart'; +import 'package:flutter/material.dart'; + +mixin Retryer { + Future retryOperation( + FutureOr Function() operation, { + required RetryConfig config, + required void Function(T?) onSuccessful, + required void Function(E?) onFailed, + }) async { + for (int attempts = 0; attempts < config.maxRetries; attempts++) { + final completer = Completer(); + await Future.delayed( + attempts == 0 ? Duration.zero : config.retryDelay, + operation, + ).then(completer.complete).catchError(completer.completeError); + try { + final result = await completer.future; + onSuccessful(result); + break; + } catch (e, stack) { + if (e is E?) { + if (attempts == config.maxRetries - 1) { + onFailed(e as E?); + } + } else { + FlutterError.reportError( + FlutterErrorDetails( + exception: e, + library: 'fl_query', + context: ErrorDescription('retryOperation'), + stack: stack, + ), + ); + } + } + } + } + + CancelableOperation cancellableRetryOperation( + FutureOr Function() operation, { + required RetryConfig config, + required void Function(T?) onSuccessful, + required void Function(E?) onFailed, + }) { + return CancelableOperation.fromFuture( + retryOperation( + operation, + config: config, + onSuccessful: onSuccessful, + onFailed: onFailed, + ), + ); + } +} diff --git a/packages/fl_query/lib/src/core/mixins/validation.dart b/packages/fl_query/lib/src/core/mixins/validation.dart new file mode 100644 index 0000000..253aa17 --- /dev/null +++ b/packages/fl_query/lib/src/core/mixins/validation.dart @@ -0,0 +1,6 @@ +mixin Invalidation { + DateTime get updatedAt; + Duration get staleDuration; + + bool get isStale => DateTime.now().difference(updatedAt) > staleDuration; +} diff --git a/packages/fl_query/lib/src/core/mutation.dart b/packages/fl_query/lib/src/core/mutation.dart new file mode 100644 index 0000000..c9bc817 --- /dev/null +++ b/packages/fl_query/lib/src/core/mutation.dart @@ -0,0 +1,220 @@ +import 'dart:async'; + +import 'package:async/async.dart'; +import 'package:fl_query/src/collections/retry_config.dart'; +import 'package:fl_query/src/core/client.dart'; +import 'package:fl_query/src/core/mixins/retryer.dart'; +import 'package:fl_query/src/widgets/state_resolvers/mutation_state.dart'; +import 'package:flutter/widgets.dart'; +import 'package:mutex/mutex.dart'; +import 'package:state_notifier/state_notifier.dart'; + +typedef MutationFn = Future Function( + VariablesType variables, +); + +class MutationState { + final DataType? data; + final ErrorType? error; + final bool _loading; + final DateTime updatedAt; + + MutationState({ + this.data, + this.error, + bool loading = false, + DateTime? updatedAt, + }) : _loading = loading, + updatedAt = updatedAt ?? DateTime.now(); + + MutationState copyWith({ + DataType? data, + ErrorType? error, + DateTime? updatedAt, + bool? loading, + }) { + return MutationState( + data: data ?? this.data, + error: error ?? this.error, + loading: loading ?? this._loading, + updatedAt: updatedAt ?? DateTime.now(), + ); + } +} + +class Mutation + extends StateNotifier> + with Retryer { + final String key; + + final RetryConfig retryConfig; + + MutationFn _mutationFn; + + Mutation( + this.key, + MutationFn mutationFn, { + required this.retryConfig, + }) : _dataController = StreamController.broadcast(), + _errorController = StreamController.broadcast(), + _mutationController = StreamController.broadcast(), + _mutationFn = mutationFn, + super(MutationState()) { + // Listen to network changes and cancel any ongoing operations + bool wasConnected = true; + _connectivitySubscription = QueryClient.connectivity.onConnectivityChanged + .listen((isConnected) async { + try { + if (!isConnected && + wasConnected && + _mutex.isLocked && + retryConfig.cancelWhenOffline) { + await _operation?.cancel(); + } + } finally { + wasConnected = isConnected; + } + }); + } + + final _mutex = Mutex(); + final StreamController _mutationController; + final StreamController _dataController; + final StreamController _errorController; + CancelableOperation? _operation; + late final StreamSubscription? _connectivitySubscription; + + bool get isInactive => !hasListeners; + bool get isMutating => state._loading; + bool get hasData => state.data != null; + bool get hasError => state.error != null; + + DataType? get data => state.data; + ErrorType? get error => state.error; + Stream get dataStream => _dataController.stream; + Stream get errorStream => _errorController.stream; + Stream get mutationStream => _mutationController.stream; + + Future _operate(VariablesType variables) async { + if (!await QueryClient.connectivity.isConnected && + retryConfig.cancelWhenOffline) { + return; + } + return _mutex.protect(() async { + state = state.copyWith(loading: true); + _operation = cancellableRetryOperation( + () { + _mutationController.add(variables); + return _mutationFn(variables); + }, + config: retryConfig, + onSuccessful: (data) { + state = state.copyWith(data: data, loading: false); + if (data is DataType) { + _dataController.add(data); + } + }, + onFailed: (error) { + state = state.copyWith(error: error, loading: false); + if (error is ErrorType) { + _errorController.add(error); + } + }, + ); + }); + } + + Future mutate( + VariablesType variables, { + bool scheduleToQueue = false, + }) { + if (isMutating && !scheduleToQueue) { + return Future.value(state.data); + } + return _operate(variables).then((_) => data); + } + + void updateMutationFn(MutationFn mutationFn) { + if (mutationFn == _mutationFn) return; + _mutationFn = mutationFn; + } + + Widget resolve( + Widget Function(DataType data) data, { + required Widget Function(ErrorType error) error, + required Widget Function() loading, + Widget Function()? mutating, + Widget Function()? offline, + }) { + if (hasData) { + return data(this.data!); + } else if (!QueryClient.connectivity.isConnectedSync) { + return offline != null ? offline() : loading(); + } else if (isMutating) { + return mutating != null ? mutating() : loading(); + } else if (hasError) { + return error(this.error!); + } else { + return loading(); + } + } + + Widget resolveWith( + BuildContext context, + Widget Function(DataType data) data, { + required Widget Function(ErrorType error)? error, + required Widget Function()? loading, + Widget Function()? offline, + Widget Function()? mutating, + }) { + final resolvents = MutationStateResolverProvider.of(context); + + assert( + resolvents.error != null || error != null, + 'You must provide an error widget or an error resolver using `MutationStateResolverProvider`', + ); + + assert( + resolvents.loading != null || loading != null, + 'You must provide a loading widget or a loading resolver using `MutationStateResolverProvider`', + ); + + return resolve( + data, + error: resolvents.error != null + ? (e) => resolvents.error!(e as dynamic) + : error!, + loading: (resolvents.loading ?? loading)!, + offline: resolvents.offline ?? offline, + mutating: resolvents.mutating ?? mutating, + ); + } + + Future reset() async { + await _operation?.cancel(); + state = MutationState(); + } + + @override + void dispose() { + _operation?.cancel(); + _connectivitySubscription?.cancel(); + _dataController.close(); + _errorController.close(); + _mutationController.close(); + super.dispose(); + } + + @override + operator ==(Object other) { + return identical(this, other) || (other is Mutation && key == other.key); + } + + @override + int get hashCode => key.hashCode; + + Mutation + cast() { + return this as Mutation; + } +} diff --git a/packages/fl_query/lib/src/core/provider.dart b/packages/fl_query/lib/src/core/provider.dart new file mode 100644 index 0000000..93f46e7 --- /dev/null +++ b/packages/fl_query/lib/src/core/provider.dart @@ -0,0 +1,78 @@ +import 'package:fl_query/src/collections/default_configs.dart'; +import 'package:fl_query/src/core/cache.dart'; +import 'package:fl_query/src/core/client.dart'; +import 'package:flutter/foundation.dart'; +import 'package:flutter/material.dart'; + +class QueryClientProvider extends InheritedWidget { + final QueryClient client; + QueryClientProvider({ + super.key, + required super.child, + QueryClient? client, + QueryCache? cache, + Duration cacheDuration = DefaultConstants.cacheDuration, + int? maxRetries, + Duration? retryDelay, + Duration? staleDuration, + Duration? refreshInterval, + bool? refreshOnMount, + bool? refreshOnQueryFnChange, + }) : assert( + (client == null && cache != null) || cache == null, + '[QueryClientProvider] no `client` must be provided when supplying `cache`', + ), + assert( + (client == null && maxRetries != null) || maxRetries == null, + '[QueryClientProvider] no `client` must be provided when supplying `maxRetries`', + ), + assert( + (client == null && retryDelay != null) || retryDelay == null, + '[QueryClientProvider] no `client` must be provided when supplying `retryDelay`', + ), + assert( + (client == null && staleDuration != null) || staleDuration == null, + '[QueryClientProvider] no `client` must be provided when supplying `staleDuration`', + ), + assert( + (client == null && refreshInterval != null) || + refreshInterval == null, + '[QueryClientProvider] no `client` must be provided when supplying `refreshInterval`', + ), + assert( + (client == null && refreshOnMount != null) || refreshOnMount == null, + '[QueryClientProvider] no `client` must be provided when supplying `refreshOnMount`', + ), + assert( + (client == null && refreshOnQueryFnChange != null) || + refreshOnQueryFnChange == null, + '[QueryClientProvider] no `client` must be provided when supplying `refreshOnQueryFnChange`', + ), + assert( + (client == null && cacheDuration != DefaultConstants.cacheDuration) || + cacheDuration == DefaultConstants.cacheDuration, + '[QueryClientProvider] no `client` must be provided when supplying `cacheDuration`', + ), + client = client ?? + QueryClient( + cache: cache, + cacheDuration: cacheDuration, + maxRetries: maxRetries, + retryDelay: retryDelay, + staleDuration: staleDuration, + refreshInterval: refreshInterval, + refreshOnMount: refreshOnMount, + refreshOnQueryFnChange: refreshOnQueryFnChange, + ); + + @override + bool updateShouldNotify(covariant QueryClientProvider oldWidget) { + return client != oldWidget.client; + } + + @override + void debugFillProperties(DiagnosticPropertiesBuilder properties) { + super.debugFillProperties(properties); + properties.add(DiagnosticsProperty('client', client)); + } +} diff --git a/packages/fl_query/lib/src/core/query.dart b/packages/fl_query/lib/src/core/query.dart new file mode 100644 index 0000000..91a2762 --- /dev/null +++ b/packages/fl_query/lib/src/core/query.dart @@ -0,0 +1,300 @@ +import 'dart:async'; + +import 'package:fl_query/src/collections/json_config.dart'; +import 'package:fl_query/src/collections/refresh_config.dart'; +import 'package:fl_query/src/collections/retry_config.dart'; +import 'package:fl_query/src/core/client.dart'; +import 'package:fl_query/src/core/mixins/retryer.dart'; +import 'package:fl_query/src/core/mixins/validation.dart'; +import 'package:fl_query/src/widgets/state_resolvers/query_state.dart'; +import 'package:flutter/widgets.dart' hide Listener; +import 'package:hive_flutter/adapters.dart'; +import 'package:mutex/mutex.dart'; +import 'package:state_notifier/state_notifier.dart'; +import 'package:async/async.dart'; + +typedef QueryFn = FutureOr Function(); + +class QueryState with Invalidation { + final DataType? data; + final ErrorType? error; + final DateTime updatedAt; + final Duration staleDuration; + + final bool _loading; + + const QueryState({ + this.data, + this.error, + required this.updatedAt, + required this.staleDuration, + bool loading = false, + }) : _loading = loading; + + QueryState copyWith({ + DataType? data, + ErrorType? error, + DateTime? updatedAt, + bool? loading, + }) { + return QueryState( + updatedAt: updatedAt ?? this.updatedAt, + staleDuration: staleDuration, + data: data ?? this.data, + error: error ?? this.error, + loading: loading ?? this._loading, + ); + } +} + +class Query + extends StateNotifier> + with Retryer { + final String key; + + final RefreshConfig refreshConfig; + final RetryConfig retryConfig; + final JsonConfig? jsonConfig; + + QueryFn _queryFn; + + Query( + this.key, + QueryFn queryFn, { + DataType? initial, + required this.retryConfig, + required this.refreshConfig, + this.jsonConfig, + }) : _box = Hive.lazyBox(QueryClient.queryCachePrefix), + _dataController = StreamController.broadcast(), + _errorController = StreamController.broadcast(), + _initial = initial, + _queryFn = queryFn, + super(QueryState( + updatedAt: DateTime.now(), + staleDuration: refreshConfig.staleDuration, + data: initial, + )) { + if (jsonConfig != null) { + _mutex.protect(() async { + final json = await _box.get(key); + if (json != null) { + _initial = jsonConfig!.fromJson( + Map.castFrom(json), + ); + state = state.copyWith(data: _initial, updatedAt: DateTime.now()); + } + }).then((_) { + if (hasListeners) { + return fetch(); + } + }); + } else { + _initial = initial; + } + + if (refreshConfig.refreshInterval > Duration.zero) + Timer.periodic(refreshConfig.refreshInterval, (_) async { + if (state.isStale) { + await refresh(); + } + }); + + // Listen to network changes and cancel any ongoing operations + + bool wasConnected = true; + _connectivitySubscription = QueryClient.connectivity.onConnectivityChanged + .listen((isConnected) async { + try { + if (isConnected && + !wasConnected && + state.isStale && + refreshConfig.refreshOnNetworkStateChange) { + await refresh(); + } else if (!isConnected && + _mutex.isLocked && + retryConfig.cancelWhenOffline) { + await _operation?.cancel(); + } + } finally { + wasConnected = isConnected; + } + }); + } + + DataType? _initial; + final LazyBox _box; + final _mutex = Mutex(); + final StreamController _dataController; + final StreamController _errorController; + StreamSubscription? _connectivitySubscription; + + bool get isInitial => hasData && state.data == _initial; + bool get isLoading => + (isInitial && !hasError && state._loading) || + (!hasData && !hasError && state._loading); + bool get isRefreshing => + ((!isInitial && hasData) || hasError) && state._loading; + bool get isInactive => !hasListeners; + bool get hasData => state.data != null; + bool get hasError => state.error != null; + + DataType? get data => state.data; + ErrorType? get error => state.error; + Stream get dataStream => _dataController.stream; + Stream get errorStream => _errorController.stream; + + CancelableOperation? _operation; + + Future _operate() async { + if (!await QueryClient.connectivity.isConnected && + retryConfig.cancelWhenOffline) { + return; + } + return _mutex.protect(() async { + state = state.copyWith(loading: true); + _operation = cancellableRetryOperation( + _queryFn, + config: retryConfig, + onSuccessful: (DataType? data) { + state = state.copyWith( + data: data, + error: null, + updatedAt: DateTime.now(), + loading: false, + ); + if (data is DataType) { + _dataController.add(data); + if (jsonConfig != null) { + _box.put( + key, + jsonConfig!.toJson(data), + ); + } + } + }, + onFailed: (ErrorType? error) { + state = state.copyWith( + error: error, + updatedAt: DateTime.now(), + loading: false, + ); + if (error is ErrorType) _errorController.add(error); + }, + ); + }); + } + + Future fetch() async { + if (_mutex.isLocked || (hasData && !isInitial) || hasError) + return state.data; + return _operate().then((_) => state.data); + } + + Future refresh() async { + if (_mutex.isLocked) return state.data; + return _operate().then((_) => state.data); + } + + void updateQueryFn(QueryFn queryFn) { + if (_queryFn == queryFn) return; + _queryFn = queryFn; + if ((state.isStale && !hasError) || refreshConfig.refreshOnQueryFnChange) { + refresh(); + } + } + + void setData(DataType data) { + state = state.copyWith( + data: data, + updatedAt: DateTime.now(), + loading: false, + ); + } + + Future reset() async { + await _operation?.cancel(); + state = state.copyWith( + data: _initial, + updatedAt: DateTime.now(), + loading: false, + ); + _box.delete(key); + } + + Widget resolve( + Widget Function(DataType data) data, { + required Widget Function(ErrorType data) error, + required Widget Function() loading, + Widget Function()? offline, + }) { + if (hasData) { + return data(this.data!); + } else if (!QueryClient.connectivity.isConnectedSync) { + return offline != null ? offline() : loading(); + } else if (hasError) { + return error(this.error!); + } else { + return loading(); + } + } + + Widget resolveWith( + BuildContext context, + Widget Function(DataType data) data, { + required Widget Function(ErrorType error)? error, + required Widget Function()? loading, + Widget Function()? offline, + }) { + final resolvents = QueryStateResolverProvider.of(context); + + assert( + resolvents.error != null || error != null, + 'You must provide an error widget or an error resolver using `QueryStateResolverProvider`', + ); + + assert( + resolvents.loading != null || loading != null, + 'You must provide a loading widget or a loading resolver using `QueryStateResolverProvider`', + ); + + return resolve( + data, + error: resolvents.error != null + ? (e) => resolvents.error!(e as dynamic) + : error!, + loading: (resolvents.loading ?? loading)!, + offline: resolvents.offline ?? offline, + ); + } + + @override + RemoveListener addListener(Listener> listener, + {bool fireImmediately = true}) { + if (state.isStale || refreshConfig.refreshOnMount) { + refresh(); + } + return super.addListener(listener, fireImmediately: fireImmediately); + } + + @override + void dispose() { + _operation?.cancel(); + _connectivitySubscription?.cancel(); + _dataController.close(); + _errorController.close(); + super.dispose(); + } + + @override + operator ==(Object other) { + return identical(this, other) || (other is Query && key == other.key); + } + + @override + int get hashCode => key.hashCode; + + Query cast() { + return this as Query; + } +} diff --git a/packages/fl_query/lib/src/infinite_query.dart b/packages/fl_query/lib/src/infinite_query.dart deleted file mode 100644 index 3fcf398..0000000 --- a/packages/fl_query/lib/src/infinite_query.dart +++ /dev/null @@ -1,327 +0,0 @@ -import 'dart:async'; -import 'dart:convert'; - -import 'package:connectivity_plus/connectivity_plus.dart'; -import 'package:fl_query/fl_query.dart'; -import 'package:fl_query/src/base_query.dart'; -import 'package:flutter/cupertino.dart'; -import 'package:queue/queue.dart'; - -typedef InfiniteQueryTaskFunction - = FutureOr Function( - String queryKey, - PageParam pageParam, - Outside externalData, -); - -typedef InfiniteQueryListeners = FutureOr - Function(T page, PageParam pageParam, List pages); - -typedef InfiniteQueryPageParamFunction - = FutureOr Function(T lastPage, PageParam lastParam); - -class InfiniteQuery - extends BaseQuery, Outside, Map> { - InfiniteQueryTaskFunction task; - - InfiniteQueryPageParamFunction? getNextPageParam; - InfiniteQueryPageParamFunction? getPreviousPageParam; - - bool _hasNextPage = true; - bool _hasPreviousPage = true; - - bool _isFetchingNextPage = false; - bool _isFetchingPreviousPage = false; - - bool get isFetchingNextPage => _isFetchingNextPage; - bool get isFetchingPreviousPage => _isFetchingPreviousPage; - bool get hasNextPage => _hasNextPage; - bool get hasPreviousPage => _hasPreviousPage; - - PageParam _currentParam; - - final Set> onDataListeners = Set(); - final Set> onErrorListeners = - Set(); - - final SerializeFunction? _serializePage; - final DeserializeFunction? _deserializePage; - - final SerializeFunction? serializePageParam; - final DeserializeFunction? deserializePageParam; - - InfiniteQuery({ - required super.queryKey, - required this.task, - required super.staleTime, - required super.cacheTime, - required super.externalData, - required super.retries, - required super.retryDelay, - required super.status, - required PageParam initialParam, - super.refetchOnMount, - super.refetchOnReconnect, - super.refetchInterval, - super.enabled, - super.previousData, - super.connectivity, - super.refetchOnApplicationResume, - DeserializeFunction? deserialize, - SerializeFunction? serialize, - InfiniteQueryListeners? super.onData, - InfiniteQueryListeners? super.onError, - required T? initialPage, - this.getNextPageParam, - this.getPreviousPageParam, - this.serializePageParam, - this.deserializePageParam, - }) : _currentParam = initialParam, - _serializePage = serialize, - _deserializePage = deserialize, - super( - initialData: {initialParam: initialPage}, - ); - - InfiniteQuery.fromOptions( - InfiniteQueryJob options, { - required Outside externalData, - InfiniteQueryListeners? onData, - InfiniteQueryListeners? onError, - }) : task = options.task, - _currentParam = options.initialParam, - getNextPageParam = options.getNextPageParam, - getPreviousPageParam = options.getPreviousPageParam, - _serializePage = options.serialize, - _deserializePage = options.deserialize, - serializePageParam = options.serializePageParam, - deserializePageParam = options.deserializePageParam, - super( - cacheTime: options.cacheTime ?? const Duration(minutes: 5), - retries: options.retries ?? 3, - retryDelay: options.retryDelay ?? const Duration(milliseconds: 200), - externalData: externalData, - enabled: options.enabled ?? true, - staleTime: options.staleTime ?? const Duration(milliseconds: 500), - refetchInterval: options.refetchInterval, - refetchOnMount: options.refetchOnMount, - refetchOnReconnect: options.refetchOnReconnect, - status: QueryStatus.idle, - connectivity: options.connectivity ?? Connectivity(), - queryKey: options.queryKey, - initialData: {options.initialParam: options.initialPage}, - refetchOnApplicationResume: options.refetchOnApplicationResume, - onData: onData, - onError: onError, - ); - - List get pageParams => data?.keys.toList() ?? []; - List get errors => error?.values.toList() ?? []; - List get pages => data?.values.toList() ?? []; - - @override - @protected - Timer createRefetchTimer() { - return Timer.periodic( - refetchInterval!, - (_) async { - // only refetch if its connected to the internet or refetch will - // always result in error while there's no internet - if (isStale && await isNetworkOnline) await refetchPages(); - }, - ); - } - - Future fetchNextPage([ - InfiniteQueryPageParamFunction? getNextPageParam, - ]) async { - try { - if (isFetchingNextPage || - isFetchingPreviousPage || - isLoading || - isRefetching) return null; - final page = data?[_currentParam]; - if (data == null || page == null) await execute(); - _isFetchingNextPage = true; - _isFetchingPreviousPage = false; - final nextParam = page != null - ? await (getNextPageParam ?? this.getNextPageParam)?.call( - page, - _currentParam, - ) - : null; - if (nextParam == null) { - _hasNextPage = false; - notifyListeners(); - return null; - } else { - _hasNextPage = true; - _currentParam = nextParam; - return await fetch().then((_) => data?[_currentParam]); - } - } finally { - _isFetchingNextPage = false; - notifyListeners(); - } - } - - Future fetchPreviousPage([ - InfiniteQueryPageParamFunction? getPreviousPageParam, - ]) async { - try { - if (isFetchingNextPage || - isFetchingPreviousPage || - isLoading || - isRefetching) return null; - _isFetchingPreviousPage = true; - _isFetchingNextPage = false; - notifyListeners(); - final page = data?[_currentParam]; - if (page == null) await execute(); - final prevParam = page != null - ? await (getPreviousPageParam ?? this.getPreviousPageParam)?.call( - page, - _currentParam, - ) - : null; - if (prevParam == null) { - _hasPreviousPage = false; - notifyListeners(); - return null; - } - _hasPreviousPage = true; - _currentParam = prevParam; - return await fetch().then((_) => data?[_currentParam]); - } catch (e) { - print("[InfiniteQuery.fetchPreviousPage]: $e"); - rethrow; - } finally { - _isFetchingPreviousPage = false; - notifyListeners(); - } - } - - Future> refetchPages([ - bool Function(T? page, PageParam pageParam, List allPages)? selector, - ]) async { - if (isFetchingNextPage || - isFetchingPreviousPage || - isLoading || - isRefetching) return []; - final refetchedPages = []; - final queue = Queue(); - for (final entry in data?.entries.toList() ?? >[]) { - final page = entry.value; - final selected = selector?.call(page, entry.key, pages) ?? true; - if (!selected) continue; - _currentParam = entry.key; - queue.add( - () async { - final s = await refetch(); - if (s?[_currentParam] != null) { - refetchedPages.add(s![_currentParam]!); - } - }, - ); - } - await queue.onComplete; - return refetchedPages; - } - - @override - String get debugLabel => "InfiniteQuery($queryKey)"; - - @override - void mount(ValueKey uKey) { - super.mount(uKey); - - /// refetching on mount if it's set to true - /// also checking if the is stale or not - /// no need to refetch a valid query for no reason - if (refetchOnMount == true && isStale) { - isNetworkOnline.then((isConnected) async { - if (isConnected) await refetchPages(); - }); - } - } - - @override - @protected - void setData() async { - if (data == null) data = Map(); - data?[_currentParam] = await task( - queryKey, - _currentParam, - externalData, - ); - } - - @override - @protected - void setError(specError) { - if (error is! Map) error = Map(); - error?[_currentParam] = specError; - } - - @override - @protected - FutureOr notifyDataListeners() async { - for (var onData in onDataListeners) { - if (data?[_currentParam] == null) continue; - onData.call(data![_currentParam]!, _currentParam, pages); - } - } - - @override - @protected - FutureOr notifyErrorListeners() async { - for (var onError in onErrorListeners) { - onError.call(error?[_currentParam], _currentParam, errors); - } - } - - @override - bool operator ==(other) { - return (other is InfiniteQuery && - other.queryKey == queryKey) || - identical(other, this); - } - - @override - bool get hasData => data?[_currentParam] != null; - - @override - bool get canCacheToDisk => - _serializePage != null && - _deserializePage != null && - serializePageParam != null && - deserializePageParam != null; - - @override - deserialize(String rawData) { - if (deserializePageParam == null || _deserializePage == null) return null; - return Map.from(jsonDecode(rawData)).cast().map( - (key, value) { - return MapEntry(deserializePageParam!(key), _deserializePage!(value)); - }, - ); - } - - @override - serialize(data) { - if (serializePageParam == null || _serializePage == null) return null; - - data.removeWhere((key, value) => value == null); - - return jsonEncode(data.map( - (key, value) { - return MapEntry( - serializePageParam!(key), - _serializePage!(value!), - ); - }, - )); - } -} diff --git a/packages/fl_query/lib/src/infinite_query_builder.dart b/packages/fl_query/lib/src/infinite_query_builder.dart deleted file mode 100644 index 5d4f26f..0000000 --- a/packages/fl_query/lib/src/infinite_query_builder.dart +++ /dev/null @@ -1,160 +0,0 @@ -// ignore_for_file: invalid_use_of_protected_member - -import 'package:fl_query/src/infinite_query.dart'; -import 'package:fl_query/src/models/infinite_query_job.dart'; -import 'package:fl_query/src/query_bowl.dart'; -import 'package:fl_query/src/utils.dart'; -import 'package:flutter/widgets.dart'; - -class InfiniteQueryBuilder - extends StatefulWidget { - final Function( - BuildContext context, - InfiniteQuery query, - ) builder; - final InfiniteQueryJob job; - final Outside externalData; - final InfiniteQueryListeners? onData; - final InfiniteQueryListeners? onError; - - InfiniteQueryBuilder({ - required this.job, - required this.builder, - required this.externalData, - this.onData, - this.onError, - Key? key, - }) : super(key: key); - - @override - State> createState() => - _InfiniteQueryBuilderState(); -} - -class _InfiniteQueryBuilderState - extends State> { - InfiniteQuery? infiniteQuery; - late QueryBowl queryBowl; - late final ValueKey uKey; - - @override - void initState() { - super.initState(); - uKey = ValueKey(uuid.v4()); - WidgetsBinding.instance.addPostFrameCallback((_) { - init(); - QueryBowl.of(context).onInfiniteQueriesUpdate( - (infiniteQuery) async { - if (infiniteQuery.queryKey != widget.job.queryKey) return; - if (mounted) - setState(() { - this.infiniteQuery = infiniteQuery; - }); - if (infiniteQuery.isCachedData && !infiniteQuery.fetched) - await infiniteQuery.refetchPages(); - }, - ); - }); - } - - void init([T? previousData]) async { - final bowl = QueryBowl.of(context); - final prevInfiniteQuery = - bowl.getInfiniteQuery(widget.job.queryKey); - infiniteQuery = bowl.addInfiniteQuery( - widget.job, - externalData: widget.externalData, - key: uKey, - ); - final hasExternalDataChanged = prevInfiniteQuery != null - ? !isShallowEqual( - prevInfiniteQuery.externalData, - prevInfiniteQuery.prevUsedExternalData, - ) - : !isShallowEqual( - infiniteQuery!.externalData, - infiniteQuery!.prevUsedExternalData, - ); - - if (infiniteQuery!.fetched && hasExternalDataChanged) { - await infiniteQuery!.refetchPages(); - } else if (!infiniteQuery!.fetched) { - await infiniteQuery!.fetch(); - } - } - - @override - void didUpdateWidget(covariant oldWidget) { - final hasOnErrorChanged = - oldWidget.onError != widget.onError && oldWidget.onError != null; - final hasOnDataChanged = - oldWidget.onData != widget.onData && oldWidget.onData != null; - - // re-init the query-builder when new queryJob is appended - if (oldWidget.job.queryKey != widget.job.queryKey) { - _infiniteQueryDispose(); - init(); - - /// setting the new query's initial data as prev query's data - /// when [job.keepPreviousData] is true and both are dynamic - // if (oldWidget.job.isDynamic && - // widget.job.isDynamic && - // oldWidget.job.keepPreviousData == true && - // widget.job.keepPreviousData == true) { - // init(infiniteQuery?.pages); - // } else { - // init(); - // } - } else if (!isShallowEqual(oldWidget.externalData, widget.externalData)) { - if (widget.job.refetchOnExternalDataChange ?? - queryBowl.refetchOnExternalDataChange) { - QueryBowl.of(context).addInfiniteQuery( - widget.job, - externalData: widget.externalData, - key: uKey, - onData: widget.onData, - onError: widget.onError, - )..refetchPages(); - } else { - QueryBowl.of(context) - .getQuery(widget.job.queryKey) - ?.setExternalData(widget.externalData); - } - if (hasOnDataChanged) - infiniteQuery?.removeDataListener(oldWidget.onData!); - if (hasOnErrorChanged) - infiniteQuery?.removeErrorListener(oldWidget.onError!); - } else { - if (hasOnDataChanged) { - infiniteQuery?.removeDataListener(oldWidget.onData!); - if (widget.onData != null) - infiniteQuery?.addDataListener(widget.onData!); - } - if (hasOnErrorChanged) { - infiniteQuery?.removeErrorListener(oldWidget.onError!); - if (widget.onError != null) - infiniteQuery?.addErrorListener(widget.onError!); - } - } - super.didUpdateWidget(oldWidget); - } - - _infiniteQueryDispose() { - infiniteQuery?.unmount(uKey); - if (widget.onData != null) - infiniteQuery?.removeDataListener(widget.onData!); - if (widget.onError != null) - infiniteQuery?.removeErrorListener(widget.onError!); - } - - @override - Widget build(BuildContext context) { - queryBowl = QueryBowl.of(context); - final latestInfiniteQuery = queryBowl - .getInfiniteQuery(widget.job.queryKey) ?? - infiniteQuery; - if (latestInfiniteQuery == null) return Container(); - return widget.builder(context, latestInfiniteQuery); - } -} diff --git a/packages/fl_query/lib/src/mixins/autocast.dart b/packages/fl_query/lib/src/mixins/autocast.dart deleted file mode 100644 index 2227884..0000000 --- a/packages/fl_query/lib/src/mixins/autocast.dart +++ /dev/null @@ -1,3 +0,0 @@ -mixin AutoCast { - A? cast() => this is A ? this as A : null; -} diff --git a/packages/fl_query/lib/src/models/infinite_query_data.dart b/packages/fl_query/lib/src/models/infinite_query_data.dart deleted file mode 100644 index adbe8e3..0000000 --- a/packages/fl_query/lib/src/models/infinite_query_data.dart +++ /dev/null @@ -1,9 +0,0 @@ -class InfiniteQueryData { - final Set pages; - final Set pageParams; - - InfiniteQueryData({ - required this.pages, - required this.pageParams, - }); -} diff --git a/packages/fl_query/lib/src/models/infinite_query_job.dart b/packages/fl_query/lib/src/models/infinite_query_job.dart deleted file mode 100644 index d6756fb..0000000 --- a/packages/fl_query/lib/src/models/infinite_query_job.dart +++ /dev/null @@ -1,138 +0,0 @@ -import 'package:connectivity_plus/connectivity_plus.dart'; -import 'package:fl_query/src/infinite_query.dart'; -import 'package:fl_query/src/models/query_job.dart'; -import 'package:flutter/widgets.dart'; - -class InfiniteQueryJob { - // all params - String _queryKey; - InfiniteQueryTaskFunction task; - SerializeFunction? serialize; - DeserializeFunction? deserialize; - SerializeFunction? serializePageParam; - DeserializeFunction? deserializePageParam; - final int? retries; - final Duration? retryDelay; - T? initialPage; - PageParam initialParam; - - /// If set to false then the initial fetch will not be called & to - /// start the process the user has to call the refetch first - final bool? enabled; - - // got from global options - final bool? refetchOnMount; - final bool? refetchOnReconnect; - final bool? refetchOnExternalDataChange; - final bool? refetchOnApplicationResume; - final bool? refetchOnWindowFocus; - final Duration? staleTime; - final Duration? cacheTime; - - final Duration? refetchInterval; - final Connectivity? connectivity; - final InfiniteQueryPageParamFunction getNextPageParam; - final InfiniteQueryPageParamFunction getPreviousPageParam; - - @protected - bool isDynamic = false; - - InfiniteQueryJob({ - required String queryKey, - required this.task, - required this.initialParam, - required this.getNextPageParam, - required this.getPreviousPageParam, - this.retries, - this.retryDelay, - this.initialPage, - this.staleTime, - this.cacheTime, - this.enabled, - this.refetchInterval, - this.refetchOnMount, - this.refetchOnReconnect, - this.refetchOnExternalDataChange, - this.refetchOnApplicationResume, - this.refetchOnWindowFocus, - this.connectivity, - this.deserialize, - this.serialize, - this.serializePageParam, - this.deserializePageParam, - }) : assert( - serialize == null && - deserialize == null && - serializePageParam == null && - deserializePageParam == null || - (serialize != null && - deserialize != null && - serializePageParam != null && - deserializePageParam != null && - enabled != false), - "All or none of the serialize, deserialize, serializePageParam & deserializePageParam function must be provided. And `enabled` must be true if all of them are provided.", - ), - _queryKey = queryKey; - - String get queryKey => _queryKey; - - static InfiniteQueryJob Function(String queryKey) - withVariableKey({ - required InfiniteQueryTaskFunction task, - required InfiniteQueryPageParamFunction getNextPageParam, - required InfiniteQueryPageParamFunction getPreviousPageParam, - required PageParam initialParam, - - /// a extra key joined with queryKey by a '#' - /// - /// useful for matching a group query - String? preQueryKey, - int? retries, - Duration? retryDelay, - T? initialPage, - Duration? staleTime, - Duration? cacheTime, - bool? enabled, - Duration? refetchInterval, - bool? refetchOnMount, - bool? refetchOnReconnect, - bool? refetchOnExternalDataChange, - bool? refetchOnApplicationResume, - bool? refetchOnWindowFocus, - Connectivity? connectivity, - SerializeFunction? serialize, - DeserializeFunction? deserialize, - SerializeFunction? serializePageParam, - DeserializeFunction? deserializePageParam, - }) { - return (String queryKey) { - if (preQueryKey != null) queryKey = "$preQueryKey#$queryKey"; - final query = InfiniteQueryJob( - queryKey: queryKey, - task: task, - getNextPageParam: getNextPageParam, - getPreviousPageParam: getPreviousPageParam, - retries: retries, - retryDelay: retryDelay, - initialPage: initialPage, - staleTime: staleTime, - cacheTime: cacheTime, - enabled: enabled, - refetchInterval: refetchInterval, - refetchOnMount: refetchOnMount, - refetchOnReconnect: refetchOnReconnect, - refetchOnExternalDataChange: refetchOnExternalDataChange, - refetchOnApplicationResume: refetchOnApplicationResume, - refetchOnWindowFocus: refetchOnWindowFocus, - connectivity: connectivity, - initialParam: initialParam, - serialize: serialize, - deserialize: deserialize, - serializePageParam: serializePageParam, - deserializePageParam: deserializePageParam, - ); - query.isDynamic = true; - return query; - }; - } -} diff --git a/packages/fl_query/lib/src/models/mutation_job.dart b/packages/fl_query/lib/src/models/mutation_job.dart deleted file mode 100644 index 5859f03..0000000 --- a/packages/fl_query/lib/src/models/mutation_job.dart +++ /dev/null @@ -1,48 +0,0 @@ -import 'package:connectivity_plus/connectivity_plus.dart'; -import 'package:fl_query/fl_query.dart'; - -class MutationJob { - String _mutationKey; - MutationTaskFunction task; - final int? retries; - final Duration? retryDelay; - final Duration? cacheTime; - final Connectivity? connectivity; - - MutationJob({ - required String mutationKey, - required this.task, - this.connectivity, - this.retries, - this.retryDelay, - this.cacheTime, - }) : _mutationKey = mutationKey; - - String get mutationKey => _mutationKey; - - static MutationJob Function(String queryKey) - withVariableKey({ - required MutationTaskFunction task, - - /// a extra key joined with mutationKey by a '#' - /// - /// useful for matching a group mutation - String? preMutationKey, - int? retries, - Duration? retryDelay, - Duration? cacheTime, - Connectivity? connectivity, - }) { - return (String mutationKey) { - if (preMutationKey != null) mutationKey = "$preMutationKey#$mutationKey"; - return MutationJob( - mutationKey: mutationKey, - task: task, - retries: retries, - retryDelay: retryDelay, - cacheTime: cacheTime, - connectivity: connectivity, - ); - }; - } -} diff --git a/packages/fl_query/lib/src/models/query_job.dart b/packages/fl_query/lib/src/models/query_job.dart deleted file mode 100644 index fa9cf1e..0000000 --- a/packages/fl_query/lib/src/models/query_job.dart +++ /dev/null @@ -1,117 +0,0 @@ -import 'package:connectivity_plus/connectivity_plus.dart'; -import 'package:fl_query/src/query.dart'; -import 'package:flutter/widgets.dart'; - -typedef SerializeFunction = String Function(T data); -typedef DeserializeFunction = T Function(String raw); - -class QueryJob { - // all params - String _queryKey; - QueryTaskFunction task; - final SerializeFunction? serialize; - final DeserializeFunction? deserialize; - final int? retries; - final Duration? retryDelay; - T? initialData; - - /// If set to false then the initial fetch will not be called & to - /// start the process the user has to call the refetch first - final bool? enabled; - - // got from global options - final bool? refetchOnMount; - final bool? refetchOnReconnect; - final bool? refetchOnExternalDataChange; - final bool? refetchOnApplicationResume; - final bool? refetchOnWindowFocus; - final bool? keepPreviousData; - final Duration? staleTime; - final Duration? cacheTime; - - final Duration? refetchInterval; - final Connectivity? connectivity; - - @protected - bool isDynamic = false; - - QueryJob({ - required String queryKey, - required this.task, - this.retries, - this.retryDelay, - this.initialData, - this.staleTime, - this.cacheTime, - this.enabled, - this.refetchInterval, - this.refetchOnMount, - this.refetchOnReconnect, - this.refetchOnExternalDataChange, - this.connectivity, - this.keepPreviousData, - this.refetchOnApplicationResume, - this.refetchOnWindowFocus, - this.deserialize, - this.serialize, - }) : assert( - serialize == null && deserialize == null || - (serialize != null && deserialize != null && enabled != false), - "Both or none of the serialize and deserialize function must be provided and enabled must be true if you want to use disk caching", - ), - _queryKey = queryKey; - - String get queryKey => _queryKey; - - static QueryJob Function(String queryKey) - withVariableKey({ - required QueryTaskFunction task, - - /// a extra key joined with queryKey by a '#' - /// - /// useful for matching a group query - String? preQueryKey, - int? retries, - Duration? retryDelay, - T? initialData, - Duration? staleTime, - Duration? cacheTime, - bool? enabled, - Duration? refetchInterval, - bool? refetchOnMount, - bool? refetchOnReconnect, - bool? refetchOnExternalDataChange, - bool? refetchOnApplicationResume, - bool? refetchOnWindowFocus, - Connectivity? connectivity, - bool? keepPreviousData, - SerializeFunction? serialize, - DeserializeFunction? deserialize, - }) { - return (String queryKey) { - if (preQueryKey != null) queryKey = "$preQueryKey#$queryKey"; - final query = QueryJob( - queryKey: queryKey, - task: task, - retries: retries, - retryDelay: retryDelay, - initialData: initialData, - staleTime: staleTime, - cacheTime: cacheTime, - enabled: enabled, - refetchInterval: refetchInterval, - refetchOnMount: refetchOnMount, - refetchOnReconnect: refetchOnReconnect, - refetchOnExternalDataChange: refetchOnExternalDataChange, - connectivity: connectivity, - keepPreviousData: keepPreviousData, - refetchOnApplicationResume: refetchOnApplicationResume, - refetchOnWindowFocus: refetchOnWindowFocus, - serialize: serialize, - deserialize: deserialize, - ); - query.isDynamic = true; - return query; - }; - } -} diff --git a/packages/fl_query/lib/src/mutation.dart b/packages/fl_query/lib/src/mutation.dart deleted file mode 100644 index 51a820b..0000000 --- a/packages/fl_query/lib/src/mutation.dart +++ /dev/null @@ -1,222 +0,0 @@ -import 'dart:async'; - -import 'package:fl_query/fl_query.dart'; -import 'package:fl_query/src/base_operation.dart'; -import 'package:fl_query/src/mixins/autocast.dart'; -import 'package:fl_query/src/models/mutation_job.dart'; -import 'package:flutter/widgets.dart'; - -enum MutationStatus { - error, - success, - loading, - idle, -} - -typedef MutationListenerReturnable = FutureOr Function(T); - -typedef MutationListener = FutureOr Function( - T payload, - V variables, - dynamic realData, -); - -typedef MutationTaskFunction = FutureOr Function( - String queryKey, V variables); - -class Mutation extends BaseOperation - with AutoCast { - // all params - final String mutationKey; - MutationTaskFunction task; - - MutationStatus status; - - dynamic _sideEffectContext; - - @protected - final Set> _onDataListeners = {}; - @protected - final Set> _onErrorListeners = {}; - @protected - final Set> _onMutateListeners = {}; - - // using late as _variables will only be used after a [mutate] or - // [mutateAsync] is executed - late V _variables; - - Mutation({ - required this.mutationKey, - required this.task, - required super.retries, - required super.retryDelay, - super.connectivity, - required Duration cacheTime, - MutationListener? onData, - MutationListener? onError, - MutationListenerReturnable? onMutate, - }) : status = MutationStatus.idle, - super(cacheTime: cacheTime) { - if (onData != null) _onDataListeners.add(onData); - if (onError != null) _onErrorListeners.add(onError); - if (onMutate != null) _onMutateListeners.add(onMutate); - } - - Mutation.fromOptions( - MutationJob options, { - MutationListener? onData, - MutationListener? onError, - MutationListenerReturnable? onMutate, - }) : mutationKey = options.mutationKey, - task = options.task, - status = MutationStatus.idle, - super( - retries: options.retries ?? 3, - retryDelay: options.retryDelay ?? const Duration(milliseconds: 200), - cacheTime: options.cacheTime ?? const Duration(minutes: 5), - connectivity: options.connectivity, - ) { - if (onData != null) _onDataListeners.add(onData); - if (onError != null) _onErrorListeners.add(onError); - } - - // all methods - - /// Calls the task function & doesn't check if there's already - /// cached data available - Future _execute(V variables) async { - try { - status = MutationStatus.loading; - notifyListeners(); - retryAttempts = 0; - for (final onMutate in _onMutateListeners) { - _sideEffectContext = await onMutate(variables); - } - data = await task(mutationKey, variables); - updatedAt = DateTime.now(); - status = MutationStatus.success; - for (final onData in _onDataListeners) { - onData(data!, _variables, _sideEffectContext); - } - notifyListeners(); - } catch (e) { - if (retries == 0) { - status = MutationStatus.error; - error = e; - for (final onError in _onErrorListeners) { - onError(error, variables, _sideEffectContext); - } - notifyListeners(); - throw e; - } else { - // retrying for retry count if failed for the first time - while (retryAttempts <= retries) { - await Future.delayed(retryDelay); - try { - for (final onMutate in _onMutateListeners) { - _sideEffectContext = onMutate(variables); - } - data = await task(mutationKey, variables); - status = MutationStatus.success; - for (final onData in _onDataListeners) { - onData(data!, variables, _sideEffectContext); - } - notifyListeners(); - break; - } catch (e) { - if (retryAttempts == retries) { - status = MutationStatus.error; - error = e; - for (final onError in _onErrorListeners) { - onError(error, variables, _sideEffectContext); - } - notifyListeners(); - throw e; - } - retryAttempts++; - } - } - } - } - } - - void addDataListener(MutationListener listener) { - _onDataListeners.add(listener); - } - - void addErrorListener(MutationListener listener) { - _onErrorListeners.add(listener); - } - - void addMutateListener(MutationListenerReturnable listener) { - _onMutateListeners.add(listener); - } - - void removeDataListener(MutationListener listener) { - _onDataListeners.remove(listener); - } - - void removeErrorListener(MutationListener listener) { - _onErrorListeners.remove(listener); - } - - void removeMutateListener(MutationListenerReturnable listener) { - _onMutateListeners.remove(listener); - } - - void mutate( - V variables, { - MutationListener? onData, - MutationListener? onError, - }) { - _variables = variables; - if (onData != null) _onDataListeners.add(onData); - if (onError != null) _onErrorListeners.add(onError); - try { - _execute(variables).then((_) { - _onDataListeners.remove(onData); - _onErrorListeners.remove(onError); - }); - } catch (e) { - return; - } - } - - Future mutateAsync(V variables) async { - _variables = variables; - return await _execute(variables).then((_) => data); - } - - /// Update configurations of the mutation after already creating the - /// Mutation instance - void updateDefaultOptions({ - Duration? cacheTime, - }) { - if (this.cacheTime == Duration(minutes: 5) && cacheTime != null) - this.cacheTime = cacheTime; - - notifyListeners(); - } - - void reset() { - data = null; - retryAttempts = 0; - updatedAt = DateTime.now(); - _onDataListeners.clear(); - _onErrorListeners.clear(); - status = MutationStatus.idle; - _onMutateListeners.clear(); - _sideEffectContext = null; - } - - bool get isError => status == MutationStatus.error; - bool get isIdle => status == MutationStatus.idle; - bool get isLoading => status == MutationStatus.loading; - bool get isSuccess => status == MutationStatus.success; - - @override - bool operator ==(other) { - return (other is Mutation && other.mutationKey == mutationKey) || - identical(other, this); - } -} diff --git a/packages/fl_query/lib/src/mutation_builder.dart b/packages/fl_query/lib/src/mutation_builder.dart deleted file mode 100644 index a659f58..0000000 --- a/packages/fl_query/lib/src/mutation_builder.dart +++ /dev/null @@ -1,117 +0,0 @@ -// ignore_for_file: invalid_use_of_protected_member - -import 'package:fl_query/src/models/mutation_job.dart'; -import 'package:fl_query/src/mutation.dart'; -import 'package:fl_query/src/query_bowl.dart'; -import 'package:fl_query/src/utils.dart'; -import 'package:flutter/widgets.dart'; - -class MutationBuilder extends StatefulWidget { - final Function(BuildContext context, Mutation mutation) builder; - final MutationJob job; - - /// Called when the query returns new data, on query - /// refetch or query gets expired - final MutationListener? onData; - - /// Called when the query returns error - final MutationListener? onError; - - /// called right before the mutation is about to run - /// - /// perfect scenario for doing optimistic updates - final MutationListenerReturnable? onMutate; - - const MutationBuilder({ - required this.job, - required this.builder, - this.onData, - this.onError, - this.onMutate, - Key? key, - }) : super(key: key); - - @override - State> createState() => _MutationBuilderState(); -} - -class _MutationBuilderState - extends State> { - late ValueKey uKey; - - Mutation? mutation; - - @override - void initState() { - super.initState(); - uKey = ValueKey(uuid.v4()); - WidgetsBinding.instance.addPostFrameCallback((_) { - init(); - QueryBowl.of(context).onMutationsUpdate( - (mutation) { - if (mutation.mutationKey != widget.job.mutationKey || !mounted) - return; - setState(() { - this.mutation = mutation; - }); - }, - ); - }); - } - - void init([_]) { - final bowl = QueryBowl.of(context); - - setState(() { - mutation = bowl.addMutation( - widget.job, - onData: widget.onData, - onError: widget.onError, - onMutate: widget.onMutate, - key: uKey, - ); - }); - } - - @override - void didUpdateWidget(covariant MutationBuilder oldWidget) { - if (oldWidget.job.mutationKey != widget.job.mutationKey) { - _mutationDispose(); - init(); - } else { - if (oldWidget.onData != widget.onData && oldWidget.onData != null) { - mutation?.removeDataListener(oldWidget.onData!); - if (widget.onData != null) mutation?.addDataListener(widget.onData!); - } - if (oldWidget.onError != widget.onError && oldWidget.onError != null) { - mutation?.removeErrorListener(oldWidget.onError!); - if (widget.onError != null) mutation?.addErrorListener(widget.onError!); - } - if (oldWidget.onMutate != widget.onMutate && oldWidget.onMutate != null) { - mutation?.removeMutateListener(oldWidget.onMutate!); - if (widget.onMutate != null) - mutation?.addMutateListener(widget.onMutate!); - } - } - super.didUpdateWidget(oldWidget); - } - - @override - void dispose() { - _mutationDispose(); - super.dispose(); - } - - void _mutationDispose() { - mutation?.unmount(uKey); - if (widget.onData != null) mutation?.addDataListener(widget.onData!); - if (widget.onError != null) mutation?.addErrorListener(widget.onError!); - if (widget.onMutate != null) mutation?.addMutateListener(widget.onMutate!); - } - - @override - Widget build(BuildContext context) { - if (mutation == null) return Container(); - return widget.builder(context, mutation!); - } -} diff --git a/packages/fl_query/lib/src/query.dart b/packages/fl_query/lib/src/query.dart deleted file mode 100644 index ac0a691..0000000 --- a/packages/fl_query/lib/src/query.dart +++ /dev/null @@ -1,162 +0,0 @@ -import 'dart:async'; - -import 'package:connectivity_plus/connectivity_plus.dart'; -import 'package:fl_query/fl_query.dart'; -import 'package:fl_query/src/base_query.dart'; -import 'package:fl_query/src/models/query_job.dart'; -import 'package:flutter/widgets.dart'; - -enum QueryStatus { - /// in times when an error occurs - /// will get reset to idle on refetch/retry - error, - - /// when a query successfully executes - success, - - /// when the query is running (not refetching) - loading, - - /// when the query isn't yet fetched, re-fetched, or got reset - /// mostly when both [data] & [error] are null. Also [fetched] is false - idle, - - /// when the query is refetching (rerunning) - refetching, - - /// when the query data is loaded from cache - cached, -} - -typedef QueryTaskFunction = FutureOr Function( - String queryKey, - Outside externalData, -); - -typedef QueryListener = FutureOr Function(T); - -typedef ListenerUnsubscriber = void Function(); - -typedef QueryUpdateFunction = FutureOr Function(T? oldData); - -class Query extends BaseQuery { - QueryTaskFunction task; - - final Set> onDataListeners = Set(); - final Set> onErrorListeners = Set(); - - final SerializeFunction? _serialize; - final DeserializeFunction? _deserialize; - - Query({ - required super.queryKey, - required this.task, - required super.staleTime, - required super.cacheTime, - required super.externalData, - required super.retries, - required super.retryDelay, - required super.status, - super.refetchOnMount, - super.refetchOnReconnect, - super.refetchInterval, - super.enabled, - super.previousData, - super.connectivity, - super.initialData, - super.refetchOnApplicationResume, - SerializeFunction? serialize, - DeserializeFunction? deserialize, - QueryListener? super.onData, - QueryListener? super.onError, - }) : _deserialize = deserialize, - _serialize = serialize; - - Query.fromOptions( - QueryJob options, { - required Outside externalData, - T? previousData, - QueryListener? onData, - QueryListener? onError, - }) : task = options.task, - _deserialize = options.deserialize, - _serialize = options.serialize, - super( - cacheTime: options.cacheTime ?? const Duration(minutes: 5), - retries: options.retries ?? 3, - retryDelay: options.retryDelay ?? const Duration(milliseconds: 200), - externalData: externalData, - enabled: options.enabled ?? true, - staleTime: options.staleTime ?? const Duration(milliseconds: 500), - initialData: options.initialData, - refetchInterval: options.refetchInterval, - refetchOnMount: options.refetchOnMount, - refetchOnReconnect: options.refetchOnReconnect, - status: previousData == null ? QueryStatus.idle : QueryStatus.success, - connectivity: options.connectivity ?? Connectivity(), - previousData: previousData, - queryKey: options.queryKey, - refetchOnApplicationResume: options.refetchOnApplicationResume, - onData: onData, - onError: onError, - ); - - @override - Timer createRefetchTimer() { - return Timer.periodic( - refetchInterval!, - (_) async { - // only refetch if its connected to the internet or refetch will - // always result in error while there's no internet - if (isStale && await isNetworkOnline) await refetch(); - }, - ); - } - - String get debugLabel => "Query($queryKey)"; - - @override - void mount(ValueKey uKey) { - super.mount(uKey); - - /// refetching on mount if it's set to true - /// also checking if the is stale or not - /// no need to refetch a valid query for no reason - if (refetchOnMount == true && isStale) { - isNetworkOnline.then((isConnected) async { - if (isConnected) await refetch(); - }); - } - } - - @override - bool operator ==(other) { - return (other is Query && other.queryKey == queryKey) || - identical(other, this); - } - - @override - FutureOr setData() async { - data = await task(queryKey, externalData); - } - - @override - void setError(e) { - error = e; - } - - @override - deserialize(rawData) { - if (_deserialize == null) return null; - return _deserialize!(rawData); - } - - @override - serialize(data) { - if (_serialize == null) return null; - return _serialize!(data); - } - - @override - bool get canCacheToDisk => _serialize != null && _deserialize != null; -} diff --git a/packages/fl_query/lib/src/query_bowl.dart b/packages/fl_query/lib/src/query_bowl.dart deleted file mode 100644 index f5270d1..0000000 --- a/packages/fl_query/lib/src/query_bowl.dart +++ /dev/null @@ -1,565 +0,0 @@ -import 'package:connectivity_plus/connectivity_plus.dart'; -import 'package:fl_query/fl_query.dart'; -import 'package:fl_query/src/query_cache.dart'; -import 'package:fl_query/src/utils.dart'; -import 'package:flutter/cupertino.dart'; -import 'package:collection/collection.dart'; -import 'package:flutter/services.dart'; -import 'package:hive_flutter/hive_flutter.dart'; - -/// The widget that holds every [Query] & [Mutation] to your -/// entire Flutter application in anywhere -/// [QueryBowl] provides an imperative way to handle all the query & -/// mutation related methods & properties. -/// Its responsible or can be used for (not recommended) creating, -/// updating & deleting queries & mutations -/// -/// This must be used along with [QueryBowlScope] -/// -/// ```dart -/// Widget build(BuildContext context) { -/// return QueryBowlScope( -/// bowl: QueryBowl(), -/// child: MaterialApp(/*...other stuff...*/), -/// ); -/// } -/// ``` -/// -class QueryBowl { - /// global stale time - /// - /// Makes [Query.data] stale after crossing the duration of provided - /// [staleTime] - final Duration staleTime; - - // refetching options - - /// refetch query when new query instance mounts - final bool refetchOnMount; - - /// refetch when desktop/web app regains Focus - final bool refetchOnWindowFocus; - - /// the delay to call each query when desktop/web application gets focused after - /// being unfocused. Using a delay after each refetch so refetching all the - /// queries at once won't create high CPU spikes & also wouldn't violate - /// rate-limit - /// - /// Though its recommended most of the time to use but it can be turned - /// off by passing [Duration.zero] - final Duration refetchOnWindowFocusDelay; - - /// refetch when application resumes from the background in mobile devices - final bool refetchOnApplicationResume; - - /// the delay to call each query when app resumes from the background in - /// mobile devices. Using a delay after each refetch so refetching all the - /// queries at once won't create high CPU spikes & also wouldn't violate - /// rate-limit - /// - /// Though its recommended most of the time to use but it can be turned - /// off by passing [Duration.zero] - final Duration refetchOnApplicationResumeDelay; - - /// refetch when user's device reconnects to the internet after not being - /// connected before - final bool refetchOnReconnect; - - /// the delay to call each query when user device reconnects to the - /// internet. Using a delay after each refetch so refetching all the - /// queries at once won't create high CPU spikes & also wouldn't violate - /// rate-limit - /// - /// Though its recommended most of the time to use but it can be turned - /// off by passing [Duration.zero] - final Duration refetchOnReconnectDelay; - - /// Refetch the query whenever the data passed as [externalData] to any - /// [QueryBuilder] or [useQuery] changes - /// - /// If set to false than the [externalData] will get updated but there - /// won't be any query update - final bool refetchOnExternalDataChange; - - /// used for periodically checking if any query got stale. - /// If none is supplied then half of the value of staleTime is used - final Duration refetchInterval; - - /// The Cache that holds all the queries, mutations and infinite queries - QueryCache cache; - - QueryBowl({ - /// The Cache that holds all the queries, mutations and infinite - /// queries - QueryCache? cache, - this.staleTime = Duration.zero, - - /// global cache time - /// - /// Removes inactive queries after provided duration of [cacheTime] - Duration? cacheTime, - this.refetchInterval = Duration.zero, - this.refetchOnMount = false, - this.refetchOnReconnect = true, - this.refetchOnReconnectDelay = const Duration(milliseconds: 100), - this.refetchOnApplicationResumeDelay = const Duration(milliseconds: 100), - this.refetchOnWindowFocusDelay = const Duration(milliseconds: 100), - this.refetchOnApplicationResume = true, - this.refetchOnWindowFocus = true, - this.refetchOnExternalDataChange = false, - }) : cache = cache ?? QueryCache(cacheTime: cacheTime) { - Connectivity() - .onConnectivityChanged - .listen((ConnectivityResult result) async { - if (isConnectedToInternet(result)) { - for (final query in this.cache.queries.toList()) { - if (query.refetchOnReconnect == false || !query.enabled) continue; - await query.refetch(); - await Future.delayed(refetchOnReconnectDelay); - } - for (final infiniteQuery in this.cache.infiniteQueries.toList()) { - if (infiniteQuery.refetchOnReconnect == false || - !infiniteQuery.enabled) continue; - await infiniteQuery.refetchPages(); - await Future.delayed(refetchOnReconnectDelay); - } - } - }); - - if (kIsMobile) { - SystemChannels.lifecycle.setMessageHandler((msg) async { - if (msg == 'AppLifecycleState.resumed') { - if (_canNotRefetchAfterWeGotTheApp) return null; - for (final query in this.cache.queries.toList()) { - if (query.refetchOnApplicationResume == false || !query.enabled) - continue; - await query.refetch(); - await Future.delayed(refetchOnApplicationResumeDelay); - } - for (final infiniteQuery in this.cache.infiniteQueries.toList()) { - if (infiniteQuery.refetchOnApplicationResume == false || - !infiniteQuery.enabled) continue; - await infiniteQuery.refetchPages(); - await Future.delayed(refetchOnApplicationResumeDelay); - } - } else if (msg != null) { - updateWeLostTheApp(); - } - return null; - }); - } - } - - DateTime? _weLostTheAppAt; - - /// Returns the number of query is currently fetching or refetching - int get isFetching { - return cache.queries.fold( - 0, - (acc, query) { - if (query.isLoading || query.isRefetching) acc++; - return acc; - }, - ); - } - - /// Provides the number of mutations that are running at the moment - int get isMutating { - return cache.mutations.fold( - 0, - (acc, mutation) { - if (mutation.isLoading) acc++; - return acc; - }, - ); - } - - bool get _canNotRefetchAfterWeGotTheApp => (_weLostTheAppAt != null && - _weLostTheAppAt!.difference(DateTime.now()) <= cache.cacheTime); - - @protected - updateWeLostTheApp() { - _weLostTheAppAt = DateTime.now(); - } - - @protected - notifyWindowFocused() async { - if (kIsMobile || _canNotRefetchAfterWeGotTheApp) return; - for (final query in this.cache.queries.toList()) { - if (query.refetchOnWindowFocus == false || !query.enabled) continue; - await query.refetch(); - await Future.delayed(refetchOnWindowFocusDelay); - } - for (final infiniteQuery in this.cache.infiniteQueries.toList()) { - if (infiniteQuery.refetchOnWindowFocus == false || !infiniteQuery.enabled) - continue; - await infiniteQuery.refetchPages(); - await Future.delayed(refetchOnWindowFocusDelay); - } - } - - void onQueriesUpdate( - void Function(Query query) listener, - ) { - cache.on((event, changes) { - if (event == CacheEvent.query && changes is Query) { - listener(changes); - } - }); - } - - void onMutationsUpdate( - void Function(Mutation mutation) listener, - ) { - cache.on((event, changes) { - if (event == CacheEvent.mutation && changes is Mutation) { - listener(changes); - } - }); - } - - void onInfiniteQueriesUpdate( - void Function(InfiniteQuery infiniteQuery) listener, - ) { - cache.on((event, changes) { - if (event == CacheEvent.infiniteQuery && - changes is InfiniteQuery) { - listener(changes); - } - }); - } - - InfiniteQuery? - getInfiniteQuery( - String queryKey, - ) { - return cache.infiniteQueries.firstWhereOrNull((infiniteQuery) { - return infiniteQuery.queryKey == queryKey && - infiniteQuery is InfiniteQuery; - })?.cast>(); - } - - /// Get a query by providing queryKey only - /// - /// Useful for optimistic update or single query refetch - Query? getQuery(String queryKey) { - return cache.queries.firstWhereOrNull((query) { - return query.queryKey == queryKey && query is Query; - })?.cast>(); - } - - /// Get a mutation by providing mutationKey only - /// - /// Useful for mutation resets - Mutation? getMutation(String mutationKey) { - return cache.mutations.firstWhereOrNull((mutation) { - return mutation.mutationKey == mutationKey && mutation is Mutation; - })?.cast>(); - } - - /// Sets [Query]'s data manually - /// - /// Mostly used in combination with [onMutate] callback of - /// [MutationBuilder] & [useMutation] for optimistic updates - void setQueryData( - String queryKey, - QueryUpdateFunction updateCb, - ) { - getQuery(queryKey)?.setQueryData(updateCb); - } - - /// Sets [InfiniteQuery]'s data manually - /// - /// Mostly used in combination with [onMutate] callback of - /// [MutationBuilder] & [useMutation] for optimistic updates - void - setInfiniteQueryData( - String queryKey, - QueryUpdateFunction> updateCb, - ) { - getInfiniteQuery(queryKey)?.setQueryData(updateCb); - } - - /// resets all the queries matching the passed List of queryKeys - /// - /// If an empty list of [queryKeys] is passed then all of the queries - /// will be reset - void resetQueries(List queryKeys) { - for (final query in cache.queries) { - if (queryKeys.isNotEmpty && !queryKeys.contains(query.queryKey)) continue; - query.reset(); - } - } - - /// makes all the queries matching the passed List of queryKeys stale - /// - /// If an empty list of [queryKeys] is passed then all of the queries - /// will be invalidated - void invalidateQueries(List queryKeys) { - for (final query in cache.queries) { - if (queryKeys.isNotEmpty && queryKeys.contains(query.queryKey)) continue; - query.invalidate(); - } - } - - /// refetches all the queries matching the passed List of queryKeys - /// - /// If an empty list of [queryKeys] is passed then all of the queries - /// will be refetched - Future refetchQueries(List queryKeys) async { - for (final query in cache.queries) { - if (queryKeys.isNotEmpty && queryKeys.contains(query.queryKey)) continue; - await query.refetch(); - } - } - - /// Removes all the queries matching the passed List of queryKeys - /// from the [QueryCache] - int removeQueries(List queryKeys) { - int count = 0; - for (final query in cache.queries) { - if (queryKeys.isEmpty || !queryKeys.contains(query.queryKey)) continue; - cache.removeQuery(query); - count++; - } - return count; - } - - Query _createQueryWithDefaults( - QueryJob options, - Outside externalData, [ - T? previousData, - ]) { - final query = Query.fromOptions( - options, - externalData: externalData, - previousData: previousData, - ); - query.updateDefaultOptions( - cacheTime: cache.cacheTime, - staleTime: staleTime, - refetchInterval: refetchInterval, - refetchOnMount: refetchOnMount, - refetchOnReconnect: refetchOnReconnect, - refetchOnApplicationResume: refetchOnApplicationResume, - refetchOnWindowFocus: refetchOnWindowFocus, - ); - return query; - } - - InfiniteQuery _createInfiniteQueryWithDefaults< - T extends Object, Outside, PageParam extends Object>( - InfiniteQueryJob options, - Outside externalData, - ) { - final infiniteQuery = InfiniteQuery.fromOptions( - options, - externalData: externalData, - ); - infiniteQuery.updateDefaultOptions( - cacheTime: cache.cacheTime, - staleTime: staleTime, - refetchInterval: refetchInterval, - refetchOnMount: refetchOnMount, - refetchOnReconnect: refetchOnReconnect, - refetchOnApplicationResume: refetchOnApplicationResume, - refetchOnWindowFocus: refetchOnWindowFocus, - ); - return infiniteQuery; - } - - /// Creates/Updates a [Query] with the provided [QueryJob] and it's - /// [externalData] and listeners and mounts the [QueryBuilder] or - /// [useQuery] for the Query - Query addQuery( - QueryJob queryJob, { - required Outside externalData, - required ValueKey key, - final QueryListener? onData, - final QueryListener? onError, - final T? previousData, - }) { - final prevQuery = getQuery(queryJob.queryKey); - if (prevQuery != null) { - // run the query if its still not called or if externalData has - // changed - if (!isShallowEqual( - prevQuery.prevUsedExternalData, - externalData, - )) { - prevQuery.setExternalData(externalData); - } - prevQuery.mount(key); - if (onData != null) prevQuery.addDataListener(onData); - if (onError != null) prevQuery.addErrorListener(onError); - // mounting the widget that is using the query in the prevQuery - return prevQuery; - } - final query = _createQueryWithDefaults( - queryJob, - externalData, - previousData, - ); - if (onData != null) query.addDataListener(onData); - if (onError != null) query.addErrorListener(onError); - query.mount(key); - cache.addQuery(query); - return query; - } - - /// Creates/Updates a [InfiniteQuery] with the provided - /// [InfiniteQueryJob] and it's [externalData] and listeners and mounts - /// the [InfiniteQueryBuilder] or [useInfiniteQuery] for the it - InfiniteQuery - addInfiniteQuery( - InfiniteQueryJob infiniteQueryJob, { - required Outside externalData, - required ValueKey key, - final InfiniteQueryListeners? onData, - final InfiniteQueryListeners? onError, - }) { - final prevInfiniteQuery = - getInfiniteQuery(infiniteQueryJob.queryKey); - if (prevInfiniteQuery != null) { - // run the query if its still not called or if externalData has - // changed - if (!isShallowEqual( - prevInfiniteQuery.prevUsedExternalData, - externalData, - )) { - prevInfiniteQuery.setExternalData(externalData); - } - prevInfiniteQuery.mount(key); - if (onData != null) prevInfiniteQuery.addDataListener(onData); - if (onError != null) prevInfiniteQuery.addErrorListener(onError); - // mounting the widget that is using the query in the prevQuery - return prevInfiniteQuery; - } - - final infiniteQuery = - _createInfiniteQueryWithDefaults( - infiniteQueryJob, - externalData, - ); - if (onData != null) infiniteQuery.addDataListener(onData); - if (onError != null) infiniteQuery.addErrorListener(onError); - infiniteQuery.mount(key); - cache.addInfiniteQuery(infiniteQuery); - return infiniteQuery; - } - - /// Creates/Updates a [Mutation] with the provided - /// [MutationJob] and it's listeners. Mounts - /// the [MutationBuilder] or [useMutation] for the it - Mutation addMutation( - MutationJob mutationJob, { - final MutationListener? onData, - final MutationListener? onError, - final MutationListenerReturnable? onMutate, - required ValueKey key, - }) { - final prevMutation = getMutation(mutationJob.mutationKey); - if (prevMutation != null) { - if (onData != null) prevMutation.addDataListener(onData); - if (onError != null) prevMutation.addErrorListener(onError); - if (onMutate != null) prevMutation.addMutateListener(onMutate); - prevMutation.mount(key); - return prevMutation; - } else { - final mutation = Mutation.fromOptions( - mutationJob, - ); - if (onData != null) mutation.addDataListener(onData); - if (onError != null) mutation.addErrorListener(onError); - if (onMutate != null) mutation.addMutateListener(onMutate); - mutation.updateDefaultOptions(cacheTime: cache.cacheTime); - mutation.mount(key); - cache.addMutation(mutation); - return mutation; - } - } - - /// Creates/Updates a [Query] with the provided [QueryJob] and it's - /// [externalData] and listeners and mounts the [QueryBuilder] or - /// [useQuery] for the Query - /// - /// It also fetches/refetches the [Query] strategically/based on changes - Future fetchQuery( - QueryJob options, { - required Outside externalData, - final QueryListener? onData, - final QueryListener? onError, - required ValueKey key, - }) async { - final prevQuery = getQuery(options.queryKey); - if (prevQuery != null) { - // run the query if its still not called or if externalData has - // changed - final hasExternalDataChanged = !isShallowEqual( - prevQuery.prevUsedExternalData, - externalData, - ); - prevQuery.mount(key); - if (onData != null) prevQuery.addDataListener(onData); - if (onError != null) prevQuery.addErrorListener(onError); - if (!prevQuery.hasData || hasExternalDataChanged) { - if (hasExternalDataChanged) prevQuery.setExternalData(externalData); - - return await prevQuery.refetch(); - } - // mounting the widget that is using the query in the prevQuery - return prevQuery.data; - } - - final query = _createQueryWithDefaults( - options, - externalData, - ); - - query.mount(key); - cache.addQuery(query); - return await query.fetch(); - } - - /// Finds the closest instance of [QueryBowl] for the provided - /// [BuildContext] - static QueryBowl of(BuildContext context) { - return context.dependOnInheritedWidgetOfExactType()!.bowl; - } -} - -/// A simple [InheritedWidget] that does the job of injecting [QueryBowl] -/// into context -/// -/// ```dart -/// Widget build(BuildContext context) { -/// return QueryBowlScope( -/// bowl: QueryBowl(), -/// child: MaterialApp(/*...other stuff...*/), -/// ); -/// } -/// ``` -class QueryBowlScope extends InheritedWidget { - final QueryBowl bowl; - - QueryBowlScope({ - required this.bowl, - required Widget child, - Key? key, - }) : super( - key: key, - child: MouseRegion( - onEnter: (event) { - bowl.notifyWindowFocused(); - }, - onExit: (event) { - bowl.updateWeLostTheApp(); - }, - child: child, - ), - ); - - @override - bool updateShouldNotify(covariant oldWidget) => false; -} diff --git a/packages/fl_query/lib/src/query_builder.dart b/packages/fl_query/lib/src/query_builder.dart deleted file mode 100644 index 1144713..0000000 --- a/packages/fl_query/lib/src/query_builder.dart +++ /dev/null @@ -1,156 +0,0 @@ -import 'package:fl_query/src/models/query_job.dart'; -import 'package:fl_query/src/query.dart'; -import 'package:fl_query/src/query_bowl.dart'; -import 'package:fl_query/src/utils.dart'; -import 'package:flutter/cupertino.dart'; - -class QueryBuilder extends StatefulWidget { - final Widget Function(BuildContext context, Query query) builder; - final QueryJob job; - final Outside externalData; - - /// Called when the query returns new data, on query - /// refetch or query gets expired - final QueryListener? onData; - - /// Called when the query returns error - final QueryListener? onError; - - const QueryBuilder({ - required this.job, - required this.externalData, - required this.builder, - this.onData, - this.onError, - Key? key, - }) : super(key: key); - - @override - _QueryBuilderState createState() => - _QueryBuilderState(); -} - -class _QueryBuilderState - extends State> { - Query? query; - late final ValueKey uKey; - - @override - void initState() { - super.initState(); - - uKey = ValueKey(uuid.v4()); - - WidgetsBinding.instance.addPostFrameCallback((_) { - init(); - - QueryBowl.of(context).onQueriesUpdate( - (query) { - if (query.queryKey != widget.job.queryKey) return; - if (mounted) - setState(() { - this.query = query; - }); - }, - ); - }); - } - - void init([T? previousData]) async { - final bowl = QueryBowl.of(context); - final prevQuery = bowl.getQuery(widget.job.queryKey); - query = bowl.addQuery( - widget.job, - externalData: widget.externalData, - previousData: previousData, - key: uKey, - onData: widget.onData, - onError: widget.onError, - ); - final hasExternalDataChanged = prevQuery != null - ? !isShallowEqual( - prevQuery.externalData, - prevQuery.prevUsedExternalData, - ) - : !isShallowEqual( - query!.externalData, - query!.prevUsedExternalData, - ); - - if (query!.fetched && hasExternalDataChanged) { - await query!.refetch(); - } else if (!query!.fetched) { - await query!.fetch(); - } - } - - @override - void didUpdateWidget(covariant oldWidget) { - final bowl = QueryBowl.of(context); - final hasOnErrorChanged = - oldWidget.onError != widget.onError && oldWidget.onError != null; - final hasOnDataChanged = - oldWidget.onData != widget.onData && oldWidget.onData != null; - - // re-init the query-builder when new queryJob is appended - if (oldWidget.job.queryKey != widget.job.queryKey) { - _queryDispose(); - - /// setting the new query's initial data as prev query's data - /// when [job.keepPreviousData] is true and both are dynamic - if (oldWidget.job.isDynamic && - widget.job.isDynamic && - oldWidget.job.keepPreviousData == true && - widget.job.keepPreviousData == true) { - init(query?.data); - } else { - init(); - } - } else if (!isShallowEqual(oldWidget.externalData, widget.externalData)) { - if (widget.job.refetchOnExternalDataChange ?? - bowl.refetchOnExternalDataChange) { - bowl.fetchQuery( - widget.job, - externalData: widget.externalData, - onData: widget.onData, - onError: widget.onError, - key: uKey, - ); - } else { - bowl - .getQuery(widget.job.queryKey) - ?.setExternalData(widget.externalData); - } - if (hasOnDataChanged) query?.removeDataListener(oldWidget.onData!); - if (hasOnErrorChanged) query?.removeErrorListener(oldWidget.onError!); - } else { - if (hasOnDataChanged) { - query?.removeDataListener(oldWidget.onData!); - if (widget.onData != null) query?.addDataListener(widget.onData!); - } - if (hasOnErrorChanged) { - query?.removeErrorListener(oldWidget.onError!); - if (widget.onError != null) query?.addErrorListener(widget.onError!); - } - } - super.didUpdateWidget(oldWidget); - } - - _queryDispose() { - query?.unmount(uKey); - if (widget.onData != null) query?.removeDataListener(widget.onData!); - if (widget.onError != null) query?.removeErrorListener(widget.onError!); - } - - @override - void dispose() { - _queryDispose(); - super.dispose(); - } - - @override - Widget build(BuildContext context) { - if (query == null) return Container(); - return widget.builder(context, query!); - } -} diff --git a/packages/fl_query/lib/src/query_cache.dart b/packages/fl_query/lib/src/query_cache.dart deleted file mode 100644 index 308729e..0000000 --- a/packages/fl_query/lib/src/query_cache.dart +++ /dev/null @@ -1,146 +0,0 @@ -import 'package:collection/collection.dart'; -import 'package:fl_query/fl_query.dart'; -import 'package:fl_query/src/base_operation.dart'; - -typedef ReadonlySet = UnmodifiableSetView; - -enum CacheEvent { - clearCache, - query, - infiniteQuery, - mutation, -} - -typedef CacheUpdateListener = void Function(CacheEvent event, T? changes); - -class QueryCache { - /// Removes inactive queries after provided duration of [cacheTime] - final Duration cacheTime; - - QueryCache({Duration? cacheTime}) - : cacheTime = cacheTime ?? const Duration(minutes: 5) {} - - final Set _queries = {}; - final Set _infiniteQueries = {}; - final Set _mutations = {}; - - final Set> _listeners = {}; - - Set get queries => _queries; - Set get infiniteQueries => _infiniteQueries; - Set get mutations => _mutations; - - ReadonlySet> get listeners => - UnmodifiableSetView(_listeners); - - _notifyListeners(CacheEvent event, changes) { - _listeners.forEach((listener) => listener(event, changes)); - } - - _listenToQueryChanges(Query query) { - query.addListener(() { - if (query.isInactive) { - _queries.removeWhere((el) { - if (el.queryKey != query.queryKey) { - el.dispose(); - return true; - } - return false; - }); - _notifyListeners(CacheEvent.query, null); - } else { - _notifyListeners(CacheEvent.query, query); - } - }); - } - - _listenToInfiniteQueryChanges(InfiniteQuery infiniteQuery) { - infiniteQuery.addListener(() { - if (infiniteQuery.isInactive) { - _infiniteQueries.removeWhere((el) { - if (el.queryKey != infiniteQuery.queryKey) { - el.dispose(); - return true; - } - return false; - }); - _notifyListeners(CacheEvent.infiniteQuery, null); - } else { - _notifyListeners(CacheEvent.infiniteQuery, infiniteQuery); - } - }); - } - - _listenToMutationChanges(Mutation mutation) { - mutation.addListener(() { - if (mutation.isInactive) { - _mutations.removeWhere( - (el) { - if (el.mutationKey != mutation.mutationKey) { - el.dispose(); - return true; - } - return false; - }, - ); - _notifyListeners(CacheEvent.mutation, null); - } else { - _notifyListeners(CacheEvent.mutation, mutation); - } - }); - } - - void addQuery(Query query) { - _queries.add(query); - _listenToQueryChanges(query); - _notifyListeners(CacheEvent.query, query); - } - - void addInfiniteQuery(InfiniteQuery infiniteQuery) { - _infiniteQueries.add(infiniteQuery); - _listenToInfiniteQueryChanges(infiniteQuery); - _notifyListeners(CacheEvent.infiniteQuery, infiniteQuery); - } - - void addMutation(Mutation mutation) { - _mutations.add(mutation); - _listenToMutationChanges(mutation); - _notifyListeners(CacheEvent.mutation, mutation); - } - - void removeQuery(Query query) { - query.dispose(); - _queries.remove(query); - _notifyListeners(CacheEvent.query, null); - } - - void removeInfiniteQuery(InfiniteQuery infiniteQuery) { - infiniteQuery.dispose(); - _infiniteQueries.remove(infiniteQuery); - _notifyListeners(CacheEvent.infiniteQuery, null); - } - - void removeMutation(Mutation mutation) { - mutation.dispose(); - _mutations.remove(mutation); - _notifyListeners(CacheEvent.mutation, null); - } - - void clearCache() { - _infiniteQueries.forEach((el) => el.dispose()); - _queries.forEach((el) => el.dispose()); - _mutations.forEach((el) => el.dispose()); - _infiniteQueries.clear(); - _queries.clear(); - _mutations.clear(); - _notifyListeners(CacheEvent.clearCache, null); - } - - void on(CacheUpdateListener listener) { - _listeners.add(listener); - } - - void off(CacheUpdateListener listener) { - _listeners.remove(listener); - } -} diff --git a/packages/fl_query/lib/src/utils.dart b/packages/fl_query/lib/src/utils.dart deleted file mode 100644 index f71bbf4..0000000 --- a/packages/fl_query/lib/src/utils.dart +++ /dev/null @@ -1,72 +0,0 @@ -import 'package:connectivity_plus/connectivity_plus.dart'; -import 'package:fl_query/src/query.dart'; -import 'package:uuid/uuid.dart'; -import 'dart:io' show Platform; -import 'package:flutter/foundation.dart'; - -Future callQueryListeners(Set> listeners, T data) { - return Future.wait(listeners.map( - (listener) => Future.value(listener(data)), - )); - // for (final listener in listeners) { - // await listener(data); - // } -} - -const uuid = Uuid(); - -bool isShallowEqualList(List list1, List list2) { - return list1.asMap().entries.every((l1Entry) { - return l1Entry.value == list2[l1Entry.key]; - }); -} - -bool isShallowEqualSet(Set list1, Set list2) { - return isShallowEqualList(list1.toList(), list2.toList()); -} - -bool isShallowEqualMap(Map list1, Map list2) { - return list1.entries.every((l1Entry) { - return l1Entry.value == list2[l1Entry.key]; - }); -} - -bool isShallowEqual(dynamic obj1, dynamic obj2) { - if (obj1 == null && obj2 == null) return true; - if ((obj1 == null && obj2 != null) || (obj2 == null && obj1 != null)) - return false; - if (obj1 is List && obj2 is List) { - return isShallowEqualList(obj1, obj2); - } else if (obj1 is Set && obj2 is Set) { - return isShallowEqualSet(obj1, obj2); - } else if (obj1 is Map && obj2 is Map) { - return isShallowEqualMap(obj1, obj2); - } else { - // for other types basically comparing references for non primitive - // types. And primitives are always compared by value - return obj1 == obj2; - } -} - -bool isConnectedToInternet(ConnectivityResult result) { - return [ - ConnectivityResult.ethernet, - ConnectivityResult.mobile, - ConnectivityResult.wifi, - ].contains(result); -} - -String getVariable(String queryKey) { - return queryKey.split("#").last; -} - -final kIsDesktop = kIsLinux || kIsWindows || kIsMacOS; - -final kIsMobile = kIsAndroid || kIsIOS; - -final kIsMacOS = kIsWeb ? false : Platform.isMacOS; - -final kIsLinux = kIsWeb ? false : Platform.isLinux; -final kIsAndroid = kIsWeb ? false : Platform.isAndroid; -final kIsIOS = kIsWeb ? false : Platform.isIOS; -final kIsWindows = kIsWeb ? false : Platform.isWindows; diff --git a/packages/fl_query/lib/src/widgets/infinite_query_builder.dart b/packages/fl_query/lib/src/widgets/infinite_query_builder.dart new file mode 100644 index 0000000..517f5fa --- /dev/null +++ b/packages/fl_query/lib/src/widgets/infinite_query_builder.dart @@ -0,0 +1,208 @@ +import 'dart:async'; + +import 'package:fl_query/src/collections/json_config.dart'; +import 'package:fl_query/src/collections/refresh_config.dart'; +import 'package:fl_query/src/collections/retry_config.dart'; +import 'package:fl_query/src/core/client.dart'; +import 'package:fl_query/src/core/infinite_query.dart'; +import 'package:fl_query/src/widgets/mixins/rebuilder.dart'; +import 'package:flutter/foundation.dart'; +import 'package:flutter/material.dart'; + +typedef InfiniteQueryBuilderFn = Widget Function( + BuildContext context, + InfiniteQuery query, +); + +class InfiniteQueryBuilder + extends StatefulWidget { + final InfiniteQueryFn queryFn; + final String queryKey; + + final PageType initialPage; + final InfiniteQueryNextPage nextPage; + + final RetryConfig? retryConfig; + final RefreshConfig? refreshConfig; + final JsonConfig? jsonConfig; + + final ValueChanged>? onData; + final ValueChanged>? onError; + + /// Toggle to fetch data on initial load or not + /// + /// This is useful when you want to fetch data manually after certain action + /// + /// Once user manually fetch data, this will be set to true internally + final bool enabled; + final InfiniteQueryBuilderFn builder; + + const InfiniteQueryBuilder( + this.queryKey, + this.queryFn, { + required this.nextPage, + required this.builder, + required this.initialPage, + this.retryConfig, + this.refreshConfig, + this.jsonConfig, + this.onData, + this.onError, + this.enabled = true, + super.key, + }) : assert( + (jsonConfig != null && enabled) || jsonConfig == null, + 'jsonConfig is only supported when enabled is true', + ); + + @override + State> createState() => + _InfiniteQueryBuilderState(); +} + +class _InfiniteQueryBuilderState + extends State> + with SafeRebuild { + InfiniteQuery? query; + + VoidCallback? removeListener; + + StreamSubscription>? dataSubscription; + StreamSubscription>? errorSubscription; + + Future initialize(QueryClient client) async { + setState(() { + _createQuery(client); + + if (widget.onData != null) + dataSubscription = query!.dataStream.listen(widget.onData); + if (widget.onError != null) + errorSubscription = query!.errorStream.listen(widget.onError); + + removeListener = query!.addListener(rebuild); + }); + if (widget.enabled) { + await query!.fetch(); + } + } + + void _createQuery(QueryClient client) { + query = client.createInfiniteQuery( + widget.queryKey, + widget.queryFn, + initialParam: widget.initialPage, + nextPage: widget.nextPage, + retryConfig: widget.retryConfig, + refreshConfig: widget.refreshConfig, + jsonConfig: widget.jsonConfig, + ); + } + + @override + void initState() { + super.initState(); + WidgetsBinding.instance.addPostFrameCallback((_) { + initialize(QueryClient.of(context)); + }); + } + + @override + void dispose() { + dataSubscription?.cancel(); + errorSubscription?.cancel(); + removeListener?.call(); + super.dispose(); + } + + @override + void didUpdateWidget(oldWidget) { + super.didUpdateWidget(oldWidget); + + if (oldWidget.queryKey != widget.queryKey) { + dataSubscription?.cancel(); + errorSubscription?.cancel(); + removeListener?.call(); + initialize(QueryClient.of(context)); + return; + } else if (oldWidget.enabled != widget.enabled && widget.enabled) { + query!.fetch(); + } + if (oldWidget.queryFn != widget.queryFn) { + query!.updateQueryFn(widget.queryFn); + } + if (oldWidget.nextPage != widget.nextPage) { + query!.updateNextPageFn(widget.nextPage); + } + if (oldWidget.onData != widget.onData) { + dataSubscription?.cancel(); + if (widget.onData != null) + dataSubscription = query!.dataStream.listen(widget.onData); + } + if (oldWidget.onError != widget.onError) { + errorSubscription?.cancel(); + if (widget.onError != null) + errorSubscription = query!.errorStream.listen(widget.onError); + } + } + + @override + Widget build(BuildContext context) { + if (query == null) { + _createQuery(QueryClient.of(context)); + } + return widget.builder(context, query!); + } + + @override + void debugFillProperties(DiagnosticPropertiesBuilder properties) { + super.debugFillProperties(properties); + properties.add(DiagnosticsProperty< + InfiniteQueryBuilderFn>( + 'builder', + widget.builder, + )); + properties.add(DiagnosticsProperty>( + 'queryFn', + widget.queryFn, + )); + properties + .add(DiagnosticsProperty>( + 'nextPage', + widget.nextPage, + )); + properties.add(DiagnosticsProperty( + 'initialPage', + widget.initialPage, + )); + properties.add(DiagnosticsProperty( + 'retryConfig', + widget.retryConfig, + )); + properties.add(DiagnosticsProperty( + 'refreshConfig', + widget.refreshConfig, + )); + properties.add(DiagnosticsProperty>( + 'jsonConfig', + widget.jsonConfig, + )); + properties + .add(DiagnosticsProperty>>( + 'onData', + widget.onData, + )); + properties + .add(DiagnosticsProperty>>( + 'onError', + widget.onError, + )); + properties.add(DiagnosticsProperty( + 'enabled', + widget.enabled, + )); + properties.add(DiagnosticsProperty( + 'queryKey', + widget.queryKey, + )); + } +} diff --git a/packages/fl_query/lib/src/widgets/infinite_query_listenable.dart b/packages/fl_query/lib/src/widgets/infinite_query_listenable.dart new file mode 100644 index 0000000..d8c1c37 --- /dev/null +++ b/packages/fl_query/lib/src/widgets/infinite_query_listenable.dart @@ -0,0 +1,75 @@ +import 'dart:async'; + +import 'package:fl_query/fl_query.dart'; +import 'package:fl_query/src/widgets/mixins/rebuilder.dart'; +import 'package:flutter/material.dart'; +import 'package:fl_query/src/widgets/state_notifier_listenable.dart'; + +typedef InfiniteQueryListenableBuilder = Widget + Function( + BuildContext context, + InfiniteQuery? query, +); + +class InfiniteQueryListenable + extends StatefulWidget { + final String queryKey; + final InfiniteQueryListenableBuilder builder; + const InfiniteQueryListenable( + this.queryKey, { + required this.builder, + super.key, + }); + + @override + State> createState() => + _InfiniteQueryListenableState(); +} + +class _InfiniteQueryListenableState + extends State> + with SafeRebuild { + StreamSubscription? _subscription; + + @override + void initState() { + super.initState(); + WidgetsBinding.instance.addPostFrameCallback((timeStamp) { + _subscription = QueryClient.of(context).cache.events.listen((event) { + switch (event.type) { + case QueryCacheEventType.addInfiniteQuery: + case QueryCacheEventType.removeInfiniteQuery: + if ((event.data as InfiniteQuery).key == widget.queryKey) { + rebuild(); + } + break; + default: + } + }); + }); + } + + @override + void dispose() { + _subscription?.cancel(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + final query = QueryClient.of(context) + .getInfiniteQuery(widget.queryKey); + + if (query == null) { + return widget.builder(context, null); + } + return StateNotifierListenable< + InfiniteQueryState>( + notifier: query, + builder: (context, notifier) { + final query = notifier as InfiniteQuery; + return widget.builder(context, query); + }, + ); + } +} diff --git a/packages/fl_query/lib/src/widgets/mixins/rebuilder.dart b/packages/fl_query/lib/src/widgets/mixins/rebuilder.dart new file mode 100644 index 0000000..12209c0 --- /dev/null +++ b/packages/fl_query/lib/src/widgets/mixins/rebuilder.dart @@ -0,0 +1,25 @@ +import 'package:flutter/material.dart'; +import 'package:flutter/scheduler.dart'; + +/// Guarantees that the [setState] method is called only if the widget is +/// mounted and not in the middle of a frame. If it is in the middle of a frame, +/// it will wait for the end of the frame and then call [setState]. Which ensures +/// updates are not lost/skipped. +/// +/// Shamelessly copied from [StackOverflow](https://stackoverflow.com/a/64702218/13292290) +/// +/// Thanks to [dev-aggarwal](https://stackoverflow.com/users/7061265/dev-aggarwal) +mixin SafeRebuild on State { + Future rebuild([_]) async { + if (!mounted) return; + + // if there's a current frame, + if (SchedulerBinding.instance.schedulerPhase != SchedulerPhase.idle) { + // wait for the end of that frame. + await SchedulerBinding.instance.endOfFrame; + if (!mounted) return; + } + + setState(() {}); + } +} diff --git a/packages/fl_query/lib/src/widgets/mutation_builder.dart b/packages/fl_query/lib/src/widgets/mutation_builder.dart new file mode 100644 index 0000000..ab6e639 --- /dev/null +++ b/packages/fl_query/lib/src/widgets/mutation_builder.dart @@ -0,0 +1,246 @@ +import 'dart:async'; + +import 'package:fl_query/src/collections/retry_config.dart'; +import 'package:fl_query/src/core/client.dart'; +import 'package:fl_query/src/core/mutation.dart'; +import 'package:fl_query/src/widgets/mixins/rebuilder.dart'; +import 'package:flutter/foundation.dart'; +import 'package:flutter/material.dart'; + +typedef MutationBuilderFn = Widget Function( + BuildContext context, + Mutation mutation, +); +typedef MutationOnDataFn = void Function( + DataType data, + RecoveryType? recoveryData, +); +typedef MutationOnErrorFn = void Function( + ErrorType error, + RecoveryType? recoveryData, +); +typedef MutationOnMutationFn + = FutureOr Function( + VariablesType variables, +); + +class MutationBuilder + extends StatefulWidget { + final MutationFn mutationFn; + final String mutationKey; + + final RetryConfig? retryConfig; + + final MutationOnDataFn? onData; + final MutationOnErrorFn? onError; + final MutationOnMutationFn? onMutate; + + // widget specific + final MutationBuilderFn builder; + final List? refreshQueries; + final List? refreshInfiniteQueries; + + const MutationBuilder( + this.mutationKey, + this.mutationFn, { + required this.builder, + this.retryConfig, + this.onData, + this.onError, + this.onMutate, + this.refreshQueries, + this.refreshInfiniteQueries, + super.key, + }); + + @override + State> + createState() => _MutationBuilderState(); +} + +class _MutationBuilderState + extends State< + MutationBuilder> + with SafeRebuild { + Mutation? mutation; + + VoidCallback? removeListener; + + StreamSubscription? mutationSubscription; + StreamSubscription? dataSubscription; + StreamSubscription? errorSubscription; + + RecoveryType? recoveryData; + + void subscribeOnMutate(QueryClient client) { + if (widget.onMutate != null) + mutationSubscription = mutation!.mutationStream.listen( + (event) async { + recoveryData = await widget.onMutate?.call(event); + + if (widget.onData != null) { + dataSubscription?.cancel(); + subscribeOnData(client); + } + + if (widget.onError != null) { + errorSubscription?.cancel(); + subscribeOnError(); + } + }, + ); + } + + void subscribeOnData(QueryClient client) { + if (widget.onData != null || + widget.refreshInfiniteQueries != null || + widget.refreshQueries != null) + dataSubscription = mutation!.dataStream.listen( + (event) { + final data = widget.onData?.call(event, recoveryData); + if (widget.refreshQueries != null && mounted) { + client.refreshQueries(widget.refreshQueries!); + } + if (widget.refreshInfiniteQueries != null && mounted) { + client + .refreshInfiniteQueriesAllPages(widget.refreshInfiniteQueries!); + } + return data; + }, + ); + } + + void subscribeOnError() { + if (widget.onError != null) + errorSubscription = mutation!.errorStream.listen( + (event) { + return widget.onError?.call(event, recoveryData); + }, + ); + } + + Future initialize(QueryClient client) async { + setState(() { + _createMutation(client); + subscribeOnMutate(client); + subscribeOnData(client); + subscribeOnError(); + removeListener = mutation!.addListener(rebuild); + }); + } + + void _createMutation(QueryClient client) { + mutation = client.createMutation( + widget.mutationKey, + widget.mutationFn, + retryConfig: widget.retryConfig, + ); + } + + @override + void initState() { + super.initState(); + WidgetsBinding.instance.addPostFrameCallback((_) async { + await initialize(QueryClient.of(context)); + }); + } + + @override + void dispose() { + mutationSubscription?.cancel(); + dataSubscription?.cancel(); + errorSubscription?.cancel(); + removeListener?.call(); + super.dispose(); + } + + @override + void didUpdateWidget( + MutationBuilder oldWidget, + ) { + super.didUpdateWidget(oldWidget); + + final client = QueryClient.of(context); + + if (oldWidget.mutationKey != widget.mutationKey) { + mutationSubscription?.cancel(); + dataSubscription?.cancel(); + errorSubscription?.cancel(); + removeListener?.call(); + initialize(client); + return; + } + if (oldWidget.mutationFn != widget.mutationFn) { + mutation!.updateMutationFn(widget.mutationFn); + } + if (oldWidget.onMutate != widget.onMutate) { + mutationSubscription?.cancel(); + subscribeOnMutate(client); + } + if (oldWidget.onData != widget.onData || + oldWidget.refreshQueries != widget.refreshQueries || + oldWidget.refreshInfiniteQueries != widget.refreshInfiniteQueries) { + dataSubscription?.cancel(); + subscribeOnData(client); + mutationSubscription?.cancel(); + subscribeOnMutate(client); + } + if (oldWidget.onError != widget.onError) { + errorSubscription?.cancel(); + subscribeOnError(); + } + } + + @override + Widget build(BuildContext context) { + if (mutation == null) { + _createMutation(QueryClient.of(context)); + } + return widget.builder(context, mutation!); + } + + @override + void debugFillProperties(DiagnosticPropertiesBuilder properties) { + super.debugFillProperties(properties); + properties.add( + DiagnosticsProperty>( + 'mutation', mutation), + ); + properties.add( + DiagnosticsProperty('mutationKey', widget.mutationKey), + ); + properties.add( + DiagnosticsProperty>( + 'mutationFn', widget.mutationFn), + ); + properties.add( + DiagnosticsProperty('retryConfig', widget.retryConfig), + ); + properties.add( + DiagnosticsProperty>( + 'onData', + widget.onData, + ), + ); + properties.add( + DiagnosticsProperty>( + 'onError', + widget.onError, + ), + ); + properties.add( + DiagnosticsProperty>( + 'onMutation', + widget.onMutate, + ), + ); + properties.add( + DiagnosticsProperty< + MutationBuilderFn>( + 'builder', + widget.builder, + ), + ); + } +} diff --git a/packages/fl_query/lib/src/widgets/query_builder.dart b/packages/fl_query/lib/src/widgets/query_builder.dart new file mode 100644 index 0000000..0616990 --- /dev/null +++ b/packages/fl_query/lib/src/widgets/query_builder.dart @@ -0,0 +1,182 @@ +import 'dart:async'; + +import 'package:fl_query/src/collections/json_config.dart'; +import 'package:fl_query/src/collections/refresh_config.dart'; +import 'package:fl_query/src/collections/retry_config.dart'; +import 'package:fl_query/src/core/client.dart'; +import 'package:fl_query/src/core/query.dart'; +import 'package:fl_query/src/widgets/mixins/rebuilder.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/foundation.dart'; + +typedef QueryBuilderFn = Widget Function( + BuildContext context, + Query query, +); + +class QueryBuilder extends StatefulWidget { + final QueryFn queryFn; + final String queryKey; + + final DataType? initial; + + final RetryConfig? retryConfig; + final RefreshConfig? refreshConfig; + final JsonConfig? jsonConfig; + + final ValueChanged? onData; + final ValueChanged? onError; + + // widget specific + final bool enabled; + final QueryBuilderFn builder; + + const QueryBuilder( + this.queryKey, + this.queryFn, { + required this.builder, + this.initial, + this.retryConfig, + this.refreshConfig, + this.jsonConfig, + this.onData, + this.onError, + this.enabled = true, + super.key, + }) : assert( + (jsonConfig != null && enabled) || jsonConfig == null, + 'jsonConfig is only supported when enabled is true', + ); + + @override + State> createState() => + _QueryBuilderState(); +} + +class _QueryBuilderState + extends State> with SafeRebuild { + Query? query; + + VoidCallback? removeListener; + + StreamSubscription? dataSubscription; + StreamSubscription? errorSubscription; + + void _createQuery(QueryClient client) { + query = client.createQuery( + widget.queryKey, + widget.queryFn, + initial: widget.initial, + retryConfig: widget.retryConfig, + refreshConfig: widget.refreshConfig, + jsonConfig: widget.jsonConfig, + ); + } + + Future initialize(QueryClient client) async { + setState(() { + _createQuery(client); + if (widget.onData != null) + dataSubscription = query!.dataStream.listen(widget.onData); + if (widget.onData != null) + errorSubscription = query!.errorStream.listen(widget.onError); + + removeListener = query!.addListener(rebuild); + }); + if (widget.enabled) { + await query!.fetch(); + } + } + + @override + void initState() { + super.initState(); + WidgetsBinding.instance.addPostFrameCallback((_) async { + await initialize(QueryClient.of(context)); + }); + } + + @override + void dispose() { + dataSubscription?.cancel(); + errorSubscription?.cancel(); + removeListener?.call(); + super.dispose(); + } + + @override + void didUpdateWidget( + QueryBuilder oldWidget, + ) { + super.didUpdateWidget(oldWidget); + + if (oldWidget.queryKey != widget.queryKey) { + dataSubscription?.cancel(); + errorSubscription?.cancel(); + removeListener?.call(); + initialize(QueryClient.of(context)); + return; + } else if (oldWidget.enabled != widget.enabled && widget.enabled) { + query!.fetch(); + } + if (oldWidget.queryFn != widget.queryFn) { + query!.updateQueryFn(widget.queryFn); + } + if (oldWidget.onData != widget.onData) { + dataSubscription?.cancel(); + if (widget.onData != null) + dataSubscription = query!.dataStream.listen(widget.onData); + } + if (oldWidget.onError != widget.onError) { + errorSubscription?.cancel(); + if (widget.onError != null) + errorSubscription = query!.errorStream.listen(widget.onError); + } + } + + @override + Widget build(BuildContext context) { + if (query == null) { + _createQuery(QueryClient.of(context)); + } + return widget.builder(context, query!); + } + + @override + void debugFillProperties(DiagnosticPropertiesBuilder properties) { + super.debugFillProperties(properties); + properties.add( + DiagnosticsProperty>('query', query), + ); + properties.add( + DiagnosticsProperty('queryKey', widget.queryKey), + ); + properties.add( + DiagnosticsProperty>( + 'builder', widget.builder), + ); + properties.add(DiagnosticsProperty('initial', widget.initial)); + properties.add( + DiagnosticsProperty('retryConfig', widget.retryConfig), + ); + properties.add( + DiagnosticsProperty( + 'refreshConfig', + widget.refreshConfig, + ), + ); + properties.add( + DiagnosticsProperty>( + 'jsonConfig', + widget.jsonConfig, + ), + ); + properties.add( + DiagnosticsProperty>('onData', widget.onData), + ); + properties.add( + DiagnosticsProperty>('onError', widget.onError), + ); + properties.add(DiagnosticsProperty('enabled', widget.enabled)); + } +} diff --git a/packages/fl_query/lib/src/widgets/query_listenable.dart b/packages/fl_query/lib/src/widgets/query_listenable.dart new file mode 100644 index 0000000..f8fdaeb --- /dev/null +++ b/packages/fl_query/lib/src/widgets/query_listenable.dart @@ -0,0 +1,71 @@ +import 'dart:async'; + +import 'package:fl_query/fl_query.dart'; +import 'package:fl_query/src/widgets/mixins/rebuilder.dart'; +import 'package:flutter/material.dart'; +import 'package:fl_query/src/widgets/state_notifier_listenable.dart'; + +typedef QueryListenableBuilder = Widget Function( + BuildContext context, + Query? query, +); + +class QueryListenable extends StatefulWidget { + final String queryKey; + final QueryListenableBuilder builder; + const QueryListenable( + this.queryKey, { + required this.builder, + super.key, + }); + + @override + State> createState() => + _QueryListenableState(); +} + +class _QueryListenableState + extends State> with SafeRebuild { + StreamSubscription? _subscription; + + @override + void initState() { + super.initState(); + WidgetsBinding.instance.addPostFrameCallback((timeStamp) { + _subscription = QueryClient.of(context).cache.events.listen((event) { + switch (event.type) { + case QueryCacheEventType.addQuery: + case QueryCacheEventType.removeQuery: + if ((event.data as Query).key == widget.queryKey) { + rebuild(); + } + break; + default: + } + }); + }); + } + + @override + void dispose() { + _subscription?.cancel(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + final query = + QueryClient.of(context).getQuery(widget.queryKey); + + if (query == null) { + return widget.builder(context, null); + } + return StateNotifierListenable>( + notifier: query, + builder: (context, notifier) { + final query = notifier as Query; + return widget.builder(context, query); + }, + ); + } +} diff --git a/packages/fl_query/lib/src/widgets/state_notifier_listenable.dart b/packages/fl_query/lib/src/widgets/state_notifier_listenable.dart new file mode 100644 index 0000000..245d42e --- /dev/null +++ b/packages/fl_query/lib/src/widgets/state_notifier_listenable.dart @@ -0,0 +1,60 @@ +import 'package:flutter/material.dart'; +import 'package:state_notifier/state_notifier.dart'; + +typedef StateNotifierListenableBuilder = Widget Function( + BuildContext context, + StateNotifier value, +); + +class StateNotifierListenable extends StatefulWidget { + final StateNotifier notifier; + final StateNotifierListenableBuilder builder; + const StateNotifierListenable({ + required this.notifier, + required this.builder, + super.key, + }); + + @override + State> createState() => + _StateNotifierListenableState(); +} + +class _StateNotifierListenableState + extends State> { + VoidCallback? removeListener; + + void initialize() { + removeListener = widget.notifier.addListener((_) { + if (mounted) setState(() {}); + }); + } + + @override + void initState() { + super.initState(); + WidgetsBinding.instance.addPostFrameCallback((_) { + initialize(); + }); + } + + @override + void dispose() { + removeListener?.call(); + super.dispose(); + } + + @override + void didUpdateWidget(covariant StateNotifierListenable oldWidget) { + super.didUpdateWidget(oldWidget); + if (oldWidget.notifier != widget.notifier) { + removeListener?.call(); + initialize(); + } + } + + @override + Widget build(BuildContext context) { + return widget.builder(context, widget.notifier); + } +} diff --git a/packages/fl_query/lib/src/widgets/state_resolvers/infinite_query_state.dart b/packages/fl_query/lib/src/widgets/state_resolvers/infinite_query_state.dart new file mode 100644 index 0000000..e26fbab --- /dev/null +++ b/packages/fl_query/lib/src/widgets/state_resolvers/infinite_query_state.dart @@ -0,0 +1,40 @@ +import 'package:flutter/widgets.dart'; + +class InfiniteQueryStateResolverProvider extends InheritedWidget { + final Widget Function(List errors)? error; + final Widget Function()? loading; + final Widget Function()? offline; + + InfiniteQueryStateResolverProvider({ + this.error, + this.loading, + this.offline, + required super.child, + }) : assert( + error != null || loading != null || offline != null, + 'Why are you using `InfiniteQueryStateResolverProvider` with no resolver?\n' + 'You should provide at least one resolver.', + ); + + static InfiniteQueryStateResolverProvider? maybeOf(BuildContext context) { + return context.dependOnInheritedWidgetOfExactType< + InfiniteQueryStateResolverProvider>(); + } + + static InfiniteQueryStateResolverProvider of(BuildContext context) { + final provider = maybeOf(context); + assert( + provider != null, + 'You are trying to access a `InfiniteQueryStateResolverProvider` outside of its scope.\n' + 'You should wrap your widget tree with `InfiniteQueryStateResolverProvider`.', + ); + return provider!; + } + + @override + bool updateShouldNotify(InfiniteQueryStateResolverProvider oldWidget) { + return error != oldWidget.error || + loading != oldWidget.loading || + offline != oldWidget.offline; + } +} diff --git a/packages/fl_query/lib/src/widgets/state_resolvers/mutation_state.dart b/packages/fl_query/lib/src/widgets/state_resolvers/mutation_state.dart new file mode 100644 index 0000000..a23d349 --- /dev/null +++ b/packages/fl_query/lib/src/widgets/state_resolvers/mutation_state.dart @@ -0,0 +1,43 @@ +import 'package:flutter/widgets.dart'; + +class MutationStateResolverProvider extends InheritedWidget { + final Widget Function(dynamic error)? error; + final Widget Function()? loading; + final Widget Function()? offline; + final Widget Function()? mutating; + + MutationStateResolverProvider({ + this.error, + this.loading, + this.offline, + this.mutating, + required super.child, + }) : assert( + error != null || loading != null || offline != null, + 'Why are you using `MutationStateResolverProvider` with no resolver?\n' + 'You should provide at least one resolver.', + ); + + static MutationStateResolverProvider? maybeOf(BuildContext context) { + return context + .dependOnInheritedWidgetOfExactType(); + } + + static MutationStateResolverProvider of(BuildContext context) { + final provider = maybeOf(context); + assert( + provider != null, + 'You are trying to access a `MutationStateResolverProvider` outside of its scope.\n' + 'You should wrap your widget tree with `MutationStateResolverProvider`.', + ); + return provider!; + } + + @override + bool updateShouldNotify(MutationStateResolverProvider oldWidget) { + return error != oldWidget.error || + loading != oldWidget.loading || + offline != oldWidget.offline || + mutating != oldWidget.mutating; + } +} diff --git a/packages/fl_query/lib/src/widgets/state_resolvers/query_state.dart b/packages/fl_query/lib/src/widgets/state_resolvers/query_state.dart new file mode 100644 index 0000000..69632e7 --- /dev/null +++ b/packages/fl_query/lib/src/widgets/state_resolvers/query_state.dart @@ -0,0 +1,40 @@ +import 'package:flutter/widgets.dart'; + +class QueryStateResolverProvider extends InheritedWidget { + final Widget Function(dynamic error)? error; + final Widget Function()? loading; + final Widget Function()? offline; + + QueryStateResolverProvider({ + this.error, + this.loading, + this.offline, + required super.child, + }) : assert( + error != null || loading != null || offline != null, + 'Why are you using `QueryStateResolverProvider` with no resolver?\n' + 'You should provide at least one resolver.', + ); + + static QueryStateResolverProvider? maybeOf(BuildContext context) { + return context + .dependOnInheritedWidgetOfExactType(); + } + + static QueryStateResolverProvider of(BuildContext context) { + final provider = maybeOf(context); + assert( + provider != null, + 'You are trying to access a `QueryStateResolverProvider` outside of its scope.\n' + 'You should wrap your widget tree with `QueryStateResolverProvider`.', + ); + return provider!; + } + + @override + bool updateShouldNotify(QueryStateResolverProvider oldWidget) { + return error != oldWidget.error || + loading != oldWidget.loading || + offline != oldWidget.offline; + } +} diff --git a/packages/fl_query/pubspec.yaml b/packages/fl_query/pubspec.yaml index f0619e6..d2d41d2 100644 --- a/packages/fl_query/pubspec.yaml +++ b/packages/fl_query/pubspec.yaml @@ -1,29 +1,27 @@ name: fl_query description: Asynchronous data caching, refetching & invalidation library for Flutter -version: 0.3.1 +version: 1.0.0-alpha.5 + homepage: https://fl-query.vercel.app - issue_tracker: https://github.com/KRTirtho/fl-query/issues - -repository: https://github.com/KRTirtho/fl-query - +repository: https://github.com/KRTirtho/fl-query/tree/main/packages/fl_query environment: - sdk: ">=2.17.1 <3.0.0" + sdk: ">=2.17.1 <4.0.0" flutter: ">=1.17.0" dependencies: - collection: ^1.16.0 - connectivity_plus: ^2.3.9 flutter: sdk: flutter + async: ^2.10.0 + collection: ^1.16.0 hive_flutter: ^1.1.0 - queue: ^3.1.0+1 - uuid: ^3.0.6 + mutex: ^3.0.1 + state_notifier: ^0.7.2+1 dev_dependencies: + build_runner: ^2.2.0 + flutter_lints: ^2.0.0 flutter_test: sdk: flutter - flutter_lints: ^2.0.0 mockito: ^5.2.0 - build_runner: ^2.2.0 diff --git a/packages/fl_query/test/query_test.dart b/packages/fl_query/test/query_test.dart deleted file mode 100644 index 5fd0333..0000000 --- a/packages/fl_query/test/query_test.dart +++ /dev/null @@ -1,241 +0,0 @@ -import 'dart:math'; - -import 'package:connectivity_plus/connectivity_plus.dart'; -import 'package:fl_query/src/models/query_job.dart'; -import 'package:fl_query/src/query.dart'; -import 'package:fl_query/src/query_bowl.dart'; -import 'package:fl_query/src/utils.dart'; -import 'package:flutter/widgets.dart'; -import 'package:flutter_test/flutter_test.dart'; -import 'package:mockito/annotations.dart'; -import 'package:mockito/mockito.dart'; -import 'query_test.mocks.dart'; - -@GenerateMocks( - [QueryBowl, Connectivity], - customMocks: [ - MockSpec>( - as: #MockQueryJobVoidObject, - returnNullOnMissingStub: true, - ), - ], -) -void main() { - // for testing query without external data - late Query query; - late MockQueryJobVoidObject queryJob; - setUp(() { - queryJob = MockQueryJobVoidObject(); - when(queryJob.queryKey).thenReturn("test"); - when(queryJob.task).thenAnswer( - (_) => - (_, __) => Future.delayed(Duration(milliseconds: 300), () => "test"), - ); - query = Query.fromOptions( - queryJob, - externalData: null, - ); - }); - - group("Query Test", () { - test("default values", () { - expect(query.enabled, isTrue); - expect(query.refetchCount, 0); - expect(query.retries, 3); - expect(query.retryAttempts, 0); - expect(query.fetched, isFalse); - expect(query.retryDelay, Duration(milliseconds: 200)); - expect(query.status, QueryStatus.idle); - expect(query.isStale, isFalse); - expect(query.isIdle, true); - expect(query.isInactive, isTrue); - expect(query.isLoading, isFalse); - expect(query.isSuccess, isFalse); - expect(query.hasError, isFalse); - expect(query.hasData, isFalse); - }); - - test("calling fetch for the first time runs the _execute method", () async { - final data = await query.fetch(); - expect(data, "test"); - expect(query.fetched, isTrue); - verify(queryJob.task).called(1); - }); - - test( - "calling fetch twice or more should return same data where _execute gets called once", - () async { - final data1 = await query.fetch(); - final data2 = await query.fetch(); - - await query.fetch(); - await query.fetch(); - expect(data1, data2); - verify(queryJob.task).called(1); - }); - - test('calling refetch should return new data', () async { - reset(queryJob); - when(queryJob.queryKey).thenReturn("test"); - when(queryJob.task).thenAnswer( - (_) => (_, __) => Future.value(Random().nextInt(100)), - ); - query = Query.fromOptions( - queryJob, - externalData: null, - ); - - await Future.delayed(Duration(milliseconds: 100)); - await query.fetch().then((data) async { - final refetchData = await query.refetch(); - expect(data, isNot(equals(refetchData))); - }); - }); - - test( - "refetch should not run When another refetch is already running", - () async { - await query.fetch(); - await Future.delayed(Duration(milliseconds: 100)); - await Future.wait([ - query.refetch(), - query.refetch(), - ]); - expect(query.refetchCount, 1); - }, - ); - test( - "failing task should be retried the amount of times passed as retries parameter", - () async { - reset(queryJob); - when(queryJob.queryKey).thenReturn("test"); - when(queryJob.task).thenAnswer( - (_) => (_, __) => Future.error("Error"), - ); - query = Query.fromOptions( - queryJob, - externalData: null, - ); - - await query.fetch(); - - expect(query.retryAttempts, 3); - expect(query.isError, true); - }, - ); - test( - "onData listeners are called When new data is fetched and set", - () async { - int count = 0; - query.addDataListener((_) { - count++; - }); - await query.fetch(); - expect(count, 1); - }, - ); - test( - "onError listeners are called When any error occurs", - () async { - reset(queryJob); - when(queryJob.queryKey).thenReturn("test"); - when(queryJob.task).thenAnswer( - (_) => (_, __) => Future.error("Error"), - ); - query = Query.fromOptions( - queryJob, - externalData: null, - ); - int count = 0; - query.addErrorListener((_) { - count++; - }); - await query.fetch(); - expect(count, 1); - }, - ); - test("query should become stale after defined amount time", () async { - when(queryJob.staleTime).thenReturn(Duration(milliseconds: 500)); - query = Query.fromOptions( - queryJob, - externalData: null, - ); - expect(query.isStale, isFalse); - await Future.delayed(Duration(milliseconds: 300)); - expect(query.isStale, isFalse); - await Future.delayed(Duration(milliseconds: 600)); - expect(query.isStale, isTrue); - }); - test( - "query should refetch in interval When refetchInterval is specified", - () async { - reset(queryJob); - when(queryJob.queryKey).thenReturn("test"); - when(queryJob.task).thenAnswer( - (_) => (_, __) => Future.value(Random().nextInt(100)), - ); - when(queryJob.staleTime).thenReturn( - Duration(milliseconds: 1), - ); - when(queryJob.refetchInterval).thenReturn( - Duration(milliseconds: 200), - ); - query = Query.fromOptions( - queryJob, - externalData: null, - ); - - final data = await query.fetch(); - await Future.delayed(Duration(milliseconds: 400)); - expect(data, isNot(equals(await query.fetch()))); - }, - ); - test( - "query should revalidate When a new caller gets mounted", - () async { - reset(queryJob); - when(queryJob.queryKey).thenReturn("test"); - when(queryJob.task).thenAnswer( - (_) => (_, __) => Future.value(Random().nextInt(150)), - ); - when(queryJob.refetchOnMount).thenReturn(true); - query = Query.fromOptions( - queryJob, - externalData: null, - ); - final data = await query.fetch(); - query.invalidate(); - query.mount(ValueKey(uuid.v4())); - await Future.delayed(Duration(milliseconds: 100)); - expect(data, isNot(equals(await query.fetch()))); - expect(query.refetchCount, 1); - }, - ); - test( - "query should not revalidate When there's no Internet Connectivity and a new caller gets mounted", - () async { - final connectivityMock = MockConnectivity(); - when(connectivityMock.checkConnectivity()).thenAnswer( - (_) async => ConnectivityResult.none, - ); - reset(queryJob); - when(queryJob.queryKey).thenReturn("test"); - when(queryJob.task).thenAnswer( - (_) => (_, __) => Future.value(Random().nextInt(150)), - ); - when(queryJob.connectivity).thenReturn(connectivityMock); - when(queryJob.refetchOnMount).thenReturn(true); - query = Query.fromOptions( - queryJob, - externalData: null, - ); - final data = await query.fetch(); - query.invalidate(); - query.mount(ValueKey(uuid.v4())); - await Future.delayed(Duration(milliseconds: 100)); - expect(data, equals(await query.fetch())); - expect(query.refetchCount, 0); - }, - ); - }); -} diff --git a/packages/fl_query/test/query_test.mocks.dart b/packages/fl_query/test/query_test.mocks.dart deleted file mode 100644 index c42bb79..0000000 --- a/packages/fl_query/test/query_test.mocks.dart +++ /dev/null @@ -1,318 +0,0 @@ -// Mocks generated by Mockito 5.3.0 from annotations -// in fl_query/test/query_test.dart. -// Do not manually edit this file. - -// ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i4; - -import 'package:connectivity_plus/connectivity_plus.dart' as _i6; -import 'package:fl_query/fl_query.dart' as _i3; -import 'package:fl_query/src/query_cache.dart' as _i2; -import 'package:flutter/cupertino.dart' as _i5; -import 'package:mockito/mockito.dart' as _i1; - -// ignore_for_file: type=lint -// ignore_for_file: avoid_redundant_argument_values -// ignore_for_file: avoid_setters_without_getters -// ignore_for_file: comment_references -// ignore_for_file: implementation_imports -// ignore_for_file: invalid_use_of_visible_for_testing_member -// ignore_for_file: prefer_const_constructors -// ignore_for_file: unnecessary_parenthesis -// ignore_for_file: camel_case_types -// ignore_for_file: subtype_of_sealed_class - -class _FakeDuration_0 extends _i1.SmartFake implements Duration { - _FakeDuration_0(Object parent, Invocation parentInvocation) - : super(parent, parentInvocation); -} - -class _FakeQueryCache_1 extends _i1.SmartFake implements _i2.QueryCache { - _FakeQueryCache_1(Object parent, Invocation parentInvocation) - : super(parent, parentInvocation); -} - -class _FakeQuery_2 extends _i1.SmartFake - implements _i3.Query { - _FakeQuery_2(Object parent, Invocation parentInvocation) - : super(parent, parentInvocation); -} - -class _FakeInfiniteQuery_3 - extends _i1.SmartFake implements _i3.InfiniteQuery { - _FakeInfiniteQuery_3(Object parent, Invocation parentInvocation) - : super(parent, parentInvocation); -} - -class _FakeMutation_4 extends _i1.SmartFake - implements _i3.Mutation { - _FakeMutation_4(Object parent, Invocation parentInvocation) - : super(parent, parentInvocation); -} - -class _FakeObject_5 extends _i1.SmartFake implements Object { - _FakeObject_5(Object parent, Invocation parentInvocation) - : super(parent, parentInvocation); -} - -/// A class which mocks [QueryBowl]. -/// -/// See the documentation for Mockito's code generation for more information. -class MockQueryBowl extends _i1.Mock implements _i3.QueryBowl { - MockQueryBowl() { - _i1.throwOnMissingStub(this); - } - - @override - Duration get staleTime => (super.noSuchMethod(Invocation.getter(#staleTime), - returnValue: _FakeDuration_0(this, Invocation.getter(#staleTime))) - as Duration); - @override - bool get refetchOnMount => (super - .noSuchMethod(Invocation.getter(#refetchOnMount), returnValue: false) - as bool); - @override - bool get refetchOnWindowFocus => - (super.noSuchMethod(Invocation.getter(#refetchOnWindowFocus), - returnValue: false) as bool); - @override - bool get refetchOnApplicationResume => - (super.noSuchMethod(Invocation.getter(#refetchOnApplicationResume), - returnValue: false) as bool); - @override - bool get refetchOnReconnect => - (super.noSuchMethod(Invocation.getter(#refetchOnReconnect), - returnValue: false) as bool); - @override - Duration get refetchOnReconnectDelay => - (super.noSuchMethod(Invocation.getter(#refetchOnReconnectDelay), - returnValue: _FakeDuration_0( - this, Invocation.getter(#refetchOnReconnectDelay))) as Duration); - @override - bool get refetchOnExternalDataChange => - (super.noSuchMethod(Invocation.getter(#refetchOnExternalDataChange), - returnValue: false) as bool); - @override - Duration get refetchInterval => - (super.noSuchMethod(Invocation.getter(#refetchInterval), - returnValue: - _FakeDuration_0(this, Invocation.getter(#refetchInterval))) - as Duration); - @override - _i2.QueryCache get cache => (super.noSuchMethod(Invocation.getter(#cache), - returnValue: _FakeQueryCache_1(this, Invocation.getter(#cache))) - as _i2.QueryCache); - @override - set cache(_i2.QueryCache? _cache) => - super.noSuchMethod(Invocation.setter(#cache, _cache), - returnValueForMissingStub: null); - @override - int get isFetching => - (super.noSuchMethod(Invocation.getter(#isFetching), returnValue: 0) - as int); - @override - int get isMutating => - (super.noSuchMethod(Invocation.getter(#isMutating), returnValue: 0) - as int); - @override - void onQueriesUpdate( - void Function(_i3.Query)? listener) => - super.noSuchMethod(Invocation.method(#onQueriesUpdate, [listener]), - returnValueForMissingStub: null); - @override - void onMutationsUpdate( - void Function(_i3.Mutation)? listener) => - super.noSuchMethod(Invocation.method(#onMutationsUpdate, [listener]), - returnValueForMissingStub: null); - @override - void onInfiniteQueriesUpdate( - void Function(_i3.InfiniteQuery)? listener) => - super.noSuchMethod( - Invocation.method(#onInfiniteQueriesUpdate, [listener]), - returnValueForMissingStub: null); - @override - _i3.InfiniteQuery? - getInfiniteQuery( - String? queryKey) => - (super.noSuchMethod(Invocation.method(#getInfiniteQuery, [queryKey])) - as _i3.InfiniteQuery?); - @override - _i3.Query? getQuery( - String? queryKey) => - (super.noSuchMethod(Invocation.method(#getQuery, [queryKey])) - as _i3.Query?); - @override - _i3.Mutation? getMutation(String? mutationKey) => - (super.noSuchMethod(Invocation.method(#getMutation, [mutationKey])) - as _i3.Mutation?); - @override - void setQueryData( - String? queryKey, _i3.QueryUpdateFunction? updateCb) => - super.noSuchMethod(Invocation.method(#setQueryData, [queryKey, updateCb]), - returnValueForMissingStub: null); - @override - void - setInfiniteQueryData( - String? queryKey, - _i3.QueryUpdateFunction>? updateCb) => - super.noSuchMethod( - Invocation.method(#setInfiniteQueryData, [queryKey, updateCb]), - returnValueForMissingStub: null); - @override - void resetQueries(List? queryKeys) => - super.noSuchMethod(Invocation.method(#resetQueries, [queryKeys]), - returnValueForMissingStub: null); - @override - void invalidateQueries(List? queryKeys) => - super.noSuchMethod(Invocation.method(#invalidateQueries, [queryKeys]), - returnValueForMissingStub: null); - @override - _i4.Future refetchQueries(List? queryKeys) => - (super.noSuchMethod(Invocation.method(#refetchQueries, [queryKeys]), - returnValue: _i4.Future.value(), - returnValueForMissingStub: _i4.Future.value()) - as _i4.Future); - @override - int removeQueries(List? queryKeys) => - (super.noSuchMethod(Invocation.method(#removeQueries, [queryKeys]), - returnValue: 0) as int); - @override - _i3.Query addQuery( - _i3.QueryJob? queryJob, - {Outside? externalData, - _i5.ValueKey? key, - _i3.QueryListener? onData, - _i3.QueryListener? onError, - T? previousData}) => - (super.noSuchMethod( - Invocation.method(#addQuery, [ - queryJob - ], { - #externalData: externalData, - #key: key, - #onData: onData, - #onError: onError, - #previousData: previousData - }), - returnValue: _FakeQuery_2( - this, - Invocation.method(#addQuery, [ - queryJob - ], { - #externalData: externalData, - #key: key, - #onData: onData, - #onError: onError, - #previousData: previousData - }))) as _i3.Query); - @override - _i3.InfiniteQuery addInfiniteQuery( - _i3.InfiniteQueryJob? infiniteQueryJob, - {Outside? externalData, - _i5.ValueKey? key, - _i3.InfiniteQueryListeners? onData, - _i3.InfiniteQueryListeners? onError}) => - (super.noSuchMethod(Invocation.method(#addInfiniteQuery, [infiniteQueryJob], {#externalData: externalData, #key: key, #onData: onData, #onError: onError}), - returnValue: _FakeInfiniteQuery_3( - this, - Invocation.method(#addInfiniteQuery, [ - infiniteQueryJob - ], { - #externalData: externalData, - #key: key, - #onData: onData, - #onError: onError - }))) as _i3.InfiniteQuery); - @override - _i3.Mutation addMutation( - _i3.MutationJob? mutationJob, - {_i3.MutationListener? onData, - _i3.MutationListener? onError, - _i3.MutationListenerReturnable? onMutate, - _i5.ValueKey? key}) => - (super - .noSuchMethod(Invocation.method(#addMutation, [mutationJob], {#onData: onData, #onError: onError, #onMutate: onMutate, #key: key}), - returnValue: _FakeMutation_4( - this, - Invocation.method(#addMutation, [ - mutationJob - ], { - #onData: onData, - #onError: onError, - #onMutate: onMutate, - #key: key - }))) as _i3.Mutation); - @override - _i4.Future fetchQuery( - _i3.QueryJob? options, - {Outside? externalData, - _i3.QueryListener? onData, - _i3.QueryListener? onError, - _i5.ValueKey? key}) => - (super.noSuchMethod( - Invocation.method(#fetchQuery, [ - options - ], { - #externalData: externalData, - #onData: onData, - #onError: onError, - #key: key - }), - returnValue: _i4.Future.value()) as _i4.Future); -} - -/// A class which mocks [Connectivity]. -/// -/// See the documentation for Mockito's code generation for more information. -class MockConnectivity extends _i1.Mock implements _i6.Connectivity { - MockConnectivity() { - _i1.throwOnMissingStub(this); - } - - @override - _i4.Stream<_i6.ConnectivityResult> get onConnectivityChanged => - (super.noSuchMethod(Invocation.getter(#onConnectivityChanged), - returnValue: _i4.Stream<_i6.ConnectivityResult>.empty()) - as _i4.Stream<_i6.ConnectivityResult>); - @override - _i4.Future<_i6.ConnectivityResult> checkConnectivity() => - (super.noSuchMethod(Invocation.method(#checkConnectivity, []), - returnValue: _i4.Future<_i6.ConnectivityResult>.value( - _i6.ConnectivityResult.bluetooth)) - as _i4.Future<_i6.ConnectivityResult>); -} - -/// A class which mocks [QueryJob]. -/// -/// See the documentation for Mockito's code generation for more information. -class MockQueryJobVoidObject extends _i1.Mock - implements _i3.QueryJob { - @override - _i3.QueryTaskFunction get task => - (super.noSuchMethod(Invocation.getter(#task), - returnValue: (String queryKey, void externalData) => - _i4.Future.value( - _FakeObject_5(this, Invocation.getter(#task)))) - as _i3.QueryTaskFunction); - @override - set task(_i3.QueryTaskFunction? _task) => - super.noSuchMethod(Invocation.setter(#task, _task), - returnValueForMissingStub: null); - @override - set initialData(Object? _initialData) => - super.noSuchMethod(Invocation.setter(#initialData, _initialData), - returnValueForMissingStub: null); - @override - bool get isDynamic => - (super.noSuchMethod(Invocation.getter(#isDynamic), returnValue: false) - as bool); - @override - set isDynamic(bool? _isDynamic) => - super.noSuchMethod(Invocation.setter(#isDynamic, _isDynamic), - returnValueForMissingStub: null); - @override - String get queryKey => - (super.noSuchMethod(Invocation.getter(#queryKey), returnValue: '') - as String); -} diff --git a/packages/fl_query_connectivity_plus_adapter/.flutter-plugins b/packages/fl_query_connectivity_plus_adapter/.flutter-plugins new file mode 100644 index 0000000..35fab5e --- /dev/null +++ b/packages/fl_query_connectivity_plus_adapter/.flutter-plugins @@ -0,0 +1,7 @@ +# This is a generated file; do not edit or check into version control. +connectivity_plus=/home/krtirtho/.pub-cache/hosted/pub.dev/connectivity_plus-4.0.1/ +path_provider=/home/krtirtho/.pub-cache/hosted/pub.dev/path_provider-2.0.15/ +path_provider_android=/home/krtirtho/.pub-cache/hosted/pub.dev/path_provider_android-2.0.27/ +path_provider_foundation=/home/krtirtho/.pub-cache/hosted/pub.dev/path_provider_foundation-2.2.3/ +path_provider_linux=/home/krtirtho/.pub-cache/hosted/pub.dev/path_provider_linux-2.1.11/ +path_provider_windows=/home/krtirtho/.pub-cache/hosted/pub.dev/path_provider_windows-2.1.7/ diff --git a/packages/fl_query_connectivity_plus_adapter/.flutter-plugins-dependencies b/packages/fl_query_connectivity_plus_adapter/.flutter-plugins-dependencies new file mode 100644 index 0000000..33e68a3 --- /dev/null +++ b/packages/fl_query_connectivity_plus_adapter/.flutter-plugins-dependencies @@ -0,0 +1 @@ +{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"connectivity_plus","path":"/home/krtirtho/.pub-cache/hosted/pub.dev/connectivity_plus-4.0.1/","native_build":true,"dependencies":[]},{"name":"path_provider_foundation","path":"/home/krtirtho/.pub-cache/hosted/pub.dev/path_provider_foundation-2.2.3/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"android":[{"name":"connectivity_plus","path":"/home/krtirtho/.pub-cache/hosted/pub.dev/connectivity_plus-4.0.1/","native_build":true,"dependencies":[]},{"name":"path_provider_android","path":"/home/krtirtho/.pub-cache/hosted/pub.dev/path_provider_android-2.0.27/","native_build":true,"dependencies":[]}],"macos":[{"name":"connectivity_plus","path":"/home/krtirtho/.pub-cache/hosted/pub.dev/connectivity_plus-4.0.1/","native_build":true,"dependencies":[]},{"name":"path_provider_foundation","path":"/home/krtirtho/.pub-cache/hosted/pub.dev/path_provider_foundation-2.2.3/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"linux":[{"name":"connectivity_plus","path":"/home/krtirtho/.pub-cache/hosted/pub.dev/connectivity_plus-4.0.1/","native_build":false,"dependencies":[]},{"name":"path_provider_linux","path":"/home/krtirtho/.pub-cache/hosted/pub.dev/path_provider_linux-2.1.11/","native_build":false,"dependencies":[]}],"windows":[{"name":"connectivity_plus","path":"/home/krtirtho/.pub-cache/hosted/pub.dev/connectivity_plus-4.0.1/","native_build":true,"dependencies":[]},{"name":"path_provider_windows","path":"/home/krtirtho/.pub-cache/hosted/pub.dev/path_provider_windows-2.1.7/","native_build":false,"dependencies":[]}],"web":[{"name":"connectivity_plus","path":"/home/krtirtho/.pub-cache/hosted/pub.dev/connectivity_plus-4.0.1/","dependencies":[]}]},"dependencyGraph":[{"name":"connectivity_plus","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_android","path_provider_foundation","path_provider_linux","path_provider_windows"]},{"name":"path_provider_android","dependencies":[]},{"name":"path_provider_foundation","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]}],"date_created":"2023-06-23 22:55:15.808306","version":"3.10.2"} \ No newline at end of file diff --git a/packages/fl_query_connectivity_plus_adapter/.gitignore b/packages/fl_query_connectivity_plus_adapter/.gitignore new file mode 100644 index 0000000..96486fd --- /dev/null +++ b/packages/fl_query_connectivity_plus_adapter/.gitignore @@ -0,0 +1,30 @@ +# 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 +# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. +/pubspec.lock +**/doc/api/ +.dart_tool/ +.packages +build/ diff --git a/packages/fl_query_connectivity_plus_adapter/.metadata b/packages/fl_query_connectivity_plus_adapter/.metadata new file mode 100644 index 0000000..10542d2 --- /dev/null +++ b/packages/fl_query_connectivity_plus_adapter/.metadata @@ -0,0 +1,10 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled and should not be manually edited. + +version: + revision: 9cd3d0d9ff05768afa249e036acc66e8abe93bff + channel: stable + +project_type: package diff --git a/packages/fl_query_connectivity_plus_adapter/CHANGELOG.md b/packages/fl_query_connectivity_plus_adapter/CHANGELOG.md new file mode 100644 index 0000000..f2e3ae3 --- /dev/null +++ b/packages/fl_query_connectivity_plus_adapter/CHANGELOG.md @@ -0,0 +1,19 @@ +## 0.1.0-alpha.4 + + - Update a dependency to the latest release. + +## 0.1.0-alpha.3 + + - Update a dependency to the latest release. + +## 0.1.0-alpha.2 + + - **FIX**(fl_query_connectivity_plus_adapter): lower the sdk constrains. + +## 0.1.0-alpha.1 + + - Update a dependency to the latest release. + +## 0.0.1 + +* TODO: Describe initial release. diff --git a/packages/fl_query_connectivity_plus_adapter/LICENSE b/packages/fl_query_connectivity_plus_adapter/LICENSE new file mode 100644 index 0000000..261eeb9 --- /dev/null +++ b/packages/fl_query_connectivity_plus_adapter/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/packages/fl_query_connectivity_plus_adapter/README.md b/packages/fl_query_connectivity_plus_adapter/README.md new file mode 100644 index 0000000..db57309 --- /dev/null +++ b/packages/fl_query_connectivity_plus_adapter/README.md @@ -0,0 +1,3 @@ +# Fl-Query Connectivity Plus Adapter + +Connectivity Plus Adapter for [Fl-Query](https://fl-query.vercel.app/) \ No newline at end of file diff --git a/packages/fl_query_connectivity_plus_adapter/analysis_options.yaml b/packages/fl_query_connectivity_plus_adapter/analysis_options.yaml new file mode 100644 index 0000000..a5744c1 --- /dev/null +++ b/packages/fl_query_connectivity_plus_adapter/analysis_options.yaml @@ -0,0 +1,4 @@ +include: package:flutter_lints/flutter.yaml + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options diff --git a/packages/fl_query_connectivity_plus_adapter/lib/fl_query_connectivity_plus_adapter.dart b/packages/fl_query_connectivity_plus_adapter/lib/fl_query_connectivity_plus_adapter.dart new file mode 100644 index 0000000..31022d0 --- /dev/null +++ b/packages/fl_query_connectivity_plus_adapter/lib/fl_query_connectivity_plus_adapter.dart @@ -0,0 +1,32 @@ +library fl_query_connectivity_plus_adapter; + +import 'package:fl_query/fl_query.dart'; +import 'package:connectivity_plus/connectivity_plus.dart'; + +/// A [ConnectivityAdapter] that uses the `connectivity_plus` package. +class FlQueryConnectivityPlusAdapter extends ConnectivityAdapter { + @override + Future get isConnected async { + final connection = await Connectivity().checkConnectivity(); + + switch (connection) { + case ConnectivityResult.bluetooth: + case ConnectivityResult.none: + return false; + default: + return true; + } + } + + @override + Stream get onConnectivityChanged => + Connectivity().onConnectivityChanged.map((event) { + switch (event) { + case ConnectivityResult.bluetooth: + case ConnectivityResult.none: + return false; + default: + return true; + } + }); +} diff --git a/packages/fl_query_connectivity_plus_adapter/pubspec.yaml b/packages/fl_query_connectivity_plus_adapter/pubspec.yaml new file mode 100644 index 0000000..7e1cf2c --- /dev/null +++ b/packages/fl_query_connectivity_plus_adapter/pubspec.yaml @@ -0,0 +1,22 @@ +name: fl_query_connectivity_plus_adapter +description: Connectivity Plus adapter for FlQuery Connectivity +version: 0.1.0-alpha.4 + +homepage: https://fl-query.vercel.app +repository: https://github.com/KRTirtho/tree/main/packages/fl_query_connectivity_plus_adapter +issue_tracker: https://github.com/KRTirtho/fl-query/issues + +environment: + sdk: ">=2.17.1 <4.0.0" + flutter: ">=1.17.0" + +dependencies: + flutter: + sdk: flutter + fl_query: ^1.0.0-alpha.5 + connectivity_plus: ^4.0.1 + +dev_dependencies: + flutter_test: + sdk: flutter + flutter_lints: ^2.0.0 \ No newline at end of file diff --git a/packages/fl_query_connectivity_plus_adapter/pubspec_overrides.yaml b/packages/fl_query_connectivity_plus_adapter/pubspec_overrides.yaml new file mode 100644 index 0000000..07a1730 --- /dev/null +++ b/packages/fl_query_connectivity_plus_adapter/pubspec_overrides.yaml @@ -0,0 +1,4 @@ +# melos_managed_dependency_overrides: fl_query +dependency_overrides: + fl_query: + path: ../fl_query diff --git a/packages/fl_query_devtools/.flutter-plugins b/packages/fl_query_devtools/.flutter-plugins new file mode 100644 index 0000000..9f3ec03 --- /dev/null +++ b/packages/fl_query_devtools/.flutter-plugins @@ -0,0 +1,6 @@ +# This is a generated file; do not edit or check into version control. +path_provider=/home/krtirtho/.pub-cache/hosted/pub.dev/path_provider-2.0.15/ +path_provider_android=/home/krtirtho/.pub-cache/hosted/pub.dev/path_provider_android-2.0.27/ +path_provider_foundation=/home/krtirtho/.pub-cache/hosted/pub.dev/path_provider_foundation-2.2.3/ +path_provider_linux=/home/krtirtho/.pub-cache/hosted/pub.dev/path_provider_linux-2.1.11/ +path_provider_windows=/home/krtirtho/.pub-cache/hosted/pub.dev/path_provider_windows-2.1.7/ diff --git a/packages/fl_query_devtools/.flutter-plugins-dependencies b/packages/fl_query_devtools/.flutter-plugins-dependencies new file mode 100644 index 0000000..ea398c7 --- /dev/null +++ b/packages/fl_query_devtools/.flutter-plugins-dependencies @@ -0,0 +1 @@ +{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"path_provider_foundation","path":"/home/krtirtho/.pub-cache/hosted/pub.dev/path_provider_foundation-2.2.3/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"android":[{"name":"path_provider_android","path":"/home/krtirtho/.pub-cache/hosted/pub.dev/path_provider_android-2.0.27/","native_build":true,"dependencies":[]}],"macos":[{"name":"path_provider_foundation","path":"/home/krtirtho/.pub-cache/hosted/pub.dev/path_provider_foundation-2.2.3/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"/home/krtirtho/.pub-cache/hosted/pub.dev/path_provider_linux-2.1.11/","native_build":false,"dependencies":[]}],"windows":[{"name":"path_provider_windows","path":"/home/krtirtho/.pub-cache/hosted/pub.dev/path_provider_windows-2.1.7/","native_build":false,"dependencies":[]}],"web":[]},"dependencyGraph":[{"name":"path_provider","dependencies":["path_provider_android","path_provider_foundation","path_provider_linux","path_provider_windows"]},{"name":"path_provider_android","dependencies":[]},{"name":"path_provider_foundation","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]}],"date_created":"2023-06-23 22:55:16.392701","version":"3.10.2"} \ No newline at end of file diff --git a/packages/fl_query_devtools/.gitignore b/packages/fl_query_devtools/.gitignore new file mode 100644 index 0000000..96486fd --- /dev/null +++ b/packages/fl_query_devtools/.gitignore @@ -0,0 +1,30 @@ +# 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 +# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. +/pubspec.lock +**/doc/api/ +.dart_tool/ +.packages +build/ diff --git a/packages/fl_query_devtools/.metadata b/packages/fl_query_devtools/.metadata new file mode 100644 index 0000000..10542d2 --- /dev/null +++ b/packages/fl_query_devtools/.metadata @@ -0,0 +1,10 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled and should not be manually edited. + +version: + revision: 9cd3d0d9ff05768afa249e036acc66e8abe93bff + channel: stable + +project_type: package diff --git a/packages/fl_query_devtools/CHANGELOG.md b/packages/fl_query_devtools/CHANGELOG.md new file mode 100644 index 0000000..b08ffce --- /dev/null +++ b/packages/fl_query_devtools/CHANGELOG.md @@ -0,0 +1,15 @@ +## 0.1.0-alpha.3 + + - **FEAT**(infinite_query): add isLoadingNextPage & remove isLoadingPage. + +## 0.1.0-alpha.2 + + - **FIX**(devtools): no wrapping child inside SizedBox.shrink. + +## 0.1.0-alpha.1 + + - Update a dependency to the latest release. + +## 0.0.1 + +* TODO: Describe initial release. diff --git a/packages/fl_query_devtools/LICENSE b/packages/fl_query_devtools/LICENSE new file mode 100644 index 0000000..261eeb9 --- /dev/null +++ b/packages/fl_query_devtools/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/packages/fl_query_devtools/README.md b/packages/fl_query_devtools/README.md new file mode 100644 index 0000000..e8af729 --- /dev/null +++ b/packages/fl_query_devtools/README.md @@ -0,0 +1,3 @@ +# Fl-Query Devtools + +Devtools support for [Fl-Query](https://fl-query.vercel.app) \ No newline at end of file diff --git a/packages/fl_query_devtools/analysis_options.yaml b/packages/fl_query_devtools/analysis_options.yaml new file mode 100644 index 0000000..a5744c1 --- /dev/null +++ b/packages/fl_query_devtools/analysis_options.yaml @@ -0,0 +1,4 @@ +include: package:flutter_lints/flutter.yaml + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options diff --git a/packages/fl_query_devtools/lib/fl_query_devtools.dart b/packages/fl_query_devtools/lib/fl_query_devtools.dart new file mode 100644 index 0000000..8267661 --- /dev/null +++ b/packages/fl_query_devtools/lib/fl_query_devtools.dart @@ -0,0 +1,3 @@ +library fl_query_devtools; + +export 'src/devtools.dart'; diff --git a/packages/fl_query_devtools/lib/src/devtools.dart b/packages/fl_query_devtools/lib/src/devtools.dart new file mode 100644 index 0000000..b8c7566 --- /dev/null +++ b/packages/fl_query_devtools/lib/src/devtools.dart @@ -0,0 +1,94 @@ +import 'package:fl_query_devtools/src/widgets/devtools_root.dart'; +import 'package:flutter/foundation.dart'; +import 'package:flutter/material.dart'; + +class FlQueryDevtools extends StatefulWidget { + final Widget? child; + const FlQueryDevtools({ + super.key, + this.child, + }); + + @override + State createState() => _FlQueryDevtoolsState(); +} + +class _FlQueryDevtoolsState extends State { + bool _showDevtools = false; + + @override + Widget build(BuildContext context) { + if (kDebugMode) { + return Navigator( + onPopPage: (route, result) { + return true; + }, + pages: [ + MaterialPage( + child: Scaffold( + body: Stack( + children: [ + if (widget.child != null) widget.child!, + if (_showDevtools) ...[ + Positioned( + child: GestureDetector( + onTap: () { + setState(() { + _showDevtools = false; + }); + }, + child: const SizedBox.expand( + child: ColoredBox( + color: Colors.black38, + ), + ), + ), + ), + Positioned( + child: Align( + alignment: Alignment.bottomCenter, + child: Container( + height: MediaQuery.of(context).size.height * 0.7, + width: double.infinity, + margin: const EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8.0), + decoration: BoxDecoration( + color: Theme.of(context).colorScheme.surface, + borderRadius: BorderRadius.circular(8.0), + ), + child: DevtoolsRoot( + onClose: () { + setState(() { + _showDevtools = false; + }); + }, + ), + ), + ), + ), + ] + ], + ), + floatingActionButtonLocation: + FloatingActionButtonLocation.startFloat, + floatingActionButton: AnimatedScale( + duration: const Duration(milliseconds: 100), + scale: _showDevtools ? 0 : 1, + child: FloatingActionButton.extended( + onPressed: () { + setState(() { + _showDevtools = !_showDevtools; + }); + }, + label: const Text("Fl-Query Devtools"), + icon: const Icon(Icons.search_rounded), + ), + ), + ), + ), + ], + ); + } + return widget.child ?? const SizedBox.shrink(); + } +} diff --git a/packages/fl_query_devtools/lib/src/helpers/jsonify_value.dart b/packages/fl_query_devtools/lib/src/helpers/jsonify_value.dart new file mode 100644 index 0000000..a8d74c3 --- /dev/null +++ b/packages/fl_query_devtools/lib/src/helpers/jsonify_value.dart @@ -0,0 +1,29 @@ +import 'dart:convert'; + +import 'package:fl_query/fl_query.dart'; + +Object? jsonifyValue(data, JsonConfig? jsonConfig) { + switch (data.runtimeType) { + case String: + case int: + case double: + case bool: + case Null: + return data; + case Iterable: + case Map: + try { + jsonEncode(data); + return data is Iterable ? data.toList() : data; + } catch (e) { + return "[Parsing Error]: ${data.runtimeType} contains unsupported non-primitive and non-jsonEncodable value"; + } + default: + if (jsonConfig == null) { + return "$data" + "\nProvide `jsonConfig: JsonConfig(...)` to enable Json view for data"; + } else { + return (jsonConfig as dynamic).toJson(data); + } + } +} diff --git a/packages/fl_query_devtools/lib/src/helpers/primitvify_value.dart b/packages/fl_query_devtools/lib/src/helpers/primitvify_value.dart new file mode 100644 index 0000000..483ab52 --- /dev/null +++ b/packages/fl_query_devtools/lib/src/helpers/primitvify_value.dart @@ -0,0 +1,22 @@ +import 'dart:convert'; + +Object? primitivifyValue(data) { + switch (data.runtimeType) { + case String: + case int: + case double: + case bool: + case Null: + return data; + case Iterable: + case Map: + try { + jsonEncode(data); + return data; + } catch (e) { + return "[Parsing Error]: ${data.runtimeType} contains unsupported non-primitive and non-jsonEncodable value"; + } + default: + return data.toString(); + } +} diff --git a/packages/fl_query_devtools/lib/src/widgets/devtools_root.dart b/packages/fl_query_devtools/lib/src/widgets/devtools_root.dart new file mode 100644 index 0000000..d8561c8 --- /dev/null +++ b/packages/fl_query_devtools/lib/src/widgets/devtools_root.dart @@ -0,0 +1,46 @@ +import 'package:fl_query_devtools/src/widgets/tabs/infinite_query_tab.dart'; +import 'package:fl_query_devtools/src/widgets/tabs/mutation_tab.dart'; +import 'package:fl_query_devtools/src/widgets/tabs/query_tab.dart'; +import 'package:flutter/material.dart'; + +class DevtoolsRoot extends StatefulWidget { + final VoidCallback? onClose; + const DevtoolsRoot({super.key, this.onClose}); + + @override + State createState() => _DevtoolsRootState(); +} + +class _DevtoolsRootState extends State { + @override + Widget build(BuildContext context) { + return DefaultTabController( + length: 3, + child: Scaffold( + appBar: AppBar( + title: const Text('FlQuery Devtools'), + actions: [ + IconButton( + onPressed: widget.onClose, + icon: const Icon(Icons.close), + ), + ], + bottom: const TabBar( + tabs: [ + Tab(text: 'Queries'), + Tab(text: 'Infinite Queries'), + Tab(text: 'Mutations'), + ], + ), + ), + body: const TabBarView( + children: [ + QueryTab(), + InfiniteQueryTab(), + MutationTab(), + ], + ), + ), + ); + } +} diff --git a/packages/fl_query_devtools/lib/src/widgets/explorers/explorer_view.dart b/packages/fl_query_devtools/lib/src/widgets/explorers/explorer_view.dart new file mode 100644 index 0000000..c686411 --- /dev/null +++ b/packages/fl_query_devtools/lib/src/widgets/explorers/explorer_view.dart @@ -0,0 +1,42 @@ +import 'package:flutter/material.dart'; +import 'package:json_view/json_view.dart' hide JsonConfig; + +class ExplorerView extends StatefulWidget { + final String title; + final Object data; + final VoidCallback? onClose; + const ExplorerView({ + super.key, + required this.title, + required this.data, + this.onClose, + }); + + @override + State createState() => _ExplorerViewState(); +} + +class _ExplorerViewState extends State { + @override + Widget build(BuildContext context) { + return Card( + color: Theme.of(context).colorScheme.surface, + child: Column( + children: [ + Row( + children: [ + IconButton( + icon: const Icon(Icons.close), + onPressed: widget.onClose, + ), + Text(widget.title), + ], + ), + const Divider(), + Expanded( + child: JsonView(json: widget.data), + ), + ], + )); + } +} diff --git a/packages/fl_query_devtools/lib/src/widgets/query_tile.dart b/packages/fl_query_devtools/lib/src/widgets/query_tile.dart new file mode 100644 index 0000000..c87ea5a --- /dev/null +++ b/packages/fl_query_devtools/lib/src/widgets/query_tile.dart @@ -0,0 +1,43 @@ +import 'package:flutter/material.dart'; + +class QueryTile extends StatelessWidget { + final String title; + final bool isLoading; + final bool hasError; + final VoidCallback? onTap; + const QueryTile({ + super.key, + required this.title, + required this.isLoading, + required this.hasError, + this.onTap, + }); + + @override + Widget build(BuildContext context) { + return ListTile( + onTap: onTap, + leading: AnimatedSwitcher( + duration: const Duration(milliseconds: 100), + child: isLoading + ? const CircularProgressIndicator() + : hasError + ? Tooltip( + message: "'$title' has Errors", + child: const Icon( + Icons.error, + color: Colors.red, + ), + ) + : Tooltip( + message: "'$title' has fetched/mutated data successfully", + child: const Icon( + Icons.check, + color: Colors.green, + ), + ), + ), + title: Text(title), + ); + } +} diff --git a/packages/fl_query_devtools/lib/src/widgets/tabs/infinite_query_tab.dart b/packages/fl_query_devtools/lib/src/widgets/tabs/infinite_query_tab.dart new file mode 100644 index 0000000..3e668e8 --- /dev/null +++ b/packages/fl_query_devtools/lib/src/widgets/tabs/infinite_query_tab.dart @@ -0,0 +1,103 @@ +import 'package:fl_query/fl_query.dart'; +import 'package:fl_query_devtools/src/helpers/jsonify_value.dart'; +import 'package:fl_query_devtools/src/helpers/primitvify_value.dart'; +import 'package:fl_query_devtools/src/widgets/explorers/explorer_view.dart'; +import 'package:fl_query_devtools/src/widgets/query_tile.dart'; +import 'package:flutter/material.dart'; + +class InfiniteQueryTab extends StatefulWidget { + const InfiniteQueryTab({super.key}); + + @override + State createState() => _InfiniteQueryTabState(); +} + +class _InfiniteQueryTabState extends State { + String? _selectedQueryKey; + + @override + Widget build(BuildContext context) { + final client = QueryClient.of(context); + + return LayoutBuilder(builder: (context, constrains) { + return Row( + children: [ + Expanded( + child: ListView.builder( + itemCount: client.cache.infiniteQueries.length, + itemBuilder: (context, index) { + final infiniteQuery = + client.cache.infiniteQueries.elementAt(index); + return InfiniteQueryListenable( + infiniteQuery.key, + builder: (context, query) { + if (query == null) { + return const SizedBox.shrink(); + } + + return QueryTile( + title: query.key, + isLoading: query.isLoadingNextPage, + hasError: query.hasErrors, + onTap: () { + setState(() { + _selectedQueryKey = query.key; + }); + }, + ); + }, + ); + }, + ), + ), + AnimatedSize( + duration: const Duration(milliseconds: 200), + curve: Curves.bounceInOut, + child: Builder(builder: (context) { + return SizedBox( + width: _selectedQueryKey == null + ? 0 + : constrains.biggest.width * 0.5, + child: SizedBox.expand( + child: InfiniteQueryListenable( + _selectedQueryKey ?? '', + builder: (context, query) { + if (query == null) { + return const SizedBox.shrink(); + } + + return ExplorerView( + title: query.key, + data: { + 'pages': query.state.pages.map((page) { + return { + "pageParam": primitivifyValue(page.page), + "data": jsonifyValue(page.data, query.jsonConfig), + "errors": primitivifyValue(page.error), + "stale": page.isStale, + "updatedAt": page.updatedAt.toString(), + }; + }).toList(), + 'isLoadingNextPage': query.isLoadingNextPage, + 'isRefreshingPage': query.isRefreshingPage, + 'isInactive': query.isInactive, + 'refreshConfig': query.refreshConfig.toJson(), + 'retryConfig': query.retryConfig.toJson() + }, + onClose: () { + setState(() { + _selectedQueryKey = null; + }); + }, + ); + }, + ), + ), + ); + }), + ), + ], + ); + }); + } +} diff --git a/packages/fl_query_devtools/lib/src/widgets/tabs/mutation_tab.dart b/packages/fl_query_devtools/lib/src/widgets/tabs/mutation_tab.dart new file mode 100644 index 0000000..8c2a024 --- /dev/null +++ b/packages/fl_query_devtools/lib/src/widgets/tabs/mutation_tab.dart @@ -0,0 +1,29 @@ +import 'package:fl_query/fl_query.dart'; +import 'package:fl_query_devtools/src/widgets/query_tile.dart'; +import 'package:flutter/material.dart'; + +class MutationTab extends StatefulWidget { + const MutationTab({super.key}); + + @override + State createState() => _MutationTabState(); +} + +class _MutationTabState extends State { + @override + Widget build(BuildContext context) { + final client = QueryClient.of(context); + + return ListView.builder( + itemCount: client.cache.mutations.length, + itemBuilder: (context, index) { + final mutation = client.cache.mutations.elementAt(index); + return QueryTile( + title: mutation.key, + isLoading: mutation.isMutating, + hasError: mutation.hasError, + ); + }, + ); + } +} diff --git a/packages/fl_query_devtools/lib/src/widgets/tabs/query_tab.dart b/packages/fl_query_devtools/lib/src/widgets/tabs/query_tab.dart new file mode 100644 index 0000000..29caa1f --- /dev/null +++ b/packages/fl_query_devtools/lib/src/widgets/tabs/query_tab.dart @@ -0,0 +1,96 @@ +import 'package:fl_query/fl_query.dart'; +import 'package:fl_query_devtools/src/helpers/jsonify_value.dart'; +import 'package:fl_query_devtools/src/helpers/primitvify_value.dart'; +import 'package:fl_query_devtools/src/widgets/explorers/explorer_view.dart'; +import 'package:fl_query_devtools/src/widgets/query_tile.dart'; +import 'package:flutter/material.dart'; + +class QueryTab extends StatefulWidget { + const QueryTab({super.key}); + + @override + State createState() => _QueryTabState(); +} + +class _QueryTabState extends State { + String? _selectedQueryKey; + + @override + Widget build(BuildContext context) { + final client = QueryClient.of(context); + + return LayoutBuilder(builder: (context, constrains) { + return Row( + children: [ + Expanded( + child: ListView.builder( + itemCount: client.cache.queries.length, + itemBuilder: (context, index) { + final query = client.cache.queries.elementAt(index); + return QueryListenable( + query.key, + builder: (context, query) { + if (query == null) { + return const SizedBox.shrink(); + } + + return QueryTile( + title: query.key, + isLoading: query.isLoading, + hasError: query.hasError, + onTap: () { + setState(() { + _selectedQueryKey = query.key; + }); + }, + ); + }, + ); + }, + ), + ), + AnimatedSize( + duration: const Duration(milliseconds: 200), + curve: Curves.bounceInOut, + child: Builder(builder: (context) { + return SizedBox( + width: _selectedQueryKey == null + ? 0 + : constrains.biggest.width * 0.5, + child: SizedBox.expand( + child: QueryListenable(_selectedQueryKey ?? '', + builder: (context, query) { + if (query == null) { + return const SizedBox.shrink(); + } + + return ExplorerView( + title: query.key, + data: { + 'data': jsonifyValue(query.data, query.jsonConfig), + 'errors': primitivifyValue(query.error), + 'stale': query.state.isStale, + 'updatedAt': query.state.updatedAt.toString(), + 'isLoading': query.isLoading, + 'isRefreshing': query.isRefreshing, + 'isInactive': query.isInactive, + 'isInitial': query.isInitial, + 'refreshConfig': query.refreshConfig.toJson(), + 'retryConfig': query.retryConfig.toJson() + }, + onClose: () { + setState(() { + _selectedQueryKey = null; + }); + }, + ); + }), + ), + ); + }), + ), + ], + ); + }); + } +} diff --git a/packages/fl_query_devtools/pubspec.yaml b/packages/fl_query_devtools/pubspec.yaml new file mode 100644 index 0000000..e89ea18 --- /dev/null +++ b/packages/fl_query_devtools/pubspec.yaml @@ -0,0 +1,21 @@ +name: fl_query_devtools +description: Devtools support for Fl-Query +version: 0.1.0-alpha.3 +homepage: https://fl-query.vercel.app +repository: https://github.com/KRTirtho/fl-query/tree/main/packages/fl_query_devtools +issue_tracker: https://github.com/KRTirtho/fl-query/issues + +environment: + sdk: '>=2.17.1 <4.0.0' + flutter: ">=1.17.0" + +dependencies: + flutter: + sdk: flutter + fl_query: ^1.0.0-alpha.5 + json_view: ^0.4.1 + +dev_dependencies: + flutter_test: + sdk: flutter + flutter_lints: ^2.0.0 diff --git a/packages/fl_query_devtools/pubspec_overrides.yaml b/packages/fl_query_devtools/pubspec_overrides.yaml new file mode 100644 index 0000000..07a1730 --- /dev/null +++ b/packages/fl_query_devtools/pubspec_overrides.yaml @@ -0,0 +1,4 @@ +# melos_managed_dependency_overrides: fl_query +dependency_overrides: + fl_query: + path: ../fl_query diff --git a/packages/fl_query_hooks/.flutter-plugins b/packages/fl_query_hooks/.flutter-plugins index 4868dd5..3aad94f 100644 --- a/packages/fl_query_hooks/.flutter-plugins +++ b/packages/fl_query_hooks/.flutter-plugins @@ -1,12 +1,6 @@ # This is a generated file; do not edit or check into version control. -connectivity_plus=/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-2.3.9/ -connectivity_plus_linux=/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_linux-1.3.1/ -connectivity_plus_macos=/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_macos-1.2.6/ -connectivity_plus_web=/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_web-1.2.5/ -connectivity_plus_windows=/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_windows-1.2.2/ -path_provider=/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/path_provider-2.0.11/ -path_provider_android=/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/path_provider_android-2.0.22/ -path_provider_ios=/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/path_provider_ios-2.0.11/ -path_provider_linux=/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/path_provider_linux-2.1.7/ -path_provider_macos=/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/path_provider_macos-2.0.6/ -path_provider_windows=/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/path_provider_windows-2.1.3/ +path_provider=/home/krtirtho/.pub-cache/hosted/pub.dev/path_provider-2.0.15/ +path_provider_android=/home/krtirtho/.pub-cache/hosted/pub.dev/path_provider_android-2.0.27/ +path_provider_foundation=/home/krtirtho/.pub-cache/hosted/pub.dev/path_provider_foundation-2.2.3/ +path_provider_linux=/home/krtirtho/.pub-cache/hosted/pub.dev/path_provider_linux-2.1.11/ +path_provider_windows=/home/krtirtho/.pub-cache/hosted/pub.dev/path_provider_windows-2.1.6/ diff --git a/packages/fl_query_hooks/.flutter-plugins-dependencies b/packages/fl_query_hooks/.flutter-plugins-dependencies index e8bd197..33a7df7 100644 --- a/packages/fl_query_hooks/.flutter-plugins-dependencies +++ b/packages/fl_query_hooks/.flutter-plugins-dependencies @@ -1 +1 @@ -{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"connectivity_plus","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-2.3.9/","native_build":true,"dependencies":[]},{"name":"path_provider_ios","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/path_provider_ios-2.0.11/","native_build":true,"dependencies":[]}],"android":[{"name":"connectivity_plus","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-2.3.9/","native_build":true,"dependencies":[]},{"name":"path_provider_android","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/path_provider_android-2.0.22/","native_build":true,"dependencies":[]}],"macos":[{"name":"connectivity_plus_macos","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_macos-1.2.6/","native_build":true,"dependencies":[]},{"name":"path_provider_macos","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/path_provider_macos-2.0.6/","native_build":true,"dependencies":[]}],"linux":[{"name":"connectivity_plus_linux","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_linux-1.3.1/","native_build":false,"dependencies":[]},{"name":"path_provider_linux","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/path_provider_linux-2.1.7/","native_build":false,"dependencies":[]}],"windows":[{"name":"connectivity_plus_windows","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_windows-1.2.2/","native_build":true,"dependencies":[]},{"name":"path_provider_windows","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/path_provider_windows-2.1.3/","native_build":false,"dependencies":[]}],"web":[{"name":"connectivity_plus_web","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_web-1.2.5/","dependencies":[]}]},"dependencyGraph":[{"name":"connectivity_plus","dependencies":["connectivity_plus_linux","connectivity_plus_macos","connectivity_plus_web","connectivity_plus_windows"]},{"name":"connectivity_plus_linux","dependencies":[]},{"name":"connectivity_plus_macos","dependencies":[]},{"name":"connectivity_plus_web","dependencies":[]},{"name":"connectivity_plus_windows","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_android","path_provider_ios","path_provider_linux","path_provider_macos","path_provider_windows"]},{"name":"path_provider_android","dependencies":[]},{"name":"path_provider_ios","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_macos","dependencies":[]},{"name":"path_provider_windows","dependencies":[]}],"date_created":"2022-12-15 14:11:22.006668","version":"3.3.8"} \ No newline at end of file +{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"path_provider_foundation","path":"/home/krtirtho/.pub-cache/hosted/pub.dev/path_provider_foundation-2.2.3/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"android":[{"name":"path_provider_android","path":"/home/krtirtho/.pub-cache/hosted/pub.dev/path_provider_android-2.0.27/","native_build":true,"dependencies":[]}],"macos":[{"name":"path_provider_foundation","path":"/home/krtirtho/.pub-cache/hosted/pub.dev/path_provider_foundation-2.2.3/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"/home/krtirtho/.pub-cache/hosted/pub.dev/path_provider_linux-2.1.11/","native_build":false,"dependencies":[]}],"windows":[{"name":"path_provider_windows","path":"/home/krtirtho/.pub-cache/hosted/pub.dev/path_provider_windows-2.1.6/","native_build":false,"dependencies":[]}],"web":[]},"dependencyGraph":[{"name":"path_provider","dependencies":["path_provider_android","path_provider_foundation","path_provider_linux","path_provider_windows"]},{"name":"path_provider_android","dependencies":[]},{"name":"path_provider_foundation","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]}],"date_created":"2023-06-23 22:55:19.376816","version":"3.10.2"} \ No newline at end of file diff --git a/packages/fl_query_hooks/CHANGELOG.md b/packages/fl_query_hooks/CHANGELOG.md index 6083567..3fa83c0 100644 --- a/packages/fl_query_hooks/CHANGELOG.md +++ b/packages/fl_query_hooks/CHANGELOG.md @@ -1,7 +1,82 @@ +## 1.0.0-alpha.5 + + - **FIX**(mutation): isMutating not working. + +## 1.0.0-alpha.4+1 + + - **FIX**(fl_query_hooks): upgrade flutter_hooks version & dart sdk constrain. + +## 1.0.0-alpha.4 + + - **FIX**: mutation onSuccess doesn't refresh all pages of infinite queries. + +## 1.0.0-alpha.3 + + - **REFACTOR**: move devtools to separate library. + - **REFACTOR**: more convenient ways customizing config. + - **REFACTOR**(QueryBowl): query bowl logic as a separate class instead of a stateful widget. + - **REFACTOR**(example): package specific examples instead of a single example. + - **FIX**(fl_query_hooks): fetch query when queryKey changes. + - **FIX**(fl_query_hooks): query/mutation reset to initial memoized values on hot reload. + - **FIX**: state update on unmounted hook and infinite query cache refetch not working. + - **FIX**: refetchOnExternalDataChange isn't working #18. + - **FIX**(base_query): onData callback getting called with null #17. + - **FIX**(fl_query_hooks): unneeded empty instances of query/mutation. + - **FIX**(fl_query_hooks): newest query/mutation/infinite-query instance not getting returned. + - **FEAT**: connectivity adapter package for connectivity_plus. + - **FEAT**: add devtools (WIP). + - **FEAT**: new next_page signature, query/mutation fn in notifier and safe update in use_updater. + - **FEAT**: use function hooks instead of class hooks. + - **FEAT**: use mutation hook add. + - **FEAT**: useInfiniteQuery hook add. + - **FEAT**: useQuery hook with working example. + - **FEAT**: safe cancellation of running operation on reset. + - **FEAT**: add infinite query builder with example. + - **FEAT**: cache, client, query builder add and refreshOnQueryFnChange option. + - **FEAT**: initial query and retryer implementation. + - **FEAT**: clean old junk. + - **FEAT**: add query and infinite query disk caching support. + - **FEAT**(infinite-query): onData and onError listener support. + - **FEAT**(infinite-query): add `useInfiniteQuery` hook with example. + - **FEAT**(infinite-query): add refetchPages, refetchOnStale, refetchOnMount support. + - **FEAT**: add initial support for `InfiniteQuery`. + - **FEAT**: add support for keepPreviousData & examples regarding this. + - **DOCS**: add infinite query page. + - **DOCS**: add paginated-query section and update optimistc update section. + # Changelog All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +## [1.0.0-alpha.2](https://github.com/KRTirtho/fl-query/compare/v1.0.0-alpha.1...v1.0.0-alpha.2) (2023-03-12) + + +### Features + +* **QueryClientProvider:** add config parameters and override-able client parameter ([f8895e3](https://github.com/KRTirtho/fl-query/commit/f8895e338141488e5bce4401c80b491688932085)) + +### [1.0.0-alpha.1](https://github.com/KRTirtho/fl-query/compare/v0.3.0...v1.0.0-alpha.1) (2023-03-05) + +> **BREAKING** +> - The Jobs API has been disabled. So there's no `QueryJob`, `MutationJob` and `InfiniteQueryJob` anymore. Instead, you can use the `useQuery`, `useMutation` and `useInfiniteQuery` directly +> - Some of classes were renamed to more mature names +> - `QueryBowlProvider` -> `QueryClientProvider` +> - `QueryBowl` -> `QueryClient` +> - The unnecessary `getPreviousPageParam` is now removed from `InfiniteQuery` +> - `getNextPageParam` has been renamed to `nextPage` +> - Also, `fetchNextPage` has been renamed to `fetchNext` +> - `Query` and `InfiniteQuery`'s `setQueryData` has been renamed to `setData` and it now accepts data directly instead of a call back function +> - Finally, `QueryClient`'s unneeded `prefetchQuery` method was eradicated +> - useForceUpdate hook is now removed from the package + + +### Features + +* new useQueryClient hook +* useQuery hook implementation hook based on new fl_query ([7fabf44](https://github.com/KRTirtho/fl-query/commit/7fabf44756ed36aaa4481583167735bc18f97ad1)) +* useInfiniteQuery hook implementation hook based on new fl_query ([f9a5207](https://github.com/KRTirtho/fl-query/commit/f9a520740321ababa3974e232562b32364062a35)) +* usMutation implementation hook based on new fl_query ([383d0e0](https://github.com/KRTirtho/fl-query/commit/383d0e0a85d7db6ee30bc336cb849f4ea401a8f1)) + ### [0.3.1](https://github.com/KRTirtho/fl-query/compare/v0.3.0...v0.3.1) (2022-10-03) ### Bug Fixes diff --git a/packages/fl_query_hooks/example/.flutter-plugins b/packages/fl_query_hooks/example/.flutter-plugins deleted file mode 100644 index 7051ea8..0000000 --- a/packages/fl_query_hooks/example/.flutter-plugins +++ /dev/null @@ -1,12 +0,0 @@ -# This is a generated file; do not edit or check into version control. -connectivity_plus=/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-2.3.9/ -connectivity_plus_linux=/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_linux-1.3.1/ -connectivity_plus_macos=/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_macos-1.2.4/ -connectivity_plus_web=/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_web-1.2.5/ -connectivity_plus_windows=/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_windows-1.2.2/ -path_provider=/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/path_provider-2.0.11/ -path_provider_android=/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/path_provider_android-2.0.22/ -path_provider_ios=/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/path_provider_ios-2.0.11/ -path_provider_linux=/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/path_provider_linux-2.1.7/ -path_provider_macos=/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/path_provider_macos-2.0.6/ -path_provider_windows=/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/path_provider_windows-2.1.3/ diff --git a/packages/fl_query_hooks/example/.flutter-plugins-dependencies b/packages/fl_query_hooks/example/.flutter-plugins-dependencies deleted file mode 100644 index 8f41978..0000000 --- a/packages/fl_query_hooks/example/.flutter-plugins-dependencies +++ /dev/null @@ -1 +0,0 @@ -{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"connectivity_plus","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-2.3.9/","native_build":true,"dependencies":[]},{"name":"path_provider_ios","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/path_provider_ios-2.0.11/","native_build":true,"dependencies":[]}],"android":[{"name":"connectivity_plus","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-2.3.9/","native_build":true,"dependencies":[]},{"name":"path_provider_android","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/path_provider_android-2.0.22/","native_build":true,"dependencies":[]}],"macos":[{"name":"connectivity_plus_macos","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_macos-1.2.4/","native_build":true,"dependencies":[]},{"name":"path_provider_macos","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/path_provider_macos-2.0.6/","native_build":true,"dependencies":[]}],"linux":[{"name":"connectivity_plus_linux","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_linux-1.3.1/","native_build":false,"dependencies":[]},{"name":"path_provider_linux","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/path_provider_linux-2.1.7/","native_build":false,"dependencies":[]}],"windows":[{"name":"connectivity_plus_windows","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_windows-1.2.2/","native_build":true,"dependencies":[]},{"name":"path_provider_windows","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/path_provider_windows-2.1.3/","native_build":false,"dependencies":[]}],"web":[{"name":"connectivity_plus_web","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_web-1.2.5/","dependencies":[]}]},"dependencyGraph":[{"name":"connectivity_plus","dependencies":["connectivity_plus_linux","connectivity_plus_macos","connectivity_plus_web","connectivity_plus_windows"]},{"name":"connectivity_plus_linux","dependencies":[]},{"name":"connectivity_plus_macos","dependencies":[]},{"name":"connectivity_plus_web","dependencies":[]},{"name":"connectivity_plus_windows","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_android","path_provider_ios","path_provider_linux","path_provider_macos","path_provider_windows"]},{"name":"path_provider_android","dependencies":[]},{"name":"path_provider_ios","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_macos","dependencies":[]},{"name":"path_provider_windows","dependencies":[]}],"date_created":"2022-12-15 14:11:24.851693","version":"3.3.8"} \ No newline at end of file diff --git a/packages/fl_query_hooks/example/.gitignore b/packages/fl_query_hooks/example/.gitignore index a8e938c..24476c5 100644 --- a/packages/fl_query_hooks/example/.gitignore +++ b/packages/fl_query_hooks/example/.gitignore @@ -32,9 +32,6 @@ migrate_working_dir/ .pub/ /build/ -# Web related -lib/generated_plugin_registrant.dart - # Symbolication related app.*.symbols diff --git a/packages/fl_query_hooks/example/.metadata b/packages/fl_query_hooks/example/.metadata index 95f73f5..8e89d4d 100644 --- a/packages/fl_query_hooks/example/.metadata +++ b/packages/fl_query_hooks/example/.metadata @@ -4,7 +4,7 @@ # This file should be version controlled. version: - revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 + revision: 9944297138845a94256f1cf37beb88ff9a8e811a channel: stable project_type: app @@ -13,26 +13,26 @@ project_type: app migration: platforms: - platform: root - create_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 - base_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 + create_revision: 9944297138845a94256f1cf37beb88ff9a8e811a + base_revision: 9944297138845a94256f1cf37beb88ff9a8e811a - platform: android - create_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 - base_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 + create_revision: 9944297138845a94256f1cf37beb88ff9a8e811a + base_revision: 9944297138845a94256f1cf37beb88ff9a8e811a - platform: ios - create_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 - base_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 + create_revision: 9944297138845a94256f1cf37beb88ff9a8e811a + base_revision: 9944297138845a94256f1cf37beb88ff9a8e811a - platform: linux - create_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 - base_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 + create_revision: 9944297138845a94256f1cf37beb88ff9a8e811a + base_revision: 9944297138845a94256f1cf37beb88ff9a8e811a - platform: macos - create_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 - base_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 + create_revision: 9944297138845a94256f1cf37beb88ff9a8e811a + base_revision: 9944297138845a94256f1cf37beb88ff9a8e811a - platform: web - create_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 - base_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 + create_revision: 9944297138845a94256f1cf37beb88ff9a8e811a + base_revision: 9944297138845a94256f1cf37beb88ff9a8e811a - platform: windows - create_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 - base_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 + create_revision: 9944297138845a94256f1cf37beb88ff9a8e811a + base_revision: 9944297138845a94256f1cf37beb88ff9a8e811a # User provided section diff --git a/packages/fl_query_hooks/example/android/app/build.gradle b/packages/fl_query_hooks/example/android/app/build.gradle index 0833ecf..b52183a 100644 --- a/packages/fl_query_hooks/example/android/app/build.gradle +++ b/packages/fl_query_hooks/example/android/app/build.gradle @@ -46,7 +46,7 @@ android { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "com.example.example" // You can update the following values to match your application needs. - // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration. + // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration. minSdkVersion flutter.minSdkVersion targetSdkVersion flutter.targetSdkVersion versionCode flutterVersionCode.toInteger() diff --git a/packages/fl_query_hooks/example/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java b/packages/fl_query_hooks/example/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java deleted file mode 100644 index 47e95c9..0000000 --- a/packages/fl_query_hooks/example/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java +++ /dev/null @@ -1,24 +0,0 @@ -package io.flutter.plugins; - -import androidx.annotation.Keep; -import androidx.annotation.NonNull; -import io.flutter.Log; - -import io.flutter.embedding.engine.FlutterEngine; - -/** - * Generated file. Do not edit. - * This file is generated by the Flutter tool based on the - * plugins that support the Android platform. - */ -@Keep -public final class GeneratedPluginRegistrant { - private static final String TAG = "GeneratedPluginRegistrant"; - public static void registerWith(@NonNull FlutterEngine flutterEngine) { - try { - flutterEngine.getPlugins().add(new dev.fluttercommunity.plus.connectivity.ConnectivityPlugin()); - } catch(Exception e) { - Log.e(TAG, "Error registering plugin connectivity_plus, dev.fluttercommunity.plus.connectivity.ConnectivityPlugin", e); - } - } -} diff --git a/packages/fl_query_hooks/example/android/build.gradle b/packages/fl_query_hooks/example/android/build.gradle index 83ae220..58a8c74 100644 --- a/packages/fl_query_hooks/example/android/build.gradle +++ b/packages/fl_query_hooks/example/android/build.gradle @@ -1,12 +1,12 @@ buildscript { - ext.kotlin_version = '1.6.10' + ext.kotlin_version = '1.7.10' repositories { google() mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:7.1.2' + classpath 'com.android.tools.build:gradle:7.2.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } diff --git a/packages/fl_query_hooks/example/android/gradle/wrapper/gradle-wrapper.jar b/packages/fl_query_hooks/example/android/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 13372ae..0000000 Binary files a/packages/fl_query_hooks/example/android/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/packages/fl_query_hooks/example/android/gradle/wrapper/gradle-wrapper.properties b/packages/fl_query_hooks/example/android/gradle/wrapper/gradle-wrapper.properties index cc5527d..3c472b9 100644 --- a/packages/fl_query_hooks/example/android/gradle/wrapper/gradle-wrapper.properties +++ b/packages/fl_query_hooks/example/android/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,5 @@ -#Fri Jun 23 08:50:38 CEST 2017 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip diff --git a/packages/fl_query_hooks/example/android/gradlew b/packages/fl_query_hooks/example/android/gradlew deleted file mode 100755 index 9d82f78..0000000 --- a/packages/fl_query_hooks/example/android/gradlew +++ /dev/null @@ -1,160 +0,0 @@ -#!/usr/bin/env bash - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn ( ) { - echo "$*" -} - -die ( ) { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; -esac - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules -function splitJvmOpts() { - JVM_OPTS=("$@") -} -eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS -JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" - -exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/packages/fl_query_hooks/example/android/gradlew.bat b/packages/fl_query_hooks/example/android/gradlew.bat deleted file mode 100644 index aec9973..0000000 --- a/packages/fl_query_hooks/example/android/gradlew.bat +++ /dev/null @@ -1,90 +0,0 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windowz variants - -if not "%OS%" == "Windows_NT" goto win9xME_args -if "%@eval[2+2]" == "4" goto 4NT_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* -goto execute - -:4NT_args -@rem Get arguments from the 4NT Shell from JP Software -set CMD_LINE_ARGS=%$ - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/packages/fl_query_hooks/example/android/local.properties b/packages/fl_query_hooks/example/android/local.properties deleted file mode 100644 index dd4db6b..0000000 --- a/packages/fl_query_hooks/example/android/local.properties +++ /dev/null @@ -1,2 +0,0 @@ -sdk.dir=/home/krtirtho/Android/Sdk -flutter.sdk=/opt/flutter \ No newline at end of file diff --git a/packages/fl_query_hooks/example/ios/Flutter/AppFrameworkInfo.plist b/packages/fl_query_hooks/example/ios/Flutter/AppFrameworkInfo.plist index 8d4492f..9625e10 100644 --- a/packages/fl_query_hooks/example/ios/Flutter/AppFrameworkInfo.plist +++ b/packages/fl_query_hooks/example/ios/Flutter/AppFrameworkInfo.plist @@ -21,6 +21,6 @@ CFBundleVersion 1.0 MinimumOSVersion - 9.0 + 11.0 diff --git a/packages/fl_query_hooks/example/ios/Flutter/Generated.xcconfig b/packages/fl_query_hooks/example/ios/Flutter/Generated.xcconfig deleted file mode 100644 index 2188029..0000000 --- a/packages/fl_query_hooks/example/ios/Flutter/Generated.xcconfig +++ /dev/null @@ -1,13 +0,0 @@ -// This is a generated file; do not edit or check into version control. -FLUTTER_ROOT=/opt/flutter -FLUTTER_APPLICATION_PATH=/home/krtirtho/dev/fl-query/packages/fl_query_hooks/example -COCOAPODS_PARALLEL_CODE_SIGN=true -FLUTTER_TARGET=lib/main.dart -FLUTTER_BUILD_DIR=build -FLUTTER_BUILD_NAME=1.0.0 -FLUTTER_BUILD_NUMBER=1 -EXCLUDED_ARCHS[sdk=iphonesimulator*]=i386 -DART_OBFUSCATION=false -TRACK_WIDGET_CREATION=false -TREE_SHAKE_ICONS=false -PACKAGE_CONFIG=.dart_tool/package_config.json diff --git a/packages/fl_query_hooks/example/ios/Flutter/flutter_export_environment.sh b/packages/fl_query_hooks/example/ios/Flutter/flutter_export_environment.sh deleted file mode 100755 index 6591be9..0000000 --- a/packages/fl_query_hooks/example/ios/Flutter/flutter_export_environment.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh -# This is a generated file; do not edit or check into version control. -export "FLUTTER_ROOT=/opt/flutter" -export "FLUTTER_APPLICATION_PATH=/home/krtirtho/dev/fl-query/packages/fl_query_hooks/example" -export "COCOAPODS_PARALLEL_CODE_SIGN=true" -export "FLUTTER_TARGET=lib/main.dart" -export "FLUTTER_BUILD_DIR=build" -export "FLUTTER_BUILD_NAME=1.0.0" -export "FLUTTER_BUILD_NUMBER=1" -export "DART_OBFUSCATION=false" -export "TRACK_WIDGET_CREATION=false" -export "TREE_SHAKE_ICONS=false" -export "PACKAGE_CONFIG=.dart_tool/package_config.json" diff --git a/packages/fl_query_hooks/example/ios/Runner.xcodeproj/project.pbxproj b/packages/fl_query_hooks/example/ios/Runner.xcodeproj/project.pbxproj index 6edd238..fe3d67b 100644 --- a/packages/fl_query_hooks/example/ios/Runner.xcodeproj/project.pbxproj +++ b/packages/fl_query_hooks/example/ios/Runner.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 50; + objectVersion = 54; objects = { /* Begin PBXBuildFile section */ @@ -171,6 +171,7 @@ /* Begin PBXShellScriptBuildPhase section */ 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; buildActionMask = 2147483647; files = ( ); @@ -185,6 +186,7 @@ }; 9740EEB61CF901F6004384FC /* Run Script */ = { isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; buildActionMask = 2147483647; files = ( ); @@ -272,7 +274,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; @@ -349,7 +351,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -398,7 +400,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; diff --git a/packages/fl_query_hooks/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png b/packages/fl_query_hooks/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png index 28c6bf0..7353c41 100644 Binary files a/packages/fl_query_hooks/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png and b/packages/fl_query_hooks/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png differ diff --git a/packages/fl_query_hooks/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png b/packages/fl_query_hooks/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png index 2ccbfd9..797d452 100644 Binary files a/packages/fl_query_hooks/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png and b/packages/fl_query_hooks/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png differ diff --git a/packages/fl_query_hooks/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png b/packages/fl_query_hooks/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png index f091b6b..6ed2d93 100644 Binary files a/packages/fl_query_hooks/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png and b/packages/fl_query_hooks/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png differ diff --git a/packages/fl_query_hooks/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png b/packages/fl_query_hooks/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png index 4cde121..4cd7b00 100644 Binary files a/packages/fl_query_hooks/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png and b/packages/fl_query_hooks/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png differ diff --git a/packages/fl_query_hooks/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png b/packages/fl_query_hooks/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png index d0ef06e..fe73094 100644 Binary files a/packages/fl_query_hooks/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png and b/packages/fl_query_hooks/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png differ diff --git a/packages/fl_query_hooks/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png b/packages/fl_query_hooks/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png index dcdc230..321773c 100644 Binary files a/packages/fl_query_hooks/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png and b/packages/fl_query_hooks/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png differ diff --git a/packages/fl_query_hooks/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png b/packages/fl_query_hooks/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png index 2ccbfd9..797d452 100644 Binary files a/packages/fl_query_hooks/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png and b/packages/fl_query_hooks/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png differ diff --git a/packages/fl_query_hooks/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png b/packages/fl_query_hooks/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png index c8f9ed8..502f463 100644 Binary files a/packages/fl_query_hooks/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png and b/packages/fl_query_hooks/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png differ diff --git a/packages/fl_query_hooks/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png b/packages/fl_query_hooks/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png index a6d6b86..0ec3034 100644 Binary files a/packages/fl_query_hooks/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png and b/packages/fl_query_hooks/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png differ diff --git a/packages/fl_query_hooks/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png b/packages/fl_query_hooks/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png index a6d6b86..0ec3034 100644 Binary files a/packages/fl_query_hooks/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png and b/packages/fl_query_hooks/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png differ diff --git a/packages/fl_query_hooks/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png b/packages/fl_query_hooks/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png index 75b2d16..e9f5fea 100644 Binary files a/packages/fl_query_hooks/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png and b/packages/fl_query_hooks/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png differ diff --git a/packages/fl_query_hooks/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png b/packages/fl_query_hooks/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png index c4df70d..84ac32a 100644 Binary files a/packages/fl_query_hooks/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png and b/packages/fl_query_hooks/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png differ diff --git a/packages/fl_query_hooks/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png b/packages/fl_query_hooks/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png index 6a84f41..8953cba 100644 Binary files a/packages/fl_query_hooks/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png and b/packages/fl_query_hooks/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png differ diff --git a/packages/fl_query_hooks/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png b/packages/fl_query_hooks/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png index d0e1f58..0467bf1 100644 Binary files a/packages/fl_query_hooks/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png and b/packages/fl_query_hooks/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png differ diff --git a/packages/fl_query_hooks/example/ios/Runner/GeneratedPluginRegistrant.h b/packages/fl_query_hooks/example/ios/Runner/GeneratedPluginRegistrant.h deleted file mode 100644 index 7a89092..0000000 --- a/packages/fl_query_hooks/example/ios/Runner/GeneratedPluginRegistrant.h +++ /dev/null @@ -1,19 +0,0 @@ -// -// Generated file. Do not edit. -// - -// clang-format off - -#ifndef GeneratedPluginRegistrant_h -#define GeneratedPluginRegistrant_h - -#import - -NS_ASSUME_NONNULL_BEGIN - -@interface GeneratedPluginRegistrant : NSObject -+ (void)registerWithRegistry:(NSObject*)registry; -@end - -NS_ASSUME_NONNULL_END -#endif /* GeneratedPluginRegistrant_h */ diff --git a/packages/fl_query_hooks/example/ios/Runner/GeneratedPluginRegistrant.m b/packages/fl_query_hooks/example/ios/Runner/GeneratedPluginRegistrant.m deleted file mode 100644 index a85d5ee..0000000 --- a/packages/fl_query_hooks/example/ios/Runner/GeneratedPluginRegistrant.m +++ /dev/null @@ -1,21 +0,0 @@ -// -// Generated file. Do not edit. -// - -// clang-format off - -#import "GeneratedPluginRegistrant.h" - -#if __has_include() -#import -#else -@import connectivity_plus; -#endif - -@implementation GeneratedPluginRegistrant - -+ (void)registerWithRegistry:(NSObject*)registry { - [ConnectivityPlusPlugin registerWithRegistrar:[registry registrarForPlugin:@"ConnectivityPlusPlugin"]]; -} - -@end diff --git a/packages/fl_query_hooks/example/ios/Runner/Info.plist b/packages/fl_query_hooks/example/ios/Runner/Info.plist index 907f329..7f55346 100644 --- a/packages/fl_query_hooks/example/ios/Runner/Info.plist +++ b/packages/fl_query_hooks/example/ios/Runner/Info.plist @@ -45,5 +45,7 @@ CADisableMinimumFrameDurationOnPhone + UIApplicationSupportsIndirectInputEvents + diff --git a/packages/fl_query_hooks/example/lib/components/basic_hook_infinite_query.dart b/packages/fl_query_hooks/example/lib/components/basic_hook_infinite_query.dart deleted file mode 100644 index 9f84f81..0000000 --- a/packages/fl_query_hooks/example/lib/components/basic_hook_infinite_query.dart +++ /dev/null @@ -1,99 +0,0 @@ -import 'dart:convert'; - -import 'package:fl_query_hooks/fl_query_hooks.dart'; -import 'package:flutter/material.dart'; -import 'package:fl_query/fl_query.dart'; -import 'package:flutter_hooks/flutter_hooks.dart'; -import 'package:http/http.dart' as http; - -final infiniteQueryHookJob = InfiniteQueryJob( - queryKey: "infinite-posts", - initialParam: 1, - task: (queryKey, pageParam, externalData) async { - return jsonDecode( - (await http.get( - Uri.parse("https://jsonplaceholder.typicode.com/posts/$pageParam"), - )) - .body, - ); - }, - getNextPageParam: (lastPage, lastParam) { - return lastParam + 1; - }, - getPreviousPageParam: (lastPage, lastParam) { - return lastParam - 1; - }, -); - -class BasicHookInfiniteQueryExample extends HookWidget { - const BasicHookInfiniteQueryExample({Key? key}) : super(key: key); - - @override - Widget build(BuildContext context) { - final infiniteQuery = useInfiniteQuery( - job: infiniteQueryHookJob, - externalData: null, - ); - - return Scaffold( - appBar: AppBar(), - body: Stack( - children: [ - ListView.builder( - itemCount: infiniteQuery.pages.length + 1, - itemBuilder: (context, index) { - if (index == 0) { - return Text( - """ - InfiniteQuery properties - - isFetchingNextPage: ${infiniteQuery.isFetchingNextPage} - isFetchingPreviousPage: ${infiniteQuery.isFetchingPreviousPage} - isLoading: ${infiniteQuery.isLoading} - isRefetching: ${infiniteQuery.isRefetching} - isError: ${infiniteQuery.isError} - isSuccess: ${infiniteQuery.isSuccess} - isIdle: ${infiniteQuery.isIdle} - isInactive: ${infiniteQuery.isInactive} - isStale: ${infiniteQuery.isStale} - fetched: ${infiniteQuery.fetched} - - hasData: ${infiniteQuery.hasData} - hasError: ${infiniteQuery.hasError} - hasNextPage: ${infiniteQuery.hasNextPage} - hasPreviousPage: ${infiniteQuery.hasPreviousPage} - - refetchCount: ${infiniteQuery.refetchCount} - retryAttempts: ${infiniteQuery.retryAttempts} - updatedAt: ${infiniteQuery.updatedAt} - """, - ); - } - final page = infiniteQuery.pages[index - 1]; - return ListTile( - title: Text(page?["title"] ?? ""), - subtitle: Text(page?["body"] ?? ""), - ); - }, - ), - Align( - alignment: Alignment.bottomRight, - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - IconButton( - icon: const Icon(Icons.refresh_rounded), - onPressed: () => infiniteQuery.refetchPages(), - ), - IconButton( - icon: const Icon(Icons.get_app_rounded), - onPressed: () => infiniteQuery.fetchNextPage(), - ), - ], - ), - ), - ], - ), - ); - } -} diff --git a/packages/fl_query_hooks/example/lib/components/basic_hook_mutation.dart b/packages/fl_query_hooks/example/lib/components/basic_hook_mutation.dart deleted file mode 100644 index e98cf29..0000000 --- a/packages/fl_query_hooks/example/lib/components/basic_hook_mutation.dart +++ /dev/null @@ -1,94 +0,0 @@ -import 'dart:convert'; -import 'dart:math'; - -import 'package:fl_query_hooks_example/components/basic_hook_query.dart'; -import 'package:fl_query_hooks/fl_query_hooks.dart'; -import 'package:flutter_hooks/flutter_hooks.dart'; -import 'package:http/http.dart' as http; - -import 'package:fl_query/fl_query.dart'; -import 'package:flutter/material.dart'; - -final basicMutationHookJob = MutationJob>( - mutationKey: "basic-hook-mutation-example", - task: (key, data) async { - final response = await http.post( - Uri.parse( - // to simulate a failing response environment - Random().nextBool() - ? "https://jsonplaceholder.typicode.com/posts" - : "https://google.com", - ), - headers: {'Content-type': 'application/json; charset=UTF-8'}, - body: jsonEncode(data), - ); - return jsonDecode(response.body); - }, -); - -class BasicHookMutationExample extends HookWidget { - const BasicHookMutationExample({super.key}); - @override - Widget build(BuildContext context) { - final id = useMemoized(() => Random().nextInt(2000000), []); - final titleController = useTextEditingController(); - final bodyController = useTextEditingController(); - final mutation = useMutation( - job: basicMutationHookJob, - onMutate: (v) { - QueryBowl.of(context) - .setQueryData(successHookJob.queryKey, (oldData) { - if (oldData?.contains("After Mutate (OPTIMISTIC UPDATE)") == true) { - return "$oldData"; - } - return "$oldData - After Mutate (OPTIMISTIC UPDATE)"; - }); - }, - ); - return Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - "# Basic Mutation Hook Example (with failure & retry simulation)", - style: Theme.of(context).textTheme.headline5, - ), - Padding( - padding: const EdgeInsets.all(8.0), - child: Column( - children: [ - TextField( - controller: titleController, - decoration: const InputDecoration(labelText: "Title"), - ), - TextField( - controller: bodyController, - decoration: const InputDecoration(labelText: "Body"), - ), - const SizedBox(height: 20), - ElevatedButton( - onPressed: () { - final title = titleController.value.text; - final body = bodyController.value.text; - if (body.isEmpty || title.isEmpty) return; - mutation.mutate({ - "title": title, - "body": body, - "id": id, - }, onData: (data, variable, context) { - // resetting the form - titleController.text = ""; - bodyController.text = ""; - }); - }, - child: const Text("Post"), - ), - const SizedBox(height: 20), - if (mutation.hasData) Text("Response\n${mutation.data}"), - if (mutation.hasError) Text(mutation.error.toString()), - ], - ), - ) - ], - ); - } -} diff --git a/packages/fl_query_hooks/example/lib/components/basic_hook_query.dart b/packages/fl_query_hooks/example/lib/components/basic_hook_query.dart deleted file mode 100644 index 15f73ed..0000000 --- a/packages/fl_query_hooks/example/lib/components/basic_hook_query.dart +++ /dev/null @@ -1,80 +0,0 @@ -import 'dart:math'; - -import 'package:fl_query/fl_query.dart'; -import 'package:fl_query_hooks/fl_query_hooks.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_hooks/flutter_hooks.dart'; - -final successHookJob = QueryJob( - queryKey: "greetings-hook-example", - task: (queryKey, _) => Future.delayed( - const Duration(seconds: 2), - () => - "The work successfully executed. Data: key=($queryKey) value=${Random.secure().nextInt(100)}", - ), -); - -final canFailHookJob = QueryJob( - queryKey: "failure-hook-example", - task: (queryKey, _) => Random().nextBool() - ? Future.error("$queryKey operation failed for unknown reason") - : Future.value( - "Successful execution. Result: $queryKey=${Random().nextInt(100)}", - ), -); - -class BasicHookQueryExample extends HookWidget { - const BasicHookQueryExample({Key? key}) : super(key: key); - - @override - Widget build(BuildContext context) { - final successQuery = useQuery(job: successHookJob, externalData: null); - final canFailQuery = useQuery(job: canFailHookJob, externalData: null); - return Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - "# Basic Query Hook Example", - style: Theme.of(context).textTheme.headline5, - ), - !successQuery.hasData || - successQuery.isLoading || - successQuery.isRefetching - ? const CircularProgressIndicator() - : Row( - children: [ - Text(successQuery.data!), - ElevatedButton( - child: const Text("Refetch"), - onPressed: () async { - await successQuery.refetch(); - }, - ), - ], - ), - !canFailQuery.hasData || - canFailQuery.isLoading || - canFailQuery.isRefetching - ? const CircularProgressIndicator() - : Row( - children: [ - if (canFailQuery.hasError) - Text( - "${canFailQuery.error}. Retrying: ${canFailQuery.retryAttempts}", - ), - if (canFailQuery.hasData) - Text( - "Success after ${canFailQuery.retryAttempts}\nData: ${canFailQuery.data}", - ), - ElevatedButton( - child: const Text("Refetch"), - onPressed: () async { - await canFailQuery.refetch(); - }, - ), - ], - ) - ], - ); - } -} diff --git a/packages/fl_query_hooks/example/lib/components/lazy_hook_query.dart b/packages/fl_query_hooks/example/lib/components/lazy_hook_query.dart deleted file mode 100644 index 3938422..0000000 --- a/packages/fl_query_hooks/example/lib/components/lazy_hook_query.dart +++ /dev/null @@ -1,43 +0,0 @@ -import 'package:fl_query/fl_query.dart'; -import 'package:fl_query_hooks/fl_query_hooks.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_hooks/flutter_hooks.dart'; - -final lazyHookQueryJob = QueryJob( - queryKey: "lazy-hook-query", - enabled: false, - task: (queryKey, data) { - return Future.delayed(const Duration(milliseconds: 500), - () => "Result: key=$queryKey value=$data"); - }, -); - -class LazyHookQueryExample extends HookWidget { - const LazyHookQueryExample({Key? key}) : super(key: key); - - @override - Widget build(BuildContext context) { - final query = useQuery( - job: lazyHookQueryJob, - externalData: "Love", - ); - return Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - "# Lazy Hook Query Example", - style: Theme.of(context).textTheme.headline5, - ), - Row( - children: [ - Text("Current Data: ${query.data ?? "Loading"}"), - ElevatedButton( - child: const Text("Refetch Query"), - onPressed: () => query.refetch(), - ), - ], - ), - ], - ); - } -} diff --git a/packages/fl_query_hooks/example/lib/components/mutation_hook_variable_key.dart b/packages/fl_query_hooks/example/lib/components/mutation_hook_variable_key.dart deleted file mode 100644 index f3b1f70..0000000 --- a/packages/fl_query_hooks/example/lib/components/mutation_hook_variable_key.dart +++ /dev/null @@ -1,50 +0,0 @@ -import 'dart:math'; - -import 'package:fl_query/fl_query.dart'; -import 'package:fl_query_hooks/fl_query_hooks.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_hooks/flutter_hooks.dart'; - -final mutationHookVariableKeyJob = MutationJob.withVariableKey( - preMutationKey: "mutation-example", - task: (queryKey, variables) { - return Future.value("$variables"); - }, -); - -class MutationHookVariableKeyExample extends HookWidget { - const MutationHookVariableKeyExample({Key? key}) : super(key: key); - @override - Widget build(BuildContext context) { - final id = useState(Random().nextDouble()); - final mutation = useMutation( - job: mutationHookVariableKeyJob(id.value.toString()), - ); - return Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - "# Mutation Hook Variable Key Example", - style: Theme.of(context).textTheme.headline5, - ), - Row( - children: [ - Text("${mutation.mutationKey} Result: ${mutation.data}"), - ElevatedButton( - child: const Text("Generate Random Data"), - onPressed: () { - mutation.mutate(Random().nextDouble()); - }, - ), - ElevatedButton( - child: const Text("New Mutation"), - onPressed: () { - id.value = Random().nextDouble(); - }, - ), - ], - ), - ], - ); - } -} diff --git a/packages/fl_query_hooks/example/lib/components/query_hook_external_data.dart b/packages/fl_query_hooks/example/lib/components/query_hook_external_data.dart deleted file mode 100644 index 8ada29f..0000000 --- a/packages/fl_query_hooks/example/lib/components/query_hook_external_data.dart +++ /dev/null @@ -1,58 +0,0 @@ -import 'dart:math'; - -import 'package:fl_query/fl_query.dart'; -import 'package:fl_query_hooks/fl_query_hooks.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_hooks/flutter_hooks.dart'; - -final queryHookExternalDataJob = QueryJob( - queryKey: "query-hook-external-data", - cacheTime: const Duration(seconds: 10), - task: (queryKey, data) { - return Future.delayed(const Duration(milliseconds: 500), - () => "Hello from $queryKey with $data"); - }, -); - -class QueryHookExternalDataExample extends HookWidget { - const QueryHookExternalDataExample({Key? key}) : super(key: key); - - @override - Widget build(BuildContext context) { - final externalData = useState(Random().nextDouble() * 200); - final query = useQuery( - job: queryHookExternalDataJob, - externalData: externalData.value, - ); - return Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - "# Query Hook With External Data Example", - style: Theme.of(context).textTheme.headline5, - ), - query.isLoading || query.isRefetching || !query.hasData - ? const CircularProgressIndicator() - : Row( - children: [ - Container( - width: query.externalData, - height: query.externalData, - decoration: const BoxDecoration( - shape: BoxShape.circle, - color: Colors.blue, - ), - child: Center(child: Text(query.externalData.toString())), - ), - ElevatedButton( - child: const Text("New Id"), - onPressed: () { - externalData.value = Random().nextDouble() * 200; - }, - ) - ], - ) - ], - ); - } -} diff --git a/packages/fl_query_hooks/example/lib/components/query_hook_previous_data.dart b/packages/fl_query_hooks/example/lib/components/query_hook_previous_data.dart deleted file mode 100644 index c98a317..0000000 --- a/packages/fl_query_hooks/example/lib/components/query_hook_previous_data.dart +++ /dev/null @@ -1,62 +0,0 @@ -import 'dart:convert'; - -import 'package:fl_query/fl_query.dart'; -import 'package:fl_query_hooks/fl_query_hooks.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_hooks/flutter_hooks.dart'; -import 'package:http/http.dart' as http; - -final todoJob = QueryJob.withVariableKey( - preQueryKey: "todo", - task: (queryKey, _) async { - final res = await http.get( - Uri.parse( - "https://jsonplaceholder.typicode.com/todos/${getVariable(queryKey)}"), - ); - return jsonDecode(res.body); - }, - keepPreviousData: true, -); - -class QueryHookPreviousDataExample extends HookWidget { - const QueryHookPreviousDataExample({Key? key}) : super(key: key); - - @override - Widget build(BuildContext context) { - final id = useState(1); - final query = - useQuery(job: todoJob(id.value.toString()), externalData: null); - - return Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - "# Query Variable Key with keepPreviousData", - style: Theme.of(context).textTheme.headline5, - ), - if (query.hasError) - Text(query.error.toString()) - else if (!query.hasData) - const CircularProgressIndicator() - else - Text(jsonEncode(query.data ?? {})), - Row( - children: [ - IconButton( - icon: const Icon(Icons.remove), - onPressed: () { - id.value -= 1; - }, - ), - IconButton( - icon: const Icon(Icons.add), - onPressed: () { - id.value += 1; - }, - ), - ], - ) - ], - ); - } -} diff --git a/packages/fl_query_hooks/example/lib/components/query_hook_variable_key.dart b/packages/fl_query_hooks/example/lib/components/query_hook_variable_key.dart deleted file mode 100644 index 66e59a0..0000000 --- a/packages/fl_query_hooks/example/lib/components/query_hook_variable_key.dart +++ /dev/null @@ -1,49 +0,0 @@ -import 'dart:math'; - -import 'package:fl_query/fl_query.dart'; -import 'package:fl_query_hooks/fl_query_hooks.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_hooks/flutter_hooks.dart'; - -final queryHookVariableKeyJob = - QueryJob.withVariableKey(task: (queryKey, externalData) { - return Future.delayed( - const Duration(milliseconds: 500), - () => "QueryKey:${queryKey.split("#").last}", - ); -}); - -class QueryHookVariableKeyExample extends HookWidget { - const QueryHookVariableKeyExample({Key? key}) : super(key: key); - - @override - Widget build(BuildContext context) { - final id = useState(Random().nextDouble() * 200); - final query = useQuery( - job: queryHookVariableKeyJob("hook-variable-query#${id.value}"), - externalData: null, - ); - return Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - "# Query Hook Variable Example", - style: Theme.of(context).textTheme.headline5, - ), - query.isLoading || query.isRefetching || !query.hasData - ? const CircularProgressIndicator() - : Row( - children: [ - Text("Query Result: ${query.data}"), - ElevatedButton( - child: const Text("New Id"), - onPressed: () { - id.value = Random().nextDouble() * 200; - }, - ), - ], - ) - ], - ); - } -} diff --git a/packages/fl_query_hooks/example/lib/generated_plugin_registrant.dart b/packages/fl_query_hooks/example/lib/generated_plugin_registrant.dart deleted file mode 100644 index 533f170..0000000 --- a/packages/fl_query_hooks/example/lib/generated_plugin_registrant.dart +++ /dev/null @@ -1,17 +0,0 @@ -// -// Generated file. Do not edit. -// - -// ignore_for_file: directives_ordering -// ignore_for_file: lines_longer_than_80_chars -// ignore_for_file: depend_on_referenced_packages - -import 'package:connectivity_plus_web/connectivity_plus_web.dart'; - -import 'package:flutter_web_plugins/flutter_web_plugins.dart'; - -// ignore: public_member_api_docs -void registerPlugins(Registrar registrar) { - ConnectivityPlusPlugin.registerWith(registrar); - registrar.registerMessageHandler(); -} diff --git a/packages/fl_query_hooks/example/lib/main.dart b/packages/fl_query_hooks/example/lib/main.dart index 711d30c..75b16c6 100644 --- a/packages/fl_query_hooks/example/lib/main.dart +++ b/packages/fl_query_hooks/example/lib/main.dart @@ -1,79 +1,33 @@ -import 'package:fl_query_hooks_example/components/basic_hook_infinite_query.dart'; -import 'package:fl_query_hooks_example/components/basic_hook_mutation.dart'; -import 'package:fl_query_hooks_example/components/basic_hook_query.dart'; -import 'package:fl_query_hooks_example/components/lazy_hook_query.dart'; -import 'package:fl_query_hooks_example/components/mutation_hook_variable_key.dart'; -import 'package:fl_query_hooks_example/components/query_hook_external_data.dart'; -import 'package:fl_query_hooks_example/components/query_hook_previous_data.dart'; -import 'package:fl_query_hooks_example/components/query_hook_variable_key.dart'; +import 'package:fl_query_connectivity_plus_adapter/fl_query_connectivity_plus_adapter.dart'; +import 'package:fl_query_hooks_example/router.dart'; import 'package:fl_query/fl_query.dart'; import 'package:flutter/material.dart'; -void main() { - runApp(const MyApp()); +void main() async { + WidgetsFlutterBinding.ensureInitialized(); + await QueryClient.initialize( + cachePrefix: 'fl_query_hooks_example', + connectivity: FlQueryConnectivityPlusAdapter(), + ); + runApp( + QueryClientProvider( + child: const MainApp(), + ), + ); } -class MyApp extends StatelessWidget { - const MyApp({Key? key}) : super(key: key); +class MainApp extends StatelessWidget { + const MainApp({super.key}); @override Widget build(BuildContext context) { - return QueryBowlScope( - bowl: QueryBowl(), - child: MaterialApp( - // showPerformanceOverlay: true, - title: 'Fl-Query Hooks Example', - theme: ThemeData( - useMaterial3: true, - primarySwatch: Colors.blue, - ), - home: const MyHomePage(), + return MaterialApp.router( + theme: ThemeData( + colorSchemeSeed: Colors.red[100], + useMaterial3: true, ), - ); - } -} - -class MyHomePage extends StatefulWidget { - const MyHomePage({Key? key}) : super(key: key); - - @override - State createState() => _MyHomePageState(); -} - -class _MyHomePageState extends State with WidgetsBindingObserver { - @override - Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar( - title: const Text("Fl Query Hooks Example"), - ), - body: SingleChildScrollView( - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Column( - children: [ - const BasicHookQueryExample(), - const QueryHookExternalDataExample(), - const LazyHookQueryExample(), - const QueryHookVariableKeyExample(), - const QueryHookPreviousDataExample(), - ListTile( - title: const Text("Infinite Query Example"), - trailing: const Icon(Icons.open_in_new), - onTap: () { - Navigator.of(context).push( - MaterialPageRoute( - builder: (context) => const BasicHookInfiniteQueryExample(), - ), - ); - }, - ), - const Divider(), - const BasicHookMutationExample(), - const MutationHookVariableKeyExample(), - ], - ), - )), + title: 'FL Query Hooks Example', + routerConfig: router, ); } } diff --git a/packages/fl_query_hooks/example/lib/models/product.dart b/packages/fl_query_hooks/example/lib/models/product.dart new file mode 100644 index 0000000..f613d52 --- /dev/null +++ b/packages/fl_query_hooks/example/lib/models/product.dart @@ -0,0 +1,92 @@ +class Product { + int id; + String title; + String description; + double price; + double discountPercentage; + double rating; + double stock; + String brand; + String category; + String thumbnail; + List images; + + Product({ + required this.id, + required this.title, + required this.description, + required this.price, + required this.discountPercentage, + required this.rating, + required this.stock, + required this.brand, + required this.category, + required this.thumbnail, + required this.images, + }); + + Product.fromJson(Map json) + : id = json['id'], + title = json['title'], + description = json['description'], + price = json['price'].toDouble(), + discountPercentage = json['discountPercentage'].toDouble(), + rating = json['rating'].toDouble(), + stock = json['stock'].toDouble(), + brand = json['brand'], + category = json['category'], + thumbnail = json['thumbnail'], + images = json['images'].cast(); + + Map toJson() { + final Map data = { + 'id': id, + 'title': title, + 'description': description, + 'price': price, + 'discountPercentage': discountPercentage, + 'rating': rating, + 'stock': stock, + 'brand': brand, + 'category': category, + 'thumbnail': thumbnail, + 'images': images, + }; + return data; + } +} + +class PagedProducts { + List products; + int total; + int skip; + int limit; + + PagedProducts({ + this.products = const [], + required this.total, + required this.skip, + required this.limit, + }); + + PagedProducts.fromJson(Map json) + : products = json['products'] + ?.map((v) => Product.fromJson( + Map.castFrom(v), + )) + .toList() ?? + [], + total = json['total'], + skip = json['skip'], + limit = json['limit']; + + Map toJson() { + final Map data = { + 'products': products.map((v) => v.toJson()).toList(), + 'total': total, + 'skip': skip, + 'limit': limit, + }; + return data; + } +} diff --git a/packages/fl_query_hooks/example/lib/pages/home.dart b/packages/fl_query_hooks/example/lib/pages/home.dart new file mode 100644 index 0000000..a391347 --- /dev/null +++ b/packages/fl_query_hooks/example/lib/pages/home.dart @@ -0,0 +1,31 @@ +import 'package:flutter/material.dart'; +import 'package:go_router/go_router.dart'; + +class HomePage extends StatelessWidget { + const HomePage({super.key}); + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text('FL Query Hooks Example'), + ), + body: ListView( + children: [ + ListTile( + title: const Text('Query'), + onTap: () => GoRouter.of(context).push('/query'), + ), + ListTile( + title: const Text('Infinite Query'), + onTap: () => GoRouter.of(context).push('/infinite-query'), + ), + ListTile( + title: const Text('Mutation'), + onTap: () => GoRouter.of(context).push('/mutation'), + ), + ], + ), + ); + } +} diff --git a/packages/fl_query_hooks/example/lib/pages/infinite_query.dart b/packages/fl_query_hooks/example/lib/pages/infinite_query.dart new file mode 100644 index 0000000..3916f2a --- /dev/null +++ b/packages/fl_query_hooks/example/lib/pages/infinite_query.dart @@ -0,0 +1,92 @@ +import 'dart:convert'; + +import 'package:fl_query_hooks/fl_query_hooks.dart'; +import 'package:fl_query_hooks_example/models/product.dart'; +import 'package:fl_query/fl_query.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_hooks/flutter_hooks.dart'; +import 'package:http/http.dart'; + +class InfiniteQueryPageWidget extends HookWidget { + const InfiniteQueryPageWidget({super.key}); + + @override + Widget build(BuildContext context) { + final controller = useScrollController(); + final query = useInfiniteQuery( + "products", + (page) async { + final res = await get(Uri.parse( + "https://dummyjson.com/products?limit=10&skip=${page * 10}", + )); + + if (res.statusCode == 200) { + return PagedProducts.fromJson(jsonDecode(res.body)); + } else { + throw ClientException(res.statusCode.toString(), res.request?.url); + } + }, + nextPage: (lastPage, lastPageData) { + /// returning [null] will set [hasNextPage] to [false] + if (lastPageData.products.length < 10) return null; + return lastPage + 1; + }, + initialPage: 0, + jsonConfig: JsonConfig( + fromJson: (json) => PagedProducts.fromJson(json), + toJson: (data) => data.toJson(), + ), + ); + + useEffect(() { + listener() async { + if (controller.position.pixels == controller.position.maxScrollExtent) { + final query = QueryClient.of(context).getInfiniteQuery("products"); + await query?.fetchNext(); + } + } + + controller.addListener(listener); + + return () => controller.removeListener(listener); + }, [controller]); + + final products = query.pages.map((e) => e.products).expand((e) => e); + + return Scaffold( + appBar: AppBar( + title: const Text('Infinite Query'), + ), + floatingActionButton: + InfiniteQueryListenable("products", builder: (context, query) { + return FloatingActionButton( + onPressed: () { + query?.fetchNext(); + }, + child: Text(query?.pages.length.toString() ?? "-69"), + ); + }), + body: !query.hasPages + ? const Center( + child: CircularProgressIndicator(), + ) + : ListView( + controller: controller, + children: [ + for (final product in products) + ListTile( + title: Text(product.title), + subtitle: Text(product.description), + leading: Image.network(product.thumbnail), + ), + if (query.hasNextPage) + const Center( + child: CircularProgressIndicator(), + ), + if (query.hasErrors) + ...query.errors.map((e) => Text(e.message)).toList(), + ], + ), + ); + } +} diff --git a/packages/fl_query_hooks/example/lib/pages/mutation/mutation.dart b/packages/fl_query_hooks/example/lib/pages/mutation/mutation.dart new file mode 100644 index 0000000..f31261b --- /dev/null +++ b/packages/fl_query_hooks/example/lib/pages/mutation/mutation.dart @@ -0,0 +1,105 @@ +import 'package:fl_query_hooks/fl_query_hooks.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_hooks/flutter_hooks.dart'; + +class MutationPage extends HookWidget { + const MutationPage({super.key}); + + @override + Widget build(BuildContext context) { + final nameController = useTextEditingController(); + final emailController = useTextEditingController(); + final passwordController = useTextEditingController(); + + final mutation = useMutation, dynamic, + Map, dynamic>( + 'sign-up', + (variables) { + return Future.delayed( + const Duration(seconds: 1), + () => { + 'name': variables['name'], + 'email': variables['email'], + 'password': variables['password'], + }, + ); + }, + onMutate: (variables) { + print('onMutate: $variables'); + return "Recover ME"; + }, + onData: (data, recoveryData) { + print('onData: $data'); + print('recoveryData: $recoveryData'); + }, + refreshQueries: const ['hello'], + ); + + return Scaffold( + appBar: AppBar( + title: const Text('Mutation'), + ), + body: mutation.hasData + ? ListView( + padding: const EdgeInsets.all(16), + children: [ + Center( + child: Text('Welcome ${mutation.data!['name']}'), + ), + const SizedBox(height: 16), + Center( + child: Text('Your email is ${mutation.data!['email']}'), + ), + const SizedBox(height: 16), + ElevatedButton( + onPressed: () { + mutation.reset(); + }, + child: const Text('Log out'), + ), + ], + ) + : ListView( + padding: const EdgeInsets.all(16), + children: [ + TextField( + controller: nameController, + keyboardType: TextInputType.name, + decoration: const InputDecoration( + labelText: 'Name', + ), + ), + const SizedBox(height: 16), + TextField( + controller: emailController, + keyboardType: TextInputType.emailAddress, + decoration: const InputDecoration( + labelText: 'Email', + ), + ), + const SizedBox(height: 16), + TextField( + controller: passwordController, + obscureText: true, + decoration: const InputDecoration( + labelText: 'Password', + ), + ), + const SizedBox(height: 20), + ElevatedButton( + onPressed: () async { + await mutation.mutate({ + 'name': nameController.text, + 'email': emailController.text, + 'password': passwordController.text, + }); + }, + child: mutation.isMutating + ? const CircularProgressIndicator() + : const Text('Sign Up'), + ), + ], + ), + ); + } +} diff --git a/packages/fl_query_hooks/example/lib/pages/query.dart b/packages/fl_query_hooks/example/lib/pages/query.dart new file mode 100644 index 0000000..4dbfd02 --- /dev/null +++ b/packages/fl_query_hooks/example/lib/pages/query.dart @@ -0,0 +1,62 @@ +import 'dart:math'; + +import 'package:fl_query/fl_query.dart'; +import 'package:fl_query_hooks/fl_query_hooks.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_hooks/flutter_hooks.dart'; + +class QueryPage extends HookWidget { + const QueryPage({super.key}); + + @override + Widget build(BuildContext context) { + final value = Random().nextInt(200000); + final query = useQuery( + 'hello', + () { + return Future.delayed( + const Duration(seconds: 6), () => 'Hello World! $value'); + }, + initial: 'Hello', + jsonConfig: JsonConfig( + fromJson: (json) => json['data'], + toJson: (data) => {'data': data}, + ), + onData: (value) { + debugPrint('onData: $value'); + }, + onError: (error) { + debugPrint('onError: $error'); + }, + ); + + return Scaffold( + appBar: AppBar( + title: const Text('Query'), + ), + floatingActionButton: + QueryListenable('hello', builder: (context, query) { + if (query == null) { + return const SizedBox(); + } + return FloatingActionButton( + onPressed: () { + query.refresh(); + }, + child: Text(query.data ?? 'No Data'), + ); + }), + body: query.isLoading + ? const Center( + child: CircularProgressIndicator(), + ) + : query.hasError + ? Center( + child: Text(query.error.toString()), + ) + : Center( + child: Text(query.data ?? "Unfortunately, there's no data"), + ), + ); + } +} diff --git a/packages/fl_query_hooks/example/lib/router.dart b/packages/fl_query_hooks/example/lib/router.dart new file mode 100644 index 0000000..5f3c769 --- /dev/null +++ b/packages/fl_query_hooks/example/lib/router.dart @@ -0,0 +1,27 @@ +import "package:fl_query_hooks_example/pages/home.dart"; +import "package:fl_query_hooks_example/pages/infinite_query.dart"; +import "package:fl_query_hooks_example/pages/mutation/mutation.dart"; +import "package:fl_query_hooks_example/pages/query.dart"; +import "package:go_router/go_router.dart"; + +final router = GoRouter( + initialLocation: '/', + routes: [ + GoRoute( + path: '/', + builder: (context, state) => const HomePage(), + ), + GoRoute( + path: '/query', + builder: (context, state) => const QueryPage(), + ), + GoRoute( + path: '/infinite-query', + builder: (context, state) => const InfiniteQueryPageWidget(), + ), + GoRoute( + path: '/mutation', + builder: (context, state) => const MutationPage(), + ), + ], +); diff --git a/packages/fl_query_hooks/example/linux/flutter/ephemeral/.plugin_symlinks/connectivity_plus_linux b/packages/fl_query_hooks/example/linux/flutter/ephemeral/.plugin_symlinks/connectivity_plus_linux deleted file mode 120000 index 81fb0db..0000000 --- a/packages/fl_query_hooks/example/linux/flutter/ephemeral/.plugin_symlinks/connectivity_plus_linux +++ /dev/null @@ -1 +0,0 @@ -/opt/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_linux-1.3.1/ \ No newline at end of file diff --git a/packages/fl_query_hooks/example/linux/flutter/ephemeral/flutter_linux/fl_basic_message_channel.h b/packages/fl_query_hooks/example/linux/flutter/ephemeral/flutter_linux/fl_basic_message_channel.h deleted file mode 100644 index b9fec01..0000000 --- a/packages/fl_query_hooks/example/linux/flutter/ephemeral/flutter_linux/fl_basic_message_channel.h +++ /dev/null @@ -1,205 +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. - -#ifndef FLUTTER_SHELL_PLATFORM_LINUX_FL_BASIC_MESSAGE_CHANNEL_H_ -#define FLUTTER_SHELL_PLATFORM_LINUX_FL_BASIC_MESSAGE_CHANNEL_H_ - -#if !defined(__FLUTTER_LINUX_INSIDE__) && !defined(FLUTTER_LINUX_COMPILATION) -#error "Only can be included directly." -#endif - -#include -#include - -#include "fl_binary_messenger.h" -#include "fl_message_codec.h" - -G_BEGIN_DECLS - -G_DECLARE_FINAL_TYPE(FlBasicMessageChannel, - fl_basic_message_channel, - FL, - BASIC_MESSAGE_CHANNEL, - GObject) - -G_DECLARE_FINAL_TYPE(FlBasicMessageChannelResponseHandle, - fl_basic_message_channel_response_handle, - FL, - BASIC_MESSAGE_CHANNEL_RESPONSE_HANDLE, - GObject) - -/** - * FlBasicMessageChannel: - * - * #FlBasicMessageChannel is an object that allows sending and receiving - * messages to/from Dart code over platform channels. - * - * The following example shows how to send messages on a channel: - * - * |[ - * static FlBasicMessageChannel *channel = NULL; - * - * static void message_cb (FlBasicMessageChannel* channel, - * FlValue* message, - * FlBasicMessageChannelResponseHandle* response_handle, - * gpointer user_data) { - * g_autoptr(FlValue) response = handle_message (message); - * g_autoptr(GError) error = NULL; - * if (!fl_basic_message_channel_respond (channel, response_handle, response, - * &error)) - * g_warning ("Failed to send channel response: %s", error->message); - * } - * - * static void message_response_cb (GObject *object, - * GAsyncResult *result, - * gpointer user_data) { - * g_autoptr(GError) error = NULL; - * g_autoptr(FlValue) response = - * fl_basic_message_channel_send_finish (FL_BASIC_MESSAGE_CHANNEL (object), - * result, &error); - * if (response == NULL) { - * g_warning ("Failed to send message: %s", error->message); - * return; - * } - * - * handle_response (response); - * } - * - * static void setup_channel () { - * g_autoptr(FlStandardMessageCodec) codec = fl_standard_message_codec_new (); - * channel = fl_basic_message_channel_new (messenger, "flutter/foo", - * FL_MESSAGE_CODEC (codec)); - * fl_basic_message_channel_set_message_handler (channel, message_cb, NULL, - * NULL); - * - * g_autoptr(FlValue) message = fl_value_new_string ("Hello World"); - * fl_basic_message_channel_send (channel, message, NULL, - * message_response_cb, NULL); - * } - * ]| - * - * #FlBasicMessageChannel matches the BasicMessageChannel class in the Flutter - * services library. - */ - -/** - * FlBasicMessageChannelResponseHandle: - * - * #FlBasicMessageChannelResponseHandle is an object used to send responses - * with. - */ - -/** - * FlBasicMessageChannelMessageHandler: - * @channel: an #FlBasicMessageChannel. - * @message: message received. - * @response_handle: a handle to respond to the message with. - * @user_data: (closure): data provided when registering this handler. - * - * Function called when a message is received. Call - * fl_basic_message_channel_respond() to respond to this message. If the - * response is not occurring in this callback take a reference to - * @response_handle and release that once it has been responded to. Failing to - * respond before the last reference to @response_handle is dropped is a - * programming error. - */ -typedef void (*FlBasicMessageChannelMessageHandler)( - FlBasicMessageChannel* channel, - FlValue* message, - FlBasicMessageChannelResponseHandle* response_handle, - gpointer user_data); - -/** - * fl_basic_message_channel_new: - * @messenger: an #FlBinaryMessenger. - * @name: a channel name. - * @codec: the message codec. - * - * Creates a basic message channel. @codec must match the codec used on the Dart - * end of the channel. - * - * Returns: a new #FlBasicMessageChannel. - */ -FlBasicMessageChannel* fl_basic_message_channel_new( - FlBinaryMessenger* messenger, - const gchar* name, - FlMessageCodec* codec); - -/** - * fl_basic_message_channel_set_message_handler: - * @channel: an #FlBasicMessageChannel. - * @handler: (allow-none): function to call when a message is received on this - * channel or %NULL to disable the handler. - * @user_data: (closure): user data to pass to @handler. - * @destroy_notify: (allow-none): a function which gets called to free - * @user_data, or %NULL. - * - * Sets the function called when a message is received from the Dart side of the - * channel. See #FlBasicMessageChannelMessageHandler for details on how to - * respond to messages. - * - * The handler is removed if the channel is closed or is replaced by another - * handler, set @destroy_notify if you want to detect this. - */ -void fl_basic_message_channel_set_message_handler( - FlBasicMessageChannel* channel, - FlBasicMessageChannelMessageHandler handler, - gpointer user_data, - GDestroyNotify destroy_notify); - -/** - * fl_basic_message_channel_respond: - * @channel: an #FlBasicMessageChannel. - * @response_handle: handle that was provided in a - * #FlBasicMessageChannelMessageHandler. - * @message: (allow-none): message response to send or %NULL for an empty - * response. - * @error: (allow-none): #GError location to store the error occurring, or %NULL - * to ignore. - * - * Responds to a message. - * - * Returns: %TRUE on success. - */ -gboolean fl_basic_message_channel_respond( - FlBasicMessageChannel* channel, - FlBasicMessageChannelResponseHandle* response_handle, - FlValue* message, - GError** error); - -/** - * fl_basic_message_channel_send: - * @channel: an #FlBasicMessageChannel. - * @message: message to send, must match what the #FlMessageCodec supports. - * @cancellable: (allow-none): a #GCancellable or %NULL. - * @callback: (scope async): (allow-none): a #GAsyncReadyCallback to call when - * the request is satisfied or %NULL to ignore the response. - * @user_data: (closure): user data to pass to @callback. - * - * Asynchronously sends a message. - */ -void fl_basic_message_channel_send(FlBasicMessageChannel* channel, - FlValue* message, - GCancellable* cancellable, - GAsyncReadyCallback callback, - gpointer user_data); - -/** - * fl_basic_message_channel_send_finish: - * @channel: an #FlBasicMessageChannel. - * @result: a #GAsyncResult. - * @error: (allow-none): #GError location to store the error occurring, or %NULL - * to ignore. - * - * Completes request started with fl_basic_message_channel_send(). - * - * Returns: message response on success or %NULL on error. - */ -FlValue* fl_basic_message_channel_send_finish(FlBasicMessageChannel* channel, - GAsyncResult* result, - GError** error); - -G_END_DECLS - -#endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_BASIC_MESSAGE_CHANNEL_H_ diff --git a/packages/fl_query_hooks/example/linux/flutter/ephemeral/flutter_linux/fl_binary_codec.h b/packages/fl_query_hooks/example/linux/flutter/ephemeral/flutter_linux/fl_binary_codec.h deleted file mode 100644 index e7223d8..0000000 --- a/packages/fl_query_hooks/example/linux/flutter/ephemeral/flutter_linux/fl_binary_codec.h +++ /dev/null @@ -1,45 +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. - -#ifndef FLUTTER_SHELL_PLATFORM_LINUX_FL_BINARY_CODEC_H_ -#define FLUTTER_SHELL_PLATFORM_LINUX_FL_BINARY_CODEC_H_ - -#if !defined(__FLUTTER_LINUX_INSIDE__) && !defined(FLUTTER_LINUX_COMPILATION) -#error "Only can be included directly." -#endif - -#include "fl_message_codec.h" - -G_BEGIN_DECLS - -G_DECLARE_FINAL_TYPE(FlBinaryCodec, - fl_binary_codec, - FL, - BINARY_CODEC, - FlMessageCodec) - -/** - * FlBinaryCodec: - * - * #FlBinaryCodec is an #FlMessageCodec that implements the Flutter binary - * message encoding. This only encodes and decodes #FlValue of type - * #FL_VALUE_TYPE_UINT8_LIST, other types #FlValues will generate an error - * during encoding. - * - * #FlBinaryCodec matches the BinaryCodec class in the Flutter services - * library. - */ - -/** - * fl_binary_codec_new: - * - * Creates an #FlBinaryCodec. - * - * Returns: a new #FlBinaryCodec. - */ -FlBinaryCodec* fl_binary_codec_new(); - -G_END_DECLS - -#endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_BINARY_CODEC_H_ diff --git a/packages/fl_query_hooks/example/linux/flutter/ephemeral/flutter_linux/fl_binary_messenger.h b/packages/fl_query_hooks/example/linux/flutter/ephemeral/flutter_linux/fl_binary_messenger.h deleted file mode 100644 index 84af654..0000000 --- a/packages/fl_query_hooks/example/linux/flutter/ephemeral/flutter_linux/fl_binary_messenger.h +++ /dev/null @@ -1,189 +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. - -#ifndef FLUTTER_SHELL_PLATFORM_LINUX_FL_BINARY_MESSENGER_H_ -#define FLUTTER_SHELL_PLATFORM_LINUX_FL_BINARY_MESSENGER_H_ - -#if !defined(__FLUTTER_LINUX_INSIDE__) && !defined(FLUTTER_LINUX_COMPILATION) -#error "Only can be included directly." -#endif - -#include -#include - -G_BEGIN_DECLS - -/** - * FlBinaryMessengerError: - * @FL_BINARY_MESSENGER_ERROR_ALREADY_RESPONDED: unable to send response, this - * message has already been responded to. - * - * Errors for #FlBinaryMessenger objects to set on failures. - */ -#define FL_BINARY_MESSENGER_ERROR fl_binary_messenger_codec_error_quark() - -typedef enum { - FL_BINARY_MESSENGER_ERROR_ALREADY_RESPONDED, -} FlBinaryMessengerError; - -GQuark fl_binary_messenger_codec_error_quark(void) G_GNUC_CONST; - -G_DECLARE_INTERFACE(FlBinaryMessenger, - fl_binary_messenger, - FL, - BINARY_MESSENGER, - GObject) - -G_DECLARE_DERIVABLE_TYPE(FlBinaryMessengerResponseHandle, - fl_binary_messenger_response_handle, - FL, - BINARY_MESSENGER_RESPONSE_HANDLE, - GObject) - -/** - * FlBinaryMessengerMessageHandler: - * @messenger: an #FlBinaryMessenger. - * @channel: channel message received on. - * @message: message content received from Dart. - * @response_handle: a handle to respond to the message with. - * @user_data: (closure): data provided when registering this handler. - * - * Function called when platform messages are received. Call - * fl_binary_messenger_send_response() to respond to this message. If the - * response is not occurring in this callback take a reference to - * @response_handle and release that once it has been responded to. Failing to - * respond before the last reference to @response_handle is dropped is a - * programming error. - */ -typedef void (*FlBinaryMessengerMessageHandler)( - FlBinaryMessenger* messenger, - const gchar* channel, - GBytes* message, - FlBinaryMessengerResponseHandle* response_handle, - gpointer user_data); - -struct _FlBinaryMessengerInterface { - GTypeInterface parent_iface; - - void (*set_message_handler_on_channel)( - FlBinaryMessenger* messenger, - const gchar* channel, - FlBinaryMessengerMessageHandler handler, - gpointer user_data, - GDestroyNotify destroy_notify); - - gboolean (*send_response)(FlBinaryMessenger* messenger, - FlBinaryMessengerResponseHandle* response_handle, - GBytes* response, - GError** error); - - void (*send_on_channel)(FlBinaryMessenger* messenger, - const gchar* channel, - GBytes* message, - GCancellable* cancellable, - GAsyncReadyCallback callback, - gpointer user_data); - - GBytes* (*send_on_channel_finish)(FlBinaryMessenger* messenger, - GAsyncResult* result, - GError** error); -}; - -struct _FlBinaryMessengerResponseHandleClass { - GObjectClass parent_class; -}; - -/** - * FlBinaryMessenger: - * - * #FlBinaryMessenger is an object that allows sending and receiving of platform - * messages with an #FlEngine. - */ - -/** - * FlBinaryMessengerResponseHandle: - * - * #FlBinaryMessengerResponseHandle is an object used to send responses with. - */ - -/** - * fl_binary_messenger_set_platform_message_handler: - * @binary_messenger: an #FlBinaryMessenger. - * @channel: channel to listen on. - * @handler: (allow-none): function to call when a message is received on this - * channel or %NULL to disable a handler - * @user_data: (closure): user data to pass to @handler. - * @destroy_notify: (allow-none): a function which gets called to free - * @user_data, or %NULL. - * - * Sets the function called when a platform message is received on the given - * channel. See #FlBinaryMessengerMessageHandler for details on how to respond - * to messages. - * - * The handler is removed if the channel is closed or is replaced by another - * handler, set @destroy_notify if you want to detect this. - */ -void fl_binary_messenger_set_message_handler_on_channel( - FlBinaryMessenger* messenger, - const gchar* channel, - FlBinaryMessengerMessageHandler handler, - gpointer user_data, - GDestroyNotify destroy_notify); - -/** - * fl_binary_messenger_send_response: - * @binary_messenger: an #FlBinaryMessenger. - * @response_handle: handle that was provided in a - * #FlBinaryMessengerMessageHandler. - * @response: (allow-none): response to send or %NULL for an empty response. - * @error: (allow-none): #GError location to store the error occurring, or %NULL - * to ignore. - * - * Responds to a platform message. - * - * Returns: %TRUE on success. - */ -gboolean fl_binary_messenger_send_response( - FlBinaryMessenger* messenger, - FlBinaryMessengerResponseHandle* response_handle, - GBytes* response, - GError** error); - -/** - * fl_binary_messenger_send_on_channel: - * @binary_messenger: an #FlBinaryMessenger. - * @channel: channel to send to. - * @message: (allow-none): message buffer to send or %NULL for an empty message. - * @cancellable: (allow-none): a #GCancellable or %NULL. - * @callback: (scope async): a #GAsyncReadyCallback to call when the request is - * satisfied. - * @user_data: (closure): user data to pass to @callback. - * - * Asynchronously sends a platform message. - */ -void fl_binary_messenger_send_on_channel(FlBinaryMessenger* messenger, - const gchar* channel, - GBytes* message, - GCancellable* cancellable, - GAsyncReadyCallback callback, - gpointer user_data); - -/** - * fl_binary_messenger_send_on_channel_finish: - * @binary_messenger: an #FlBinaryMessenger. - * @result: a #GAsyncResult. - * @error: (allow-none): #GError location to store the error occurring, or %NULL - * to ignore. - * - * Completes request started with fl_binary_messenger_send_on_channel(). - * - * Returns: (transfer full): message response on success or %NULL on error. - */ -GBytes* fl_binary_messenger_send_on_channel_finish(FlBinaryMessenger* messenger, - GAsyncResult* result, - GError** error); - -G_END_DECLS - -#endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_BINARY_MESSENGER_H_ diff --git a/packages/fl_query_hooks/example/linux/flutter/ephemeral/flutter_linux/fl_dart_project.h b/packages/fl_query_hooks/example/linux/flutter/ephemeral/flutter_linux/fl_dart_project.h deleted file mode 100644 index 1b56e24..0000000 --- a/packages/fl_query_hooks/example/linux/flutter/ephemeral/flutter_linux/fl_dart_project.h +++ /dev/null @@ -1,125 +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. - -#ifndef FLUTTER_SHELL_PLATFORM_LINUX_FL_DART_PROJECT_H_ -#define FLUTTER_SHELL_PLATFORM_LINUX_FL_DART_PROJECT_H_ - -#include - -#if !defined(__FLUTTER_LINUX_INSIDE__) && !defined(FLUTTER_LINUX_COMPILATION) -#error "Only can be included directly." -#endif - -G_BEGIN_DECLS - -G_DECLARE_FINAL_TYPE(FlDartProject, fl_dart_project, FL, DART_PROJECT, GObject) - -/** - * FlDartProject: - * - * #FlDartProject represents a Dart project. It is used to provide information - * about the application when creating an #FlView. - */ - -/** - * fl_dart_project_new: - * - * Creates a Flutter project for the currently running executable. The following - * data files are required relative to the location of the executable: - * - data/flutter_assets/ (as built by the Flutter tool). - * - data/icudtl.dat (provided as a resource by the Flutter tool). - * - lib/libapp.so (as built by the Flutter tool when in AOT mode). - * - * Returns: a new #FlDartProject. - */ -FlDartProject* fl_dart_project_new(); - -/** - * fl_dart_project_set_enable_mirrors: - * @project: an #FlDartProject. - * @enable_mirrors: %TRUE if the dart:mirrors library should be used. - * - * Sets if this Flutter project can use the dart:mirrors library. - * - * Deprecated: This function is temporary and will be removed in a future - * release. - */ -void fl_dart_project_set_enable_mirrors(FlDartProject* project, - gboolean enable_mirrors) G_DEPRECATED; - -/** - * fl_dart_project_get_enable_mirrors: - * @project: an #FlDartProject. - * - * Gets if this Flutter project can use the dart:mirrors library. - * - * Returns: %TRUE if the dart:mirrors library can be used. - * - * Deprecated: This function is temporary and will be removed in a future - * release. - */ -gboolean fl_dart_project_get_enable_mirrors(FlDartProject* project) - G_DEPRECATED; - -/** - * fl_dart_project_get_aot_library_path: - * @project: an #FlDartProject. - * - * Gets the path to the AOT library in the Flutter application. - * - * Returns: (type filename): an absolute file path, e.g. - * "/projects/my_dart_project/lib/libapp.so". - */ -const gchar* fl_dart_project_get_aot_library_path(FlDartProject* project); - -/** - * fl_dart_project_get_assets_path: - * @project: an #FlDartProject. - * - * Gets the path to the directory containing the assets used in the Flutter - * application. - * - * Returns: (type filename): an absolute directory path, e.g. - * "/projects/my_dart_project/data/flutter_assets". - */ -const gchar* fl_dart_project_get_assets_path(FlDartProject* project); - -/** - * fl_dart_project_get_icu_data_path: - * @project: an #FlDartProject. - * - * Gets the path to the ICU data file in the Flutter application. - * - * Returns: (type filename): an absolute file path, e.g. - * "/projects/my_dart_project/data/icudtl.dat". - */ -const gchar* fl_dart_project_get_icu_data_path(FlDartProject* project); - -/** - * fl_dart_project_set_dart_entrypoint_arguments: - * @project: an #FlDartProject. - * @argv: a pointer to a NULL-terminated array of C strings containing the - * command line arguments. - * - * Sets the command line arguments to be passed through to the Dart - * entrypoint function. - */ -void fl_dart_project_set_dart_entrypoint_arguments(FlDartProject* project, - char** argv); - -/** - * fl_dart_project_get_dart_entrypoint_arguments: - * @project: an #FlDartProject. - * - * Gets the command line arguments to be passed through to the Dart entrypoint - * function. - * - * Returns: a NULL-terminated array of strings containing the command line - * arguments to be passed to the Dart entrypoint. - */ -gchar** fl_dart_project_get_dart_entrypoint_arguments(FlDartProject* project); - -G_END_DECLS - -#endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_DART_PROJECT_H_ diff --git a/packages/fl_query_hooks/example/linux/flutter/ephemeral/flutter_linux/fl_engine.h b/packages/fl_query_hooks/example/linux/flutter/ephemeral/flutter_linux/fl_engine.h deleted file mode 100644 index 6740c0b..0000000 --- a/packages/fl_query_hooks/example/linux/flutter/ephemeral/flutter_linux/fl_engine.h +++ /dev/null @@ -1,60 +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. - -#ifndef FLUTTER_SHELL_PLATFORM_LINUX_FL_ENGINE_H_ -#define FLUTTER_SHELL_PLATFORM_LINUX_FL_ENGINE_H_ - -#if !defined(__FLUTTER_LINUX_INSIDE__) && !defined(FLUTTER_LINUX_COMPILATION) -#error "Only can be included directly." -#endif - -#include - -#include "fl_binary_messenger.h" -#include "fl_dart_project.h" -#include "fl_texture_registrar.h" - -G_BEGIN_DECLS - -G_DECLARE_FINAL_TYPE(FlEngine, fl_engine, FL, ENGINE, GObject) - -/** - * FlEngine: - * - * #FlEngine is an object that contains a running Flutter engine. - */ - -/** - * fl_engine_new_headless: - * @project: an #FlDartProject. - * - * Creates new Flutter engine running in headless mode. - * - * Returns: a new #FlEngine. - */ -FlEngine* fl_engine_new_headless(FlDartProject* project); - -/** - * fl_engine_get_binary_messenger: - * @engine: an #FlEngine. - * - * Gets the messenger to communicate with this engine. - * - * Returns: an #FlBinaryMessenger. - */ -FlBinaryMessenger* fl_engine_get_binary_messenger(FlEngine* engine); - -/** - * fl_engine_get_texture_registrar: - * @engine: an #FlEngine. - * - * Gets the texture registrar for registering textures. - * - * Returns: an #FlTextureRegistrar. - */ -FlTextureRegistrar* fl_engine_get_texture_registrar(FlEngine* engine); - -G_END_DECLS - -#endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_ENGINE_H_ diff --git a/packages/fl_query_hooks/example/linux/flutter/ephemeral/flutter_linux/fl_event_channel.h b/packages/fl_query_hooks/example/linux/flutter/ephemeral/flutter_linux/fl_event_channel.h deleted file mode 100644 index 7141def..0000000 --- a/packages/fl_query_hooks/example/linux/flutter/ephemeral/flutter_linux/fl_event_channel.h +++ /dev/null @@ -1,187 +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. - -#ifndef FLUTTER_SHELL_PLATFORM_LINUX_FL_EVENT_CHANNEL_H_ -#define FLUTTER_SHELL_PLATFORM_LINUX_FL_EVENT_CHANNEL_H_ - -#if !defined(__FLUTTER_LINUX_INSIDE__) && !defined(FLUTTER_LINUX_COMPILATION) -#error "Only can be included directly." -#endif - -#include -#include - -#include "fl_binary_messenger.h" -#include "fl_method_channel.h" -#include "fl_method_response.h" - -G_BEGIN_DECLS - -G_DECLARE_FINAL_TYPE(FlEventChannel, - fl_event_channel, - FL, - EVENT_CHANNEL, - GObject) - -/** - * FlEventChannel: - * - * #FlEventChannel is an object that allows sending - * an events stream to Dart code over platform channels. - * - * The following example shows how to send events on a channel: - * - * |[ - * static FlEventChannel *channel = NULL; - * static gboolean send_events = FALSE; - * - * static void event_occurs_cb (FooEvent *event) { - * if (send_events) { - * g_autoptr(FlValue) message = foo_event_to_value (event); - * g_autoptr(GError) error = NULL; - * if (!fl_event_channel_send (channel, message, NULL, &error)) { - * g_warning ("Failed to send event: %s", error->message); - * } - * } - * } - * - * static FlMethodErrorResponse* listen_cb (FlEventChannel* channel, - * FlValue *args, - * gpointer user_data) { - * send_events = TRUE; - * return NULL; - * } - * - * static FlMethodErrorResponse* cancel_cb (GObject *object, - * FlValue *args, - * gpointer user_data) { - * send_events = FALSE; - * return NULL; - * } - * - * static void setup_channel () { - * g_autoptr(FlStandardMethodCodec) codec = fl_standard_method_codec_new (); - * channel = fl_event_channel_new (messenger, "flutter/foo", - * FL_METHOD_CODEC (codec)); - * fl_event_channel_set_stream_handlers (channel, listen_cb, cancel_cb, - * NULL, NULL); - * } - * ]| - * - * #FlEventChannel matches the EventChannel class in the Flutter - * services library. - */ - -/** - * FlEventChannelHandler: - * @channel: an #FlEventChannel. - * @args: arguments passed from the Dart end of the channel. - * @user_data: (closure): data provided when registering this handler. - * - * Function called when the stream is listened to or cancelled. - * - * Returns: (transfer full): an #FlMethodErrorResponse or %NULL if no error. - */ -typedef FlMethodErrorResponse* (*FlEventChannelHandler)(FlEventChannel* channel, - FlValue* args, - gpointer user_data); - -/** - * fl_event_channel_new: - * @messenger: an #FlBinaryMessenger. - * @name: a channel name. - * @codec: the message codec. - * - * Creates an event channel. @codec must match the codec used on the Dart - * end of the channel. - * - * Returns: a new #FlEventChannel. - */ -FlEventChannel* fl_event_channel_new(FlBinaryMessenger* messenger, - const gchar* name, - FlMethodCodec* codec); - -/** - * fl_event_channel_set_stream_handlers: - * @channel: an #FlEventChannel. - * @listen_handler: (allow-none): function to call when the Dart side of the - * channel starts listening to the stream. - * @cancel_handler: (allow-none): function to call when the Dart side of the - * channel cancels their subscription to the stream. - * @user_data: (closure): user data to pass to @listen_handler and - * @cancel_handler. - * @destroy_notify: (allow-none): a function which gets called to free - * @user_data, or %NULL. - * - * Sets the functions called when the Dart side requests the stream to start and - * finish. - * - * The handlers are removed if the channel is closed or is replaced by another - * handler, set @destroy_notify if you want to detect this. - */ -void fl_event_channel_set_stream_handlers(FlEventChannel* channel, - FlEventChannelHandler listen_handler, - FlEventChannelHandler cancel_handler, - gpointer user_data, - GDestroyNotify destroy_notify); - -/** - * fl_event_channel_send: - * @channel: an #FlEventChannel. - * @event: event to send, must match what the #FlMethodCodec supports. - * @cancellable: (allow-none): a #GCancellable or %NULL. - * @error: (allow-none): #GError location to store the error occurring, or %NULL - * to ignore. - * - * Sends an event on the channel. - * Events should only be sent once the channel is being listened to. - * - * Returns: %TRUE if successful. - */ -gboolean fl_event_channel_send(FlEventChannel* channel, - FlValue* event, - GCancellable* cancellable, - GError** error); - -/** - * fl_event_channel_send_error: - * @channel: an #FlEventChannel. - * @code: error code to send. - * @message: error message to send. - * @details: (allow-none): error details or %NULL. - * @cancellable: (allow-none): a #GCancellable or %NULL. - * @error: (allow-none): #GError location to store the error occurring, or %NULL - * to ignore. - * - * Sends an error on the channel. - * Errors should only be sent once the channel is being listened to. - * - * Returns: %TRUE if successful. - */ -gboolean fl_event_channel_send_error(FlEventChannel* channel, - const gchar* code, - const gchar* message, - FlValue* details, - GCancellable* cancellable, - GError** error); - -/** - * fl_event_channel_send_end_of_stream: - * @channel: an #FlEventChannel. - * @cancellable: (allow-none): a #GCancellable or %NULL. - * @error: (allow-none): #GError location to store the error occurring, or %NULL - * to ignore. - * - * Indicates the stream has completed. - * It is a programmer error to send any more events after calling this. - * - * Returns: %TRUE if successful. - */ -gboolean fl_event_channel_send_end_of_stream(FlEventChannel* channel, - GCancellable* cancellable, - GError** error); - -G_END_DECLS - -#endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_EVENT_CHANNEL_H_ diff --git a/packages/fl_query_hooks/example/linux/flutter/ephemeral/flutter_linux/fl_json_message_codec.h b/packages/fl_query_hooks/example/linux/flutter/ephemeral/flutter_linux/fl_json_message_codec.h deleted file mode 100644 index ddf6818..0000000 --- a/packages/fl_query_hooks/example/linux/flutter/ephemeral/flutter_linux/fl_json_message_codec.h +++ /dev/null @@ -1,96 +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. - -#ifndef FLUTTER_SHELL_PLATFORM_LINUX_FL_JSON_MESSAGE_CODEC_H_ -#define FLUTTER_SHELL_PLATFORM_LINUX_FL_JSON_MESSAGE_CODEC_H_ - -#if !defined(__FLUTTER_LINUX_INSIDE__) && !defined(FLUTTER_LINUX_COMPILATION) -#error "Only can be included directly." -#endif - -#include "fl_message_codec.h" - -G_BEGIN_DECLS - -/** - * FlJsonMessageCodecError: - * @FL_JSON_MESSAGE_CODEC_ERROR_INVALID_UTF8: Message is not valid UTF-8. - * @FL_JSON_MESSAGE_CODEC_ERROR_INVALID_JSON: Message is not valid JSON. - * @FL_JSON_MESSAGE_CODEC_ERROR_INVALID_OBJECT_KEY_TYPE: Invalid object key - * type. - * - * Errors for #FlJsonMessageCodec objects to set on failures. - */ -#define FL_JSON_MESSAGE_CODEC_ERROR fl_json_message_codec_error_quark() - -typedef enum { - FL_JSON_MESSAGE_CODEC_ERROR_INVALID_UTF8, - FL_JSON_MESSAGE_CODEC_ERROR_INVALID_JSON, - FL_JSON_MESSAGE_CODEC_ERROR_INVALID_OBJECT_KEY_TYPE, -} FlJsonMessageCodecError; - -GQuark fl_json_message_codec_error_quark(void) G_GNUC_CONST; - -G_DECLARE_FINAL_TYPE(FlJsonMessageCodec, - fl_json_message_codec, - FL, - JSON_CODEC, - FlMessageCodec) - -/** - * FlJsonMessageCodec: - * - * #FlJsonMessageCodec is an #FlMessageCodec that implements the encodes - * #FlValue to/from JSON. This codec encodes and decodes #FlValue of type - * #FL_VALUE_TYPE_NULL, #FL_VALUE_TYPE_BOOL, #FL_VALUE_TYPE_INT, - * #FL_VALUE_TYPE_FLOAT, #FL_VALUE_TYPE_STRING, #FL_VALUE_TYPE_UINT8_LIST, - * #FL_VALUE_TYPE_INT32_LIST, #FL_VALUE_TYPE_INT64_LIST, - * #FL_VALUE_TYPE_FLOAT_LIST, #FL_VALUE_TYPE_LIST, and #FL_VALUE_TYPE_MAP. - * - * #FlJsonMessageCodec matches the JSONMessageCodec class in the Flutter - * services library. - */ - -/** - * fl_json_message_codec_new: - * - * Creates an #FlJsonMessageCodec. - * - * Returns: a new #FlJsonMessageCodec. - */ -FlJsonMessageCodec* fl_json_message_codec_new(); - -/** - * fl_json_message_codec_encode: - * @codec: an #FlJsonMessageCodec. - * @value: value to encode. - * @error: (allow-none): #GError location to store the error occurring, or - * %NULL. - * - * Encodes a value to a JSON string. - * - * Returns: a JSON representation of this value or %NULL on error. - */ -gchar* fl_json_message_codec_encode(FlJsonMessageCodec* codec, - FlValue* value, - GError** error); - -/** - * fl_json_message_codec_decode: - * @codec: an #FlJsonMessageCodec. - * @text: UTF-8 text in JSON format. - * @error: (allow-none): #GError location to store the error occurring, or - * %NULL. - * - * Decodes a value from a JSON string. - * - * Returns: an #FlValue or %NULL on error. - */ -FlValue* fl_json_message_codec_decode(FlJsonMessageCodec* codec, - const gchar* text, - GError** error); - -G_END_DECLS - -#endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_JSON_MESSAGE_CODEC_H_ diff --git a/packages/fl_query_hooks/example/linux/flutter/ephemeral/flutter_linux/fl_json_method_codec.h b/packages/fl_query_hooks/example/linux/flutter/ephemeral/flutter_linux/fl_json_method_codec.h deleted file mode 100644 index 70ddf79..0000000 --- a/packages/fl_query_hooks/example/linux/flutter/ephemeral/flutter_linux/fl_json_method_codec.h +++ /dev/null @@ -1,44 +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. - -#ifndef FLUTTER_SHELL_PLATFORM_LINUX_FL_JSON_METHOD_CODEC_H_ -#define FLUTTER_SHELL_PLATFORM_LINUX_FL_JSON_METHOD_CODEC_H_ - -#if !defined(__FLUTTER_LINUX_INSIDE__) && !defined(FLUTTER_LINUX_COMPILATION) -#error "Only can be included directly." -#endif - -#include "fl_method_codec.h" - -G_BEGIN_DECLS - -G_DECLARE_FINAL_TYPE(FlJsonMethodCodec, - fl_json_method_codec, - FL, - JSON_METHOD_CODEC, - FlMethodCodec) - -/** - * FlJsonMethodCodec: - * - * #FlJsonMessageCodec is an #FlMethodCodec that implements method calls using - * the Flutter JSON message encoding. It should be used with an - * #FlMethodChannel. - * - * #FlJsonMethodCodec matches the JSONMethodCodec class in the Flutter services - * library. - */ - -/** - * fl_json_method_codec_new: - * - * Creates an #FlJsonMethodCodec. - * - * Returns: a new #FlJsonMethodCodec. - */ -FlJsonMethodCodec* fl_json_method_codec_new(); - -G_END_DECLS - -#endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_JSON_METHOD_CODEC_H_ diff --git a/packages/fl_query_hooks/example/linux/flutter/ephemeral/flutter_linux/fl_message_codec.h b/packages/fl_query_hooks/example/linux/flutter/ephemeral/flutter_linux/fl_message_codec.h deleted file mode 100644 index b74aad2..0000000 --- a/packages/fl_query_hooks/example/linux/flutter/ephemeral/flutter_linux/fl_message_codec.h +++ /dev/null @@ -1,129 +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. - -#ifndef FLUTTER_SHELL_PLATFORM_LINUX_FL_MESSAGE_CODEC_H_ -#define FLUTTER_SHELL_PLATFORM_LINUX_FL_MESSAGE_CODEC_H_ - -#if !defined(__FLUTTER_LINUX_INSIDE__) && !defined(FLUTTER_LINUX_COMPILATION) -#error "Only can be included directly." -#endif - -#include - -#include "fl_value.h" - -G_BEGIN_DECLS - -/** - * FlMessageCodecError: - * @FL_MESSAGE_CODEC_ERROR_FAILED: Codec failed due to an unspecified error. - * @FL_MESSAGE_CODEC_ERROR_OUT_OF_DATA: Codec ran out of data reading a value. - * @FL_MESSAGE_CODEC_ERROR_ADDITIONAL_DATA: Additional data encountered in - * message. - * @FL_MESSAGE_CODEC_ERROR_UNSUPPORTED_TYPE: Codec encountered an unsupported - * #FlValue. - * - * Errors for #FlMessageCodec objects to set on failures. - */ -#define FL_MESSAGE_CODEC_ERROR fl_message_codec_error_quark() - -typedef enum { - FL_MESSAGE_CODEC_ERROR_FAILED, - FL_MESSAGE_CODEC_ERROR_OUT_OF_DATA, - FL_MESSAGE_CODEC_ERROR_ADDITIONAL_DATA, - FL_MESSAGE_CODEC_ERROR_UNSUPPORTED_TYPE, -} FlMessageCodecError; - -GQuark fl_message_codec_error_quark(void) G_GNUC_CONST; - -G_DECLARE_DERIVABLE_TYPE(FlMessageCodec, - fl_message_codec, - FL, - MESSAGE_CODEC, - GObject) - -/** - * FlMessageCodec: - * - * #FlMessageCodec is a message encoding/decoding mechanism that operates on - * #FlValue objects. Both operations returns errors if the conversion fails. - * Such situations should be treated as programming errors. - * - * #FlMessageCodec matches the MethodCodec class in the Flutter services - * library. - */ - -struct _FlMessageCodecClass { - GObjectClass parent_class; - - /** - * FlMessageCodec::encode_message: - * @codec: A #FlMessageCodec. - * @message: message to encode or %NULL to encode the null value. - * @error: (allow-none): #GError location to store the error occurring, or - * %NULL. - * - * Virtual method to encode a message. A subclass must implement this method. - * If the subclass cannot handle the type of @message then it must generate a - * FL_MESSAGE_CODEC_ERROR_UNSUPPORTED_TYPE error. - * - * Returns: a binary message or %NULL on error. - */ - GBytes* (*encode_message)(FlMessageCodec* codec, - FlValue* message, - GError** error); - - /** - * FlMessageCodec::decode_message: - * @codec: an #FlMessageCodec. - * @message: binary message to decode. - * @error: (allow-none): #GError location to store the error occurring, or - * %NULL. - * - * Virtual method to decode a message. A subclass must implement this method. - * If @message is too small then a #FL_MESSAGE_CODEC_ERROR_OUT_OF_DATA error - * must be generated. If @message is too large then a - * #FL_MESSAGE_CODEC_ERROR_ADDITIONAL_DATA error must be generated. - * - * Returns: an #FlValue or %NULL on error. - */ - FlValue* (*decode_message)(FlMessageCodec* codec, - GBytes* message, - GError** error); -}; - -/** - * fl_message_codec_encode_message: - * @codec: an #FlMessageCodec. - * @buffer: buffer to write to. - * @message: message to encode or %NULL to encode the null value. - * @error: (allow-none): #GError location to store the error occurring, or - * %NULL. - * - * Encodes a message into a binary representation. - * - * Returns: a binary encoded message or %NULL on error. - */ -GBytes* fl_message_codec_encode_message(FlMessageCodec* codec, - FlValue* message, - GError** error); - -/** - * fl_message_codec_decode_message: - * @codec: an #FlMessageCodec. - * @message: binary message to decode. - * @error: (allow-none): #GError location to store the error occurring, or - * %NULL. - * - * Decodes a message from a binary encoding. - * - * Returns: an #FlValue or %NULL on error. - */ -FlValue* fl_message_codec_decode_message(FlMessageCodec* codec, - GBytes* message, - GError** error); - -G_END_DECLS - -#endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_MESSAGE_CODEC_H_ diff --git a/packages/fl_query_hooks/example/linux/flutter/ephemeral/flutter_linux/fl_method_call.h b/packages/fl_query_hooks/example/linux/flutter/ephemeral/flutter_linux/fl_method_call.h deleted file mode 100644 index 5a5ebc7..0000000 --- a/packages/fl_query_hooks/example/linux/flutter/ephemeral/flutter_linux/fl_method_call.h +++ /dev/null @@ -1,115 +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. - -#ifndef FLUTTER_SHELL_PLATFORM_LINUX_FL_METHOD_CALL_H_ -#define FLUTTER_SHELL_PLATFORM_LINUX_FL_METHOD_CALL_H_ - -#if !defined(__FLUTTER_LINUX_INSIDE__) && !defined(FLUTTER_LINUX_COMPILATION) -#error "Only can be included directly." -#endif - -#include - -#include "fl_method_response.h" -#include "fl_value.h" - -G_BEGIN_DECLS - -G_DECLARE_FINAL_TYPE(FlMethodCall, fl_method_call, FL, METHOD_CALL, GObject) - -/** - * FlMethodCall: - * - * #FlMethodCall represents and incoming method call as returned by an - * #FlMethodChannel. - */ - -/** - * fl_method_call_get_name: - * @method_call: an #FlMethodCall. - * - * Gets the name of the method call. - * - * Returns: a method name. - */ -const gchar* fl_method_call_get_name(FlMethodCall* method_call); - -/** - * fl_method_call_get_args: - * @method_call: an #FlMethodCall. - * - * Gets the arguments passed to the method. - * - * Returns: an #FlValue. - */ -FlValue* fl_method_call_get_args(FlMethodCall* method_call); - -/** - * fl_method_call_respond: - * @method_call: an #FlMethodCall. - * @response: an #FlMethodResponse. - * @error: (allow-none): #GError location to store the error occurring, or %NULL - * to ignore. - * - * Responds to a method call. - * - * Returns: %TRUE on success. - */ -gboolean fl_method_call_respond(FlMethodCall* method_call, - FlMethodResponse* response, - GError** error); - -/** - * fl_method_call_respond_success: - * @method_call: an #FlMethodCall. - * @result: (allow-none): value to respond with, must match what the - * #FlMethodCodec supports. - * @error: (allow-none): #GError location to store the error occurring, or %NULL - * to ignore. - * - * Convenience method that responds to method call with - * #FlMethodSuccessResponse. - * - * Returns: %TRUE on success. - */ -gboolean fl_method_call_respond_success(FlMethodCall* method_call, - FlValue* result, - GError** error); - -/** - * fl_method_call_respond_error: - * @method_call: an #FlMethodCall. - * @code: error code. - * @message: (allow-none): error message. - * @details: (allow-none): details for the error. - * @error: (allow-none): #GError location to store the error occurring, or %NULL - * to ignore. - * - * Convenience method that responds to method call with #FlMethodErrorResponse. - * - * Returns: %TRUE on success. - */ -gboolean fl_method_call_respond_error(FlMethodCall* method_call, - const gchar* code, - const gchar* message, - FlValue* details, - GError** error); - -/** - * fl_method_call_respond_not_implemented: - * @method_call: an #FlMethodCall. - * @error: (allow-none): #GError location to store the error occurring, or %NULL - * to ignore. - * - * Convenience method that responds to method call with - * #FlMethodNotImplementedResponse. - * - * Returns: %TRUE on success. - */ -gboolean fl_method_call_respond_not_implemented(FlMethodCall* method_call, - GError** error); - -G_END_DECLS - -#endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_METHOD_CALL_H_ diff --git a/packages/fl_query_hooks/example/linux/flutter/ephemeral/flutter_linux/fl_method_channel.h b/packages/fl_query_hooks/example/linux/flutter/ephemeral/flutter_linux/fl_method_channel.h deleted file mode 100644 index f4102ed..0000000 --- a/packages/fl_query_hooks/example/linux/flutter/ephemeral/flutter_linux/fl_method_channel.h +++ /dev/null @@ -1,190 +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. - -#ifndef FLUTTER_SHELL_PLATFORM_LINUX_FL_METHOD_CHANNEL_H_ -#define FLUTTER_SHELL_PLATFORM_LINUX_FL_METHOD_CHANNEL_H_ - -#if !defined(__FLUTTER_LINUX_INSIDE__) && !defined(FLUTTER_LINUX_COMPILATION) -#error "Only can be included directly." -#endif - -#include -#include - -#include "fl_binary_messenger.h" -#include "fl_method_call.h" -#include "fl_method_codec.h" -#include "fl_method_response.h" - -G_BEGIN_DECLS - -G_DECLARE_FINAL_TYPE(FlMethodChannel, - fl_method_channel, - FL, - METHOD_CHANNEL, - GObject) - -/** - * FlMethodChannel: - * - * #FlMethodChannel is an object that allows method calls to and from Dart code. - * - * The following example shows how to call and handle methods on a channel. - * See #FlMethodResponse for how to handle errors in more detail. - * - * |[ - * static FlMethodChannel *channel = NULL; - * - * static void method_call_cb (FlMethodChannel* channel, - * FlMethodCall* method_call, - * gpointer user_data) { - * g_autoptr(FlMethodResponse) response = NULL; - * if (strcmp (fl_method_call_get_name (method_call), "Foo.bar") == 0) { - * g_autoptr(GError) bar_error = NULL; - * g_autoptr(FlValue) result = - * do_bar (fl_method_call_get_args (method_call), &bar_error); - * if (result == NULL) - * response = - * FL_METHOD_RESPONSE (fl_method_error_response_new ("bar error", - * bar_error->message)); - * else - * response = FL_METHOD_RESPONSE (fl_method_success_response_new - * (result)); } else response = FL_METHOD_RESPONSE - * (fl_method_not_implemented_response_new ()); - * - * g_autoptr(GError) error = NULL; - * if (!fl_method_call_respond(method_call, response)) - * g_warning ("Failed to send response: %s", error->message); - * } - * - * static void method_response_cb(GObject *object, - * GAsyncResult *result, - * gpointer user_data) { - * g_autoptr(GError) error = NULL; - * g_autoptr(FlMethodResponse) response = - * fl_method_channel_invoke_method_finish (FL_METHOD_CODEC (object), result, - * &error); - * if (response == NULL) { - * g_warning ("Failed to call method: %s", error->message); - * return; - * } - * - * g_autoptr(FlValue) value = - * fl_method_response_get_result (response, &error); - * if (response == NULL) { - * g_warning ("Method returned error: %s", error->message); - * return; - * } - * - * use_result (value); - * } - * - * static void call_method () { - * g_autoptr(FlStandardMethodCodec) codec = fl_standard_method_codec_new (); - * channel = - * fl_method_channel_new(messenger, "flutter/foo", FL_METHOD_CODEC (codec)); - * fl_method_channel_set_method_call_handler (channel, method_call_cb, NULL, - * NULL); - * - * g_autoptr(FlValue) args = fl_value_new_string ("Hello World"); - * fl_method_channel_invoke_method (channel, "Foo.foo", args, - * cancellable, method_response_cb, NULL); - * } - * ]| - * - * #FlMethodChannel matches the MethodChannel class in the Flutter services - * library. - */ - -/** - * FlMethodChannelMethodCallHandler: - * @channel: an #FlMethodChannel. - * @method_call: an #FlMethodCall. - * @user_data: (closure): data provided when registering this handler. - * - * Function called when a method call is received. Respond to the method call - * with fl_method_call_respond(). If the response is not occurring in this - * callback take a reference to @method_call and release that once it has been - * responded to. Failing to respond before the last reference to @method_call is - * dropped is a programming error. - */ -typedef void (*FlMethodChannelMethodCallHandler)(FlMethodChannel* channel, - FlMethodCall* method_call, - gpointer user_data); - -/** - * fl_method_channel_new: - * @messenger: an #FlBinaryMessenger. - * @name: a channel name. - * @codec: the method codec. - * - * Creates a new method channel. @codec must match the codec used on the Dart - * end of the channel. - * - * Returns: a new #FlMethodChannel. - */ -FlMethodChannel* fl_method_channel_new(FlBinaryMessenger* messenger, - const gchar* name, - FlMethodCodec* codec); - -/** - * fl_method_channel_set_method_call_handler: - * @channel: an #FlMethodChannel. - * @handler: function to call when a method call is received on this channel. - * @user_data: (closure): user data to pass to @handler. - * @destroy_notify: (allow-none): a function which gets called to free - * @user_data, or %NULL. - * - * Sets the function called when a method call is received from the Dart side of - * the channel. See #FlMethodChannelMethodCallHandler for details on how to - * respond to method calls. - * - * The handler is removed if the channel is closed or is replaced by another - * handler, set @destroy_notify if you want to detect this. - */ -void fl_method_channel_set_method_call_handler( - FlMethodChannel* channel, - FlMethodChannelMethodCallHandler handler, - gpointer user_data, - GDestroyNotify destroy_notify); - -/** - * fl_method_channel_invoke_method: - * @channel: an #FlMethodChannel. - * @method: the method to call. - * @args: (allow-none): arguments to the method, must match what the - * #FlMethodCodec supports. - * @cancellable: (allow-none): a #GCancellable or %NULL. - * @callback: (scope async): (allow-none): a #GAsyncReadyCallback to call when - * the request is satisfied or %NULL to ignore the response. - * @user_data: (closure): user data to pass to @callback. - * - * Calls a method on this channel. - */ -void fl_method_channel_invoke_method(FlMethodChannel* channel, - const gchar* method, - FlValue* args, - GCancellable* cancellable, - GAsyncReadyCallback callback, - gpointer user_data); - -/** - * fl_method_channel_invoke_method_finish: - * @channel: an #FlMethodChannel. - * @result: #GAsyncResult. - * @error: (allow-none): #GError location to store the error occurring, or %NULL - * to ignore. - * - * Completes request started with fl_method_channel_invoke_method(). - * - * Returns: (transfer full): an #FlMethodResponse or %NULL on error. - */ -FlMethodResponse* fl_method_channel_invoke_method_finish( - FlMethodChannel* channel, - GAsyncResult* result, - GError** error); - -G_END_DECLS - -#endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_METHOD_CHANNEL_H_ diff --git a/packages/fl_query_hooks/example/linux/flutter/ephemeral/flutter_linux/fl_method_codec.h b/packages/fl_query_hooks/example/linux/flutter/ephemeral/flutter_linux/fl_method_codec.h deleted file mode 100644 index 97bf8e9..0000000 --- a/packages/fl_query_hooks/example/linux/flutter/ephemeral/flutter_linux/fl_method_codec.h +++ /dev/null @@ -1,131 +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. - -#ifndef FLUTTER_SHELL_PLATFORM_LINUX_FL_METHOD_CODEC_H_ -#define FLUTTER_SHELL_PLATFORM_LINUX_FL_METHOD_CODEC_H_ - -#if !defined(__FLUTTER_LINUX_INSIDE__) && !defined(FLUTTER_LINUX_COMPILATION) -#error "Only can be included directly." -#endif - -#include - -#include "fl_method_response.h" -#include "fl_value.h" - -G_BEGIN_DECLS - -G_DECLARE_DERIVABLE_TYPE(FlMethodCodec, - fl_method_codec, - FL, - METHOD_CODEC, - GObject) - -/** - * FlMethodCodec: - * - * #FlMethodCodec is an abstract class that encodes and decodes method calls on - * a platform channel. Override this class to implement an encoding. - * - * #FlMethodCodec matches the MethodCodec class in the Flutter services - * library. - */ - -struct _FlMethodCodecClass { - GObjectClass parent_class; - - /** - * FlMethodCodec::encode_method_call: - * @codec: an #FlMethodCodec. - * @name: method name. - * @args: (allow-none): method arguments, or %NULL. - * @error: (allow-none): #GError location to store the error occurring, or - * %NULL. - * - * Encodes a method call. - * - * Returns: (transfer full): a binary encoding of this method call or %NULL if - * not able to encode. - */ - GBytes* (*encode_method_call)(FlMethodCodec* codec, - const gchar* name, - FlValue* args, - GError** error); - - /** - * FlMethodCodec::decode_method_call: - * @codec: an #FlMethodCodec - * @message: message to decode. - * @name: (transfer full): location to write method name or %NULL if not - * required - * @args: (transfer full): location to write method arguments, or %NULL if not - * required - * @error: (allow-none): #GError location to store the error occurring, or - * %NULL - * - * Decodes a method call. - * - * Returns: %TRUE if successfully decoded. - */ - gboolean (*decode_method_call)(FlMethodCodec* codec, - GBytes* message, - gchar** name, - FlValue** args, - GError** error); - - /** - * FlMethodCodec::encode_success_envelope: - * @codec: an #FlMethodCodec. - * @result: (allow-none): method result, or %NULL. - * @error: (allow-none): #GError location to store the error occurring, or - * %NULL. - * - * Encodes a successful response to a method call. - * - * Returns: (transfer full): a binary encoding of this response or %NULL if - * not able to encode. - */ - GBytes* (*encode_success_envelope)(FlMethodCodec* codec, - FlValue* result, - GError** error); - - /** - * FlMethodCodec::encode_error_envelope: - * @codec: an #FlMethodCodec. - * @code: an error code. - * @message: (allow-none): an error message, or %NULL. - * @details: (allow-none): error details, or %NULL. - * @error: (allow-none): #GError location to store the error occurring, or - * %NULL. - * - * Encodes an error response to a method call. - * - * Returns: (transfer full): a binary encoding of this response or %NULL if - * not able to encode. - */ - GBytes* (*encode_error_envelope)(FlMethodCodec* codec, - const gchar* code, - const gchar* message, - FlValue* details, - GError** error); - - /** - * FlMethodCodec::decode_response: - * @codec: an #FlMethodCodec. - * @message: message to decode. - * @error: (allow-none): #GError location to store the error occurring, or - * %NULL. - * - * Decodes a response to a method call. - * - * Returns: a new #FlMethodResponse or %NULL on error. - */ - FlMethodResponse* (*decode_response)(FlMethodCodec* codec, - GBytes* message, - GError** error); -}; - -G_END_DECLS - -#endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_METHOD_CODEC_H_ diff --git a/packages/fl_query_hooks/example/linux/flutter/ephemeral/flutter_linux/fl_method_response.h b/packages/fl_query_hooks/example/linux/flutter/ephemeral/flutter_linux/fl_method_response.h deleted file mode 100644 index 90c4b9c..0000000 --- a/packages/fl_query_hooks/example/linux/flutter/ephemeral/flutter_linux/fl_method_response.h +++ /dev/null @@ -1,212 +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. - -#ifndef FLUTTER_SHELL_PLATFORM_LINUX_FL_METHOD_RESPONSE_H_ -#define FLUTTER_SHELL_PLATFORM_LINUX_FL_METHOD_RESPONSE_H_ - -#if !defined(__FLUTTER_LINUX_INSIDE__) && !defined(FLUTTER_LINUX_COMPILATION) -#error "Only can be included directly." -#endif - -#include - -#include "fl_value.h" - -G_BEGIN_DECLS - -/** - * FlMethodResponseError: - * @FL_METHOD_RESPONSE_ERROR_FAILED: Call failed due to an unspecified error. - * @FL_METHOD_RESPONSE_ERROR_REMOTE_ERROR: An error was returned by the other - * side of the channel. - * @FL_METHOD_RESPONSE_ERROR_NOT_IMPLEMENTED: The requested method is not - * implemented. - * - * Errors set by `fl_method_response_get_result` when the method call response - * is not #FlMethodSuccessResponse. - */ -#define FL_METHOD_RESPONSE_ERROR fl_method_response_error_quark() - -typedef enum { - FL_METHOD_RESPONSE_ERROR_FAILED, - FL_METHOD_RESPONSE_ERROR_REMOTE_ERROR, - FL_METHOD_RESPONSE_ERROR_NOT_IMPLEMENTED, -} FlMethodResponseError; - -GQuark fl_method_response_error_quark(void) G_GNUC_CONST; - -G_DECLARE_DERIVABLE_TYPE(FlMethodResponse, - fl_method_response, - FL, - METHOD_RESPONSE, - GObject) - -struct _FlMethodResponseClass { - GObjectClass parent_class; -}; - -G_DECLARE_FINAL_TYPE(FlMethodSuccessResponse, - fl_method_success_response, - FL, - METHOD_SUCCESS_RESPONSE, - FlMethodResponse) - -G_DECLARE_FINAL_TYPE(FlMethodErrorResponse, - fl_method_error_response, - FL, - METHOD_ERROR_RESPONSE, - FlMethodResponse) - -G_DECLARE_FINAL_TYPE(FlMethodNotImplementedResponse, - fl_method_not_implemented_response, - FL, - METHOD_NOT_IMPLEMENTED_RESPONSE, - FlMethodResponse) - -/** - * FlMethodResponse: - * - * #FlMethodResponse contains the information returned when an #FlMethodChannel - * method call returns. If you expect the method call to be successful use - * fl_method_response_get_result(). If you want to handle error cases then you - * should use code like: - * - * |[ - * if (FL_IS_METHOD_SUCCESS_RESPONSE (response)) { - * FlValue *result = - * fl_method_success_response_get_result( - * FL_METHOD_SUCCESS_RESPONSE (response)); - * handle_result (result); - * } else if (FL_IS_METHOD_ERROR_RESPONSE (response)) { - * FlMethodErrorResponse *error_response = - * FL_METHOD_ERROR_RESPONSE (response); - * handle_error (fl_method_error_response_get_code (error_response), - * fl_method_error_response_get_message (error_response), - * fl_method_error_response_get_details (error_response)); - * } - * else if (FL_IS_METHOD_NOT_IMPLEMENTED_RESPONSE (response)) { - * handle_not_implemented (); - * } - * } - * ]| - */ - -/** - * FlMethodSuccessResponse: - * - * #FlMethodSuccessResponse is the #FlMethodResponse returned when a method call - * has successfully completed. The result of the method call is obtained using - * `fl_method_success_response_get_result`. - */ - -/** - * FlMethodErrorResponse: - * - * #FlMethodErrorResponse is the #FlMethodResponse returned when a method call - * results in an error. The error details are obtained using - * `fl_method_error_response_get_code`, `fl_method_error_response_get_message` - * and `fl_method_error_response_get_details`. - */ - -/** - * FlMethodNotImplementedResponse: - * - * #FlMethodNotImplementedResponse is the #FlMethodResponse returned when a - * method call is not implemented. - */ - -/** - * fl_method_response_get_result: - * @response: an #FlMethodResponse. - * @error: (allow-none): #GError location to store the error occurring, or %NULL - * to ignore. - * - * Gets the result of a method call, or an error if the response wasn't - * successful. - * - * Returns: an #FlValue or %NULL on error. - */ -FlValue* fl_method_response_get_result(FlMethodResponse* response, - GError** error); - -/** - * fl_method_success_response_new: - * @result: (allow-none): the #FlValue returned by the method call or %NULL. - * - * Creates a response to a method call when that method has successfully - * completed. - * - * Returns: a new #FlMethodResponse. - */ -FlMethodSuccessResponse* fl_method_success_response_new(FlValue* result); - -/** - * fl_method_success_response_get_result: - * @response: an #FlMethodSuccessResponse. - * - * Gets the result of the method call. - * - * Returns: an #FlValue. - */ -FlValue* fl_method_success_response_get_result( - FlMethodSuccessResponse* response); - -/** - * fl_method_error_response_new: - * @result: an #FlValue. - * @code: an error code. - * @message: (allow-none): an error message. - * @details: (allow-none): error details. - * - * Creates a response to a method call when that method has returned an error. - * - * Returns: a new #FlMethodErrorResponse. - */ -FlMethodErrorResponse* fl_method_error_response_new(const gchar* code, - const gchar* message, - FlValue* details); - -/** - * fl_method_error_response_get_code: - * @response: an #FlMethodErrorResponse. - * - * Gets the error code reported. - * - * Returns: an error code. - */ -const gchar* fl_method_error_response_get_code(FlMethodErrorResponse* response); - -/** - * fl_method_error_response_get_message: - * @response: an #FlMethodErrorResponse. - * - * Gets the error message reported. - * - * Returns: an error message or %NULL if no error message provided. - */ -const gchar* fl_method_error_response_get_message( - FlMethodErrorResponse* response); - -/** - * fl_method_error_response_get_details: - * @response: an #FlMethodErrorResponse. - * - * Gets the details provided with this error. - * - * Returns: an #FlValue or %NULL if no details provided. - */ -FlValue* fl_method_error_response_get_details(FlMethodErrorResponse* response); - -/** - * fl_method_not_implemented_response_new: - * - * Creates a response to a method call when that method does not exist. - * - * Returns: a new #FlMethodNotImplementedResponse. - */ -FlMethodNotImplementedResponse* fl_method_not_implemented_response_new(); - -G_END_DECLS - -#endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_METHOD_RESPONSE_H_ diff --git a/packages/fl_query_hooks/example/linux/flutter/ephemeral/flutter_linux/fl_pixel_buffer_texture.h b/packages/fl_query_hooks/example/linux/flutter/ephemeral/flutter_linux/fl_pixel_buffer_texture.h deleted file mode 100644 index adddd77..0000000 --- a/packages/fl_query_hooks/example/linux/flutter/ephemeral/flutter_linux/fl_pixel_buffer_texture.h +++ /dev/null @@ -1,107 +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. - -#ifndef FLUTTER_SHELL_PLATFORM_LINUX_FL_PIXEL_BUFFER_TEXTURE_H_ -#define FLUTTER_SHELL_PLATFORM_LINUX_FL_PIXEL_BUFFER_TEXTURE_H_ - -#if !defined(__FLUTTER_LINUX_INSIDE__) && !defined(FLUTTER_LINUX_COMPILATION) -#error "Only can be included directly." -#endif - -#include "fl_texture.h" - -G_BEGIN_DECLS - -G_DECLARE_DERIVABLE_TYPE(FlPixelBufferTexture, - fl_pixel_buffer_texture, - FL, - PIXEL_BUFFER_TEXTURE, - GObject) - -/** - * FlPixelBufferTexture: - * - * #FlPixelBufferTexture represents an OpenGL texture generated from a pixel - * buffer. - * - * The following example shows how to implement an #FlPixelBufferTexture. - * ![ - * // Type definition, constructor, init, destructor and class_init are - * // omitted. - * struct _VideoPixelBufferTexture { // extends FlPixelBufferTexture - * FlPixelBufferTexture parent_instance; - * - * uint8_t *buffer; // your pixel buffer. - * } - * - * G_DEFINE_TYPE(VideoTexture, - * video_texture, - * fl_pixel_buffer_texture_get_type ()) - * - * static gboolean - * video_texture_copy_pixels (FlPixelBufferTexture* texture, - * const uint8_t** out_buffer, - * uint32_t* width, - * uint32_t* height, - * GError** error) { - * // This method is called on Render Thread. Be careful with your - * // cross-thread operation. - * - * // @width and @height are initially stored the canvas size in Flutter. - * - * // You must prepare your pixel buffer in RGBA format. - * // So you may do some format conversion first if your original pixel - * // buffer is not in RGBA format. - * manage_your_pixel_buffer_here (); - * - * if (your_operations_are_successfully_finished) { - * // Directly return pointer to your pixel buffer here. - * // Flutter takes content of your pixel buffer after this function - * // is finished. So you must make the buffer live long enough until - * // next tick of Render Thread. - * // If it is hard to manage lifetime of your pixel buffer, you should - * // take look into #FlTextureGL. - * - * *out_buffer = buffer; - * *width = real_width_of_buffer; - * *height = real_height_of_buffer; - * return TRUE; - * } else { - * // set @error to report failure. - * return FALSE; - * } - * } - * ]| - */ - -struct _FlPixelBufferTextureClass { - GObjectClass parent_class; - - /** - * FlPixelBufferTexture::copy_pixels: - * @texture: an #FlPixelBufferTexture. - * @buffer: (out): pixel data. - * @width: (inout): width of the texture in pixels. - * @height: (inout): height of the texture in pixels. - * @error: (allow-none): #GError location to store the error occurring, or - * %NULL to ignore. - * - * Retrieve pixel buffer in RGBA format. - * - * As this method is usually invoked from the render thread, you must - * take care of proper synchronization. It also needs to be ensured that - * the returned buffer is not released prior to unregistering this texture. - * - * Returns: %TRUE on success. - */ - gboolean (*copy_pixels)(FlPixelBufferTexture* texture, - const uint8_t** buffer, - uint32_t* width, - uint32_t* height, - GError** error); -}; - -G_END_DECLS - -#endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_PIXEL_BUFFER_TEXTURE_H_ diff --git a/packages/fl_query_hooks/example/linux/flutter/ephemeral/flutter_linux/fl_plugin_registrar.h b/packages/fl_query_hooks/example/linux/flutter/ephemeral/flutter_linux/fl_plugin_registrar.h deleted file mode 100644 index 6382804..0000000 --- a/packages/fl_query_hooks/example/linux/flutter/ephemeral/flutter_linux/fl_plugin_registrar.h +++ /dev/null @@ -1,76 +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. - -#ifndef FLUTTER_SHELL_PLATFORM_LINUX_FL_PLUGIN_REGISTRAR_H_ -#define FLUTTER_SHELL_PLATFORM_LINUX_FL_PLUGIN_REGISTRAR_H_ - -#if !defined(__FLUTTER_LINUX_INSIDE__) && !defined(FLUTTER_LINUX_COMPILATION) -#error "Only can be included directly." -#endif - -#include - -#include "fl_binary_messenger.h" -#include "fl_texture_registrar.h" -#include "fl_view.h" - -G_BEGIN_DECLS - -G_DECLARE_INTERFACE(FlPluginRegistrar, - fl_plugin_registrar, - FL, - PLUGIN_REGISTRAR, - GObject) - -struct _FlPluginRegistrarInterface { - GTypeInterface parent_iface; - - FlBinaryMessenger* (*get_messenger)(FlPluginRegistrar* registrar); - - FlTextureRegistrar* (*get_texture_registrar)(FlPluginRegistrar* registrar); - - FlView* (*get_view)(FlPluginRegistrar* registrar); -}; - -/** - * FlPluginRegistrar: - * - * #FlPluginRegistrar is used when registering new plugins. - */ - -/** - * fl_plugin_registrar_get_messenger: - * @registrar: an #FlPluginRegistrar. - * - * Gets the messenger this plugin can communicate with. - * - * Returns: an #FlBinaryMessenger. - */ -FlBinaryMessenger* fl_plugin_registrar_get_messenger( - FlPluginRegistrar* registrar); - -/** - * fl_plugin_registrar_get_texture_registrar: - * @registrar: an #FlPluginRegistrar. - * - * Gets the texture registrar this plugin can communicate with. - * - * Returns: an #FlTextureRegistrar. - */ -FlTextureRegistrar* fl_plugin_registrar_get_texture_registrar( - FlPluginRegistrar* registrar); - -/** - * fl_plugin_registrar_get_view: - * @registrar: an #FlPluginRegistrar. - * - * Get the view that Flutter is rendering with. - * - * Returns: (allow-none): an #FlView or %NULL if running in headless mode. - */ -FlView* fl_plugin_registrar_get_view(FlPluginRegistrar* registrar); - -G_END_DECLS - -#endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_PLUGIN_REGISTRAR_H_ diff --git a/packages/fl_query_hooks/example/linux/flutter/ephemeral/flutter_linux/fl_plugin_registry.h b/packages/fl_query_hooks/example/linux/flutter/ephemeral/flutter_linux/fl_plugin_registry.h deleted file mode 100644 index ac16aba..0000000 --- a/packages/fl_query_hooks/example/linux/flutter/ephemeral/flutter_linux/fl_plugin_registry.h +++ /dev/null @@ -1,61 +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. - -#ifndef FLUTTER_SHELL_PLATFORM_LINUX_FL_PLUGIN_REGISTRY_H_ -#define FLUTTER_SHELL_PLATFORM_LINUX_FL_PLUGIN_REGISTRY_H_ - -#if !defined(__FLUTTER_LINUX_INSIDE__) && !defined(FLUTTER_LINUX_COMPILATION) -#error "Only can be included directly." -#endif - -#include - -#include "fl_plugin_registrar.h" - -G_BEGIN_DECLS - -G_DECLARE_INTERFACE(FlPluginRegistry, - fl_plugin_registry, - FL, - PLUGIN_REGISTRY, - GObject) - -/** - * FlPluginRegistry: - * - * #FlPluginRegistry vends #FlPluginRegistrar objects for named plugins. - */ - -struct _FlPluginRegistryInterface { - GTypeInterface g_iface; - - /** - * FlPluginRegistry::get_registrar_for_plugin: - * @registry: an #FlPluginRegistry. - * @name: plugin name. - * - * Gets the plugin registrar for the plugin with @name. - * - * Returns: (transfer full): an #FlPluginRegistrar. - */ - FlPluginRegistrar* (*get_registrar_for_plugin)(FlPluginRegistry* registry, - const gchar* name); -}; - -/** - * fl_plugin_registry_get_registrar_for_plugin: - * @registry: an #FlPluginRegistry. - * @name: plugin name. - * - * Gets the plugin registrar for the plugin with @name. - * - * Returns: (transfer full): an #FlPluginRegistrar. - */ -FlPluginRegistrar* fl_plugin_registry_get_registrar_for_plugin( - FlPluginRegistry* registry, - const gchar* name); - -G_END_DECLS - -#endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_PLUGIN_REGISTRY_H_ diff --git a/packages/fl_query_hooks/example/linux/flutter/ephemeral/flutter_linux/fl_standard_message_codec.h b/packages/fl_query_hooks/example/linux/flutter/ephemeral/flutter_linux/fl_standard_message_codec.h deleted file mode 100644 index 2af7b83..0000000 --- a/packages/fl_query_hooks/example/linux/flutter/ephemeral/flutter_linux/fl_standard_message_codec.h +++ /dev/null @@ -1,47 +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. - -#ifndef FLUTTER_SHELL_PLATFORM_LINUX_FL_STANDARD_MESSAGE_CODEC_H_ -#define FLUTTER_SHELL_PLATFORM_LINUX_FL_STANDARD_MESSAGE_CODEC_H_ - -#if !defined(__FLUTTER_LINUX_INSIDE__) && !defined(FLUTTER_LINUX_COMPILATION) -#error "Only can be included directly." -#endif - -#include "fl_message_codec.h" - -G_BEGIN_DECLS - -G_DECLARE_FINAL_TYPE(FlStandardMessageCodec, - fl_standard_message_codec, - FL, - STANDARD_CODEC, - FlMessageCodec) - -/** - * FlStandardMessageCodec: - * - * #FlStandardMessageCodec is an #FlMessageCodec that implements the Flutter - * standard message encoding. This codec encodes and decodes #FlValue of type - * #FL_VALUE_TYPE_NULL, #FL_VALUE_TYPE_BOOL, #FL_VALUE_TYPE_INT, - * #FL_VALUE_TYPE_FLOAT, #FL_VALUE_TYPE_STRING, #FL_VALUE_TYPE_UINT8_LIST, - * #FL_VALUE_TYPE_INT32_LIST, #FL_VALUE_TYPE_INT64_LIST, - * #FL_VALUE_TYPE_FLOAT_LIST, #FL_VALUE_TYPE_LIST, and #FL_VALUE_TYPE_MAP. - * - * #FlStandardMessageCodec matches the StandardCodec class in the Flutter - * services library. - */ - -/* - * fl_standard_message_codec_new: - * - * Creates an #FlStandardMessageCodec. - * - * Returns: a new #FlStandardMessageCodec. - */ -FlStandardMessageCodec* fl_standard_message_codec_new(); - -G_END_DECLS - -#endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_STANDARD_MESSAGE_CODEC_H_ diff --git a/packages/fl_query_hooks/example/linux/flutter/ephemeral/flutter_linux/fl_standard_method_codec.h b/packages/fl_query_hooks/example/linux/flutter/ephemeral/flutter_linux/fl_standard_method_codec.h deleted file mode 100644 index 1685ebc..0000000 --- a/packages/fl_query_hooks/example/linux/flutter/ephemeral/flutter_linux/fl_standard_method_codec.h +++ /dev/null @@ -1,44 +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. - -#ifndef FLUTTER_SHELL_PLATFORM_LINUX_FL_STANDARD_METHOD_CODEC_H_ -#define FLUTTER_SHELL_PLATFORM_LINUX_FL_STANDARD_METHOD_CODEC_H_ - -#if !defined(__FLUTTER_LINUX_INSIDE__) && !defined(FLUTTER_LINUX_COMPILATION) -#error "Only can be included directly." -#endif - -#include "fl_method_codec.h" - -G_BEGIN_DECLS - -G_DECLARE_FINAL_TYPE(FlStandardMethodCodec, - fl_standard_method_codec, - FL, - STANDARD_METHOD_CODEC, - FlMethodCodec) - -/** - * FlStandardMethodCodec: - * - * #FlStandardMethodCodec is an #FlMethodCodec that implements method calls - * using the Flutter standard message encoding. It should be used with a - * #FlMethodChannel. - * - * #FlStandardMethodCodec matches the StandardMethodCodec class in the Flutter - * services library. - */ - -/** - * fl_standard_method_codec_new: - * - * Creates an #FlStandardMethodCodec. - * - * Returns: a new #FlStandardMethodCodec. - */ -FlStandardMethodCodec* fl_standard_method_codec_new(); - -G_END_DECLS - -#endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_STANDARD_METHOD_CODEC_H_ diff --git a/packages/fl_query_hooks/example/linux/flutter/ephemeral/flutter_linux/fl_string_codec.h b/packages/fl_query_hooks/example/linux/flutter/ephemeral/flutter_linux/fl_string_codec.h deleted file mode 100644 index 8f49e9f..0000000 --- a/packages/fl_query_hooks/example/linux/flutter/ephemeral/flutter_linux/fl_string_codec.h +++ /dev/null @@ -1,44 +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. - -#ifndef FLUTTER_SHELL_PLATFORM_LINUX_FL_STRING_CODEC_H_ -#define FLUTTER_SHELL_PLATFORM_LINUX_FL_STRING_CODEC_H_ - -#if !defined(__FLUTTER_LINUX_INSIDE__) && !defined(FLUTTER_LINUX_COMPILATION) -#error "Only can be included directly." -#endif - -#include "fl_message_codec.h" - -G_BEGIN_DECLS - -G_DECLARE_FINAL_TYPE(FlStringCodec, - fl_string_codec, - FL, - STRING_CODEC, - FlMessageCodec) - -/** - * FlStringCodec: - * - * #FlStringCodec is an #FlMessageCodec that implements the Flutter string - * message encoding. This only encodes and decodes #FlValue of type - * #FL_VALUE_TYPE_STRING, other types #FlValues will generate an error during - * encoding. - * - * #FlStringCodec matches the StringCodec class in the Flutter services library. - */ - -/** - * fl_string_codec_new: - * - * Creates an #FlStringCodec. - * - * Returns: a new #FlStringCodec. - */ -FlStringCodec* fl_string_codec_new(); - -G_END_DECLS - -#endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_STRING_CODEC_H_ diff --git a/packages/fl_query_hooks/example/linux/flutter/ephemeral/flutter_linux/fl_texture.h b/packages/fl_query_hooks/example/linux/flutter/ephemeral/flutter_linux/fl_texture.h deleted file mode 100644 index 45ceb51..0000000 --- a/packages/fl_query_hooks/example/linux/flutter/ephemeral/flutter_linux/fl_texture.h +++ /dev/null @@ -1,35 +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. - -#ifndef FLUTTER_SHELL_PLATFORM_LINUX_FL_TEXTURE_H_ -#define FLUTTER_SHELL_PLATFORM_LINUX_FL_TEXTURE_H_ - -#if !defined(__FLUTTER_LINUX_INSIDE__) && !defined(FLUTTER_LINUX_COMPILATION) -#error "Only can be included directly." -#endif - -#include -#include - -G_BEGIN_DECLS - -G_DECLARE_INTERFACE(FlTexture, fl_texture, FL, TEXTURE, GObject) - -/** - * FlTexture: - * - * #FlTexture represents a texture. - * - * You can derive #FlTextureGL for populating hardware-accelerated textures or - * instantiate #FlPixelBufferTexture for populating pixel buffers. Do NOT - * directly implement this interface. - */ - -struct _FlTextureInterface { - GTypeInterface g_iface; -}; - -G_END_DECLS - -#endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_TEXTURE_H_ diff --git a/packages/fl_query_hooks/example/linux/flutter/ephemeral/flutter_linux/fl_texture_gl.h b/packages/fl_query_hooks/example/linux/flutter/ephemeral/flutter_linux/fl_texture_gl.h deleted file mode 100644 index 949f4af..0000000 --- a/packages/fl_query_hooks/example/linux/flutter/ephemeral/flutter_linux/fl_texture_gl.h +++ /dev/null @@ -1,103 +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. - -#ifndef FLUTTER_SHELL_PLATFORM_LINUX_FL_TEXTURE_GL_H_ -#define FLUTTER_SHELL_PLATFORM_LINUX_FL_TEXTURE_GL_H_ - -#if !defined(__FLUTTER_LINUX_INSIDE__) && !defined(FLUTTER_LINUX_COMPILATION) -#error "Only can be included directly." -#endif - -#include -#include -#include "fl_texture.h" - -G_BEGIN_DECLS - -G_DECLARE_DERIVABLE_TYPE(FlTextureGL, fl_texture_gl, FL, TEXTURE_GL, GObject) - -/** - * FlTextureGL: - * - * #FlTextureGL is an abstract class that represents an OpenGL texture. - * - * If you want to render textures in other OpenGL context, create and use the - * #GdkGLContext by calling gdk_window_create_gl_context () with the #GdkWindow - * of #FlView. The context will be shared with the one used by Flutter. - * - * The following example shows how to implement an #FlTextureGL. - * ![ - * #include - * - * // Type definition, constructor, init, destructor, and class_init are - * // omitted. - * struct _VideoTextureGL { // extends FlTextureGL - * FlTextureGL parent_instance; - * - * GLuint texture_id; - * }; - * - * G_DEFINE_TYPE(VideoTexture, - * video_texture, - * fl_texture_gl_get_type ()) - * - * static gboolean - * video_texture_populate (FlTextureGL *texture, - * uint32_t *target, - * uint32_t *name, - * uint32_t *width, - * uint32_t *height, - * GError **error) { - * VideoTextureGL *self = VIDEO_TEXTURE_GL (texture); - * if (self->texture_id == 0) { - * glGenTextures (1, &self->texture_id); - * glBindTexture (GL_TEXTURE_2D, self->texture_id); - * // further configuration here. - * } else { - * glBindTexture (GL_TEXTURE_2D, self->texture_id); - * } - * - * // For example, we render pixel buffer here. - * // Note that Flutter only accepts textures in GL_RGBA8 format. - * static char buffer[] = { 0x1f, 0x2f, 0x3f, 0x4f }; // 1x1 pixel. - * glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8, 1, 1, 0, GL_RGBA, - * GL_UNSIGNED_BYTE, buffer); - * - * *target = GL_TEXTURE_2D; - * *name = self->texture_id; - * *width = 1; - * *height = 1; - * - * return TRUE; - * } - * ]| - */ - -struct _FlTextureGLClass { - GObjectClass parent_class; - - /** - * Virtual method called when Flutter populates this texture. The OpenGL - * context used by Flutter has been already set. - * @texture: an #FlTexture. - * @target: texture target (example GL_TEXTURE_2D or GL_TEXTURE_RECTANGLE). - * @name: (out): name of texture. - * @width: (inout): width of the texture in pixels. - * @height: (inout): height of the texture in pixels. - * @error: (allow-none): #GError location to store the error occurring, or - * %NULL to ignore. - * - * Returns: %TRUE on success. - */ - gboolean (*populate)(FlTextureGL* texture, - uint32_t* target, - uint32_t* name, - uint32_t* width, - uint32_t* height, - GError** error); -}; - -G_END_DECLS - -#endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_TEXTURE_H_ diff --git a/packages/fl_query_hooks/example/linux/flutter/ephemeral/flutter_linux/fl_texture_registrar.h b/packages/fl_query_hooks/example/linux/flutter/ephemeral/flutter_linux/fl_texture_registrar.h deleted file mode 100644 index 1c03cdc..0000000 --- a/packages/fl_query_hooks/example/linux/flutter/ephemeral/flutter_linux/fl_texture_registrar.h +++ /dev/null @@ -1,91 +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. - -#ifndef FLUTTER_SHELL_PLATFORM_LINUX_FL_TEXTURE_REGISTRAR_H_ -#define FLUTTER_SHELL_PLATFORM_LINUX_FL_TEXTURE_REGISTRAR_H_ - -#if !defined(__FLUTTER_LINUX_INSIDE__) && !defined(FLUTTER_LINUX_COMPILATION) -#error "Only can be included directly." -#endif - -#include -#include - -#include "fl_texture.h" - -G_BEGIN_DECLS - -G_DECLARE_INTERFACE(FlTextureRegistrar, - fl_texture_registrar, - FL, - TEXTURE_REGISTRAR, - GObject) - -struct _FlTextureRegistrarInterface { - GTypeInterface parent_iface; - - gboolean (*register_texture)(FlTextureRegistrar* registrar, - FlTexture* texture); - - FlTexture* (*lookup_texture)(FlTextureRegistrar* registrar, int64_t id); - - gboolean (*mark_texture_frame_available)(FlTextureRegistrar* registrar, - FlTexture* texture); - - gboolean (*unregister_texture)(FlTextureRegistrar* registrar, - FlTexture* texture); -}; - -/** - * FlTextureRegistrar: - * - * #FlTextureRegistrar is used when registering textures. - * - * Flutter Framework accesses your texture by the related unique texture ID. To - * draw your texture in Dart, you should add Texture widget in your widget tree - * with the same texture ID. Use platform channels to send this unique texture - * ID to the Dart side. - */ - -/** - * fl_texture_registrar_register_texture: - * @registrar: an #FlTextureRegistrar. - * @texture: an #FlTexture for registration. - * - * Registers a texture. - * - * Returns: %TRUE on success. - */ -gboolean fl_texture_registrar_register_texture(FlTextureRegistrar* registrar, - FlTexture* texture); - -/** - * fl_texture_registrar_mark_texture_frame_available: - * @registrar: an #FlTextureRegistrar. - * @texture: the texture that has a frame available. - * - * Notifies the flutter engine that the texture object has updated and needs to - * be rerendered. - * - * Returns: %TRUE on success. - */ -gboolean fl_texture_registrar_mark_texture_frame_available( - FlTextureRegistrar* registrar, - FlTexture* texture); - -/** - * fl_texture_registrar_unregister_texture: - * @registrar: an #FlTextureRegistrar. - * @texture: the texture being unregistered. - * - * Unregisters an existing texture object. - * - * Returns: %TRUE on success. - */ -gboolean fl_texture_registrar_unregister_texture(FlTextureRegistrar* registrar, - FlTexture* texture); - -G_END_DECLS - -#endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_TEXTURE_REGISTRAR_H_ diff --git a/packages/fl_query_hooks/example/linux/flutter/ephemeral/flutter_linux/fl_value.h b/packages/fl_query_hooks/example/linux/flutter/ephemeral/flutter_linux/fl_value.h deleted file mode 100644 index 7365d46..0000000 --- a/packages/fl_query_hooks/example/linux/flutter/ephemeral/flutter_linux/fl_value.h +++ /dev/null @@ -1,614 +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. - -#ifndef FLUTTER_SHELL_PLATFORM_LINUX_FL_VALUE_H_ -#define FLUTTER_SHELL_PLATFORM_LINUX_FL_VALUE_H_ - -#include -#include -#include - -#if !defined(__FLUTTER_LINUX_INSIDE__) && !defined(FLUTTER_LINUX_COMPILATION) -#error "Only can be included directly." -#endif - -G_BEGIN_DECLS - -/** - * FlValue: - * - * #FlValue is an object that contains the data types used in the platform - * channel used by Flutter. - * - * In Dart the values are represented as follows: - * - #FL_VALUE_TYPE_NULL: Null - * - #FL_VALUE_TYPE_BOOL: bool - * - #FL_VALUE_TYPE_INT: num - * - #FL_VALUE_TYPE_FLOAT: num - * - #FL_VALUE_TYPE_STRING: String - * - #FL_VALUE_TYPE_UINT8_LIST: Uint8List - * - #FL_VALUE_TYPE_INT32_LIST: Int32List - * - #FL_VALUE_TYPE_INT64_LIST: Int64List - * - #FL_VALUE_TYPE_FLOAT32_LIST: Float32List - * - #FL_VALUE_TYPE_FLOAT_LIST: Float64List - * - #FL_VALUE_TYPE_LIST: List - * - #FL_VALUE_TYPE_MAP: Map - * - * See #FlMessageCodec to encode and decode these values. - */ -typedef struct _FlValue FlValue; - -/** - * FlValueType: - * @FL_VALUE_TYPE_NULL: The null value. - * @FL_VALUE_TYPE_BOOL: A boolean. - * @FL_VALUE_TYPE_INT: A 64 bit signed integer. - * @FL_VALUE_TYPE_FLOAT: A 64 bit floating point number. - * @FL_VALUE_TYPE_STRING: UTF-8 text. - * @FL_VALUE_TYPE_UINT8_LIST: An ordered list of unsigned 8 bit integers. - * @FL_VALUE_TYPE_INT32_LIST: An ordered list of 32 bit integers. - * @FL_VALUE_TYPE_INT64_LIST: An ordered list of 64 bit integers. - * @FL_VALUE_TYPE_FLOAT_LIST: An ordered list of floating point numbers. - * @FL_VALUE_TYPE_LIST: An ordered list of #FlValue objects. - * @FL_VALUE_TYPE_MAP: A map of #FlValue objects keyed by #FlValue object. - * @FL_VALUE_TYPE_FLOAT32_LIST: An ordered list of 32bit floating point numbers. - * - * Types of #FlValue. - */ -typedef enum { - FL_VALUE_TYPE_NULL, - FL_VALUE_TYPE_BOOL, - FL_VALUE_TYPE_INT, - FL_VALUE_TYPE_FLOAT, - FL_VALUE_TYPE_STRING, - FL_VALUE_TYPE_UINT8_LIST, - FL_VALUE_TYPE_INT32_LIST, - FL_VALUE_TYPE_INT64_LIST, - FL_VALUE_TYPE_FLOAT_LIST, - FL_VALUE_TYPE_LIST, - FL_VALUE_TYPE_MAP, - FL_VALUE_TYPE_FLOAT32_LIST, -} FlValueType; - -/** - * fl_value_new_null: - * - * Creates an #FlValue that contains a null value. The equivalent Dart type is - * null. - * - * Returns: a new #FlValue. - */ -FlValue* fl_value_new_null(); - -/** - * fl_value_new_bool: - * @value: the value. - * - * Creates an #FlValue that contains a boolean value. The equivalent Dart type - * is a bool. - * - * Returns: a new #FlValue. - */ -FlValue* fl_value_new_bool(bool value); - -/** - * fl_value_new_int: - * @value: the value. - * - * Creates an #FlValue that contains an integer number. The equivalent Dart type - * is a num. - * - * Returns: a new #FlValue. - */ -FlValue* fl_value_new_int(int64_t value); - -/** - * fl_value_new_float: - * @value: the value. - * - * Creates an #FlValue that contains a floating point number. The equivalent - * Dart type is a num. - * - * Returns: a new #FlValue. - */ -FlValue* fl_value_new_float(double value); - -/** - * fl_value_new_string: - * @value: a %NULL-terminated UTF-8 string. - * - * Creates an #FlValue that contains UTF-8 text. The equivalent Dart type is a - * String. - * - * Returns: a new #FlValue. - */ -FlValue* fl_value_new_string(const gchar* value); - -/** - * fl_value_new_string_sized: - * @value: a buffer containing UTF-8 text. It does not require a nul terminator. - * @value_length: the number of bytes to use from @value. - * - * Creates an #FlValue that contains UTF-8 text. The equivalent Dart type is a - * String. - * - * Returns: a new #FlValue. - */ -FlValue* fl_value_new_string_sized(const gchar* value, size_t value_length); - -/** - * fl_value_new_uint8_list: - * @value: an array of unsigned 8 bit integers. - * @value_length: number of elements in @value. - * - * Creates an ordered list containing 8 bit unsigned integers. The data is - * copied. The equivalent Dart type is a Uint8List. - * - * Returns: a new #FlValue. - */ -FlValue* fl_value_new_uint8_list(const uint8_t* value, size_t value_length); - -/** - * fl_value_new_uint8_list_from_bytes: - * @value: a #GBytes. - * - * Creates an ordered list containing 8 bit unsigned integers. The data is - * copied. The equivalent Dart type is a Uint8List. - * - * Returns: a new #FlValue. - */ -FlValue* fl_value_new_uint8_list_from_bytes(GBytes* value); - -/** - * fl_value_new_int32_list: - * @value: an array of signed 32 bit integers. - * @value_length: number of elements in @value. - * - * Creates an ordered list containing 32 bit integers. The equivalent Dart type - * is a Int32List. - * - * Returns: a new #FlValue. - */ -FlValue* fl_value_new_int32_list(const int32_t* value, size_t value_length); - -/** - * fl_value_new_int64_list: - * @value: an array of signed 64 bit integers. - * @value_length: number of elements in @value. - * - * Creates an ordered list containing 64 bit integers. The equivalent Dart type - * is a Int64List. - * - * Returns: a new #FlValue. - */ -FlValue* fl_value_new_int64_list(const int64_t* value, size_t value_length); - -/** - * fl_value_new_float32_list: - * @value: an array of floating point numbers. - * @value_length: number of elements in @value. - * - * Creates an ordered list containing 32 bit floating point numbers. - * The equivalent Dart type is a Float32List. - * - * Returns: a new #FlValue. - */ -FlValue* fl_value_new_float32_list(const float* value, size_t value_length); - -/** - * fl_value_new_float_list: - * @value: an array of floating point numbers. - * @value_length: number of elements in @value. - * - * Creates an ordered list containing floating point numbers. The equivalent - * Dart type is a Float64List. - * - * Returns: a new #FlValue. - */ -FlValue* fl_value_new_float_list(const double* value, size_t value_length); - -/** - * fl_value_new_list: - * - * Creates an ordered list. Children can be added to the list using - * fl_value_append(). The children are accessed using fl_value_get_length() - * and fl_value_get_list_value(). The equivalent Dart type is a List. - * - * The following example shows a simple list of values: - * - * |[ - * g_autoptr(FlValue) value = fl_value_new_list (); - * fl_value_append_take (value, fl_value_new_string ("one"); - * fl_value_append_take (value, fl_value_new_int (2); - * fl_value_append_take (value, fl_value_new_double (3.0); - * ]| - * - * This value can be decoded using: - * - * |[ - * g_assert (fl_value_get_type (value) == FL_VALUE_TYPE_LIST); - * for (size_t i = 0; i < fl_value_get_length (value); i++) { - * FlValue *child = fl_value_get_list_value (value, i); - * process_value (child); - * } - * ]| - * - * Returns: a new #FlValue. - */ -FlValue* fl_value_new_list(); - -/** - * fl_value_new_list_from_strv: - * @value: a %NULL-terminated array of strings. - * - * Creates an ordered list containing #FlString values. - * - * Returns: a new #FlValue. - */ -FlValue* fl_value_new_list_from_strv(const gchar* const* value); - -/** - * fl_value_new_map: - * - * Creates an ordered associative array. Children can be added to the map - * using fl_value_set(), fl_value_set_take(), fl_value_set_string(), - * fl_value_set_string_take(). The children are accessed using - * fl_value_get_length(), fl_value_get_map_key(), fl_value_get_map_value(), - * fl_value_lookup() and fl_value_lookup_string(). The equivalent Dart type is a - * Map. - * - * The following example shows how to create a map of values keyed by strings: - * - * |[ - * g_autoptr(FlValue) value = fl_value_new_map (); - * fl_value_set_string_take (value, "name", fl_value_new_string ("Gandalf")); - * fl_value_set_string_take (value, "occupation", - * fl_value_new_string ("Wizard")); - * fl_value_set_string_take (value, "age", fl_value_new_int (2019)); - * ]| - * - * This value can be decoded using: - * |[ - * g_assert (fl_value_get_type (value) == FL_VALUE_TYPE_MAP); - * FlValue *name = fl_value_lookup_string (value, "name"); - * g_assert (fl_value_get_type (name) == FL_VALUE_TYPE_STRING); - * FlValue *age = fl_value_lookup_string (value, "age"); - * g_assert (fl_value_get_type (age) == FL_VALUE_TYPE_INT); - * g_message ("Next customer is %s (%d years old)", - * fl_value_get_string (name), - * fl_value_get_int (age)); - * ]| - * - * Returns: a new #FlValue. - */ -FlValue* fl_value_new_map(); - -/** - * fl_value_ref: - * @value: an #FlValue. - * - * Increases the reference count of an #FlValue. - * - * Returns: the value that was referenced. - */ -FlValue* fl_value_ref(FlValue* value); - -/** - * fl_value_unref: - * @value: an #FlValue. - * - * Decreases the reference count of an #FlValue. When the reference count hits - * zero @value is destroyed and no longer valid. - */ -void fl_value_unref(FlValue* value); - -/** - * fl_value_get_type: - * @value: an #FlValue. - * - * Gets the type of @value. - * - * Returns: an #FlValueType. - */ -FlValueType fl_value_get_type(FlValue* value); - -/** - * fl_value_equal: - * @a: an #FlValue. - * @b: an #FlValue. - * - * Compares two #FlValue to see if they are equivalent. Two values are - * considered equivalent if they are of the same type and their data is the same - * including any child values. For values of type #FL_VALUE_TYPE_MAP the order - * of the values does not matter. - * - * Returns: %TRUE if both values are equivalent. - */ -bool fl_value_equal(FlValue* a, FlValue* b); - -/** - * fl_value_append: - * @value: an #FlValue of type #FL_VALUE_TYPE_LIST. - * @child: an #FlValue. - * - * Adds @child to the end of @value. Calling this with an #FlValue that is not - * of type #FL_VALUE_TYPE_LIST is a programming error. - */ -void fl_value_append(FlValue* value, FlValue* child); - -/** - * fl_value_append_take: - * @value: an #FlValue of type #FL_VALUE_TYPE_LIST. - * @child: (transfer full): an #FlValue. - * - * Adds @child to the end of @value. Ownership of @child is taken by @value. - * Calling this with an #FlValue that is not of type #FL_VALUE_TYPE_LIST is a - * programming error. - */ -void fl_value_append_take(FlValue* value, FlValue* child); - -/** - * fl_value_set: - * @value: an #FlValue of type #FL_VALUE_TYPE_MAP. - * @key: an #FlValue. - * @child_value: an #FlValue. - * - * Sets @key in @value to @child_value. If an existing value was in the map with - * the same key it is replaced. Calling this with an #FlValue that is not of - * type #FL_VALUE_TYPE_MAP is a programming error. - */ -void fl_value_set(FlValue* value, FlValue* key, FlValue* child_value); - -/** - * fl_value_set_take: - * @value: an #FlValue of type #FL_VALUE_TYPE_MAP. - * @key: (transfer full): an #FlValue. - * @child_value: (transfer full): an #FlValue. - * - * Sets @key in @value to @child_value. Ownership of both @key and @child_value - * is taken by @value. If an existing value was in the map with the same key it - * is replaced. Calling this with an #FlValue that is not of type - * #FL_VALUE_TYPE_MAP is a programming error. - */ -void fl_value_set_take(FlValue* value, FlValue* key, FlValue* child_value); - -/** - * fl_value_set_string: - * @value: an #FlValue of type #FL_VALUE_TYPE_MAP. - * @key: a UTF-8 text key. - * @child_value: an #FlValue. - * - * Sets a value in the map with a text key. If an existing value was in the map - * with the same key it is replaced. Calling this with an #FlValue that is not - * of type #FL_VALUE_TYPE_MAP is a programming error. - */ -void fl_value_set_string(FlValue* value, - const gchar* key, - FlValue* child_value); - -/** - * fl_value_set_string_take: - * @value: an #FlValue of type #FL_VALUE_TYPE_MAP. - * @key: a UTF-8 text key. - * @child_value: (transfer full): an #FlValue. - * - * Sets a value in the map with a text key, taking ownership of the value. If an - * existing value was in the map with the same key it is replaced. Calling this - * with an #FlValue that is not of type #FL_VALUE_TYPE_MAP is a programming - * error. - */ -void fl_value_set_string_take(FlValue* value, - const gchar* key, - FlValue* child_value); - -/** - * fl_value_get_bool: - * @value: an #FlValue of type #FL_VALUE_TYPE_BOOL. - * - * Gets the boolean value of @value. Calling this with an #FlValue that is - * not of type #FL_VALUE_TYPE_BOOL is a programming error. - * - * Returns: a boolean value. - */ -bool fl_value_get_bool(FlValue* value); - -/** - * fl_value_get_int: - * @value: an #FlValue of type #FL_VALUE_TYPE_INT. - * - * Gets the integer number of @value. Calling this with an #FlValue that is - * not of type #FL_VALUE_TYPE_INT is a programming error. - * - * Returns: an integer number. - */ -int64_t fl_value_get_int(FlValue* value); - -/** - * fl_value_get_float: - * @value: an #FlValue of type #FL_VALUE_TYPE_FLOAT. - * - * Gets the floating point number of @value. Calling this with an #FlValue - * that is not of type #FL_VALUE_TYPE_FLOAT is a programming error. - * - * Returns: a floating point number. - */ -double fl_value_get_float(FlValue* value); - -/** - * fl_value_get_string: - * @value: an #FlValue of type #FL_VALUE_TYPE_STRING. - * - * Gets the UTF-8 text contained in @value. Calling this with an #FlValue - * that is not of type #FL_VALUE_TYPE_STRING is a programming error. - * - * Returns: a UTF-8 encoded string. - */ -const gchar* fl_value_get_string(FlValue* value); - -/** - * fl_value_get_length: - * @value: an #FlValue of type #FL_VALUE_TYPE_UINT8_LIST, - * #FL_VALUE_TYPE_INT32_LIST, #FL_VALUE_TYPE_INT64_LIST, - * #FL_VALUE_TYPE_FLOAT32_LIST, #FL_VALUE_TYPE_FLOAT_LIST, #FL_VALUE_TYPE_LIST - * or #FL_VALUE_TYPE_MAP. - * - * Gets the number of elements @value contains. This is only valid for list - * and map types. Calling this with other types is a programming error. - * - * Returns: the number of elements inside @value. - */ -size_t fl_value_get_length(FlValue* value); - -/** - * fl_value_get_uint8_list: - * @value: an #FlValue of type #FL_VALUE_TYPE_UINT8_LIST. - * - * Gets the array of unisigned 8 bit integers @value contains. The data - * contains fl_value_get_length() elements. Calling this with an #FlValue that - * is not of type #FL_VALUE_TYPE_UINT8_LIST is a programming error. - * - * Returns: an array of unsigned 8 bit integers. - */ -const uint8_t* fl_value_get_uint8_list(FlValue* value); - -/** - * fl_value_get_int32_list: - * @value: an #FlValue of type #FL_VALUE_TYPE_INT32_LIST. - * - * Gets the array of 32 bit integers @value contains. The data contains - * fl_value_get_length() elements. Calling this with an #FlValue that is not of - * type #FL_VALUE_TYPE_INT32_LIST is a programming error. - * - * Returns: an array of 32 bit integers. - */ -const int32_t* fl_value_get_int32_list(FlValue* value); - -/** - * fl_value_get_int64_list: - * @value: an #FlValue of type #FL_VALUE_TYPE_INT64_LIST. - * - * Gets the array of 64 bit integers @value contains. The data contains - * fl_value_get_length() elements. Calling this with an #FlValue that is not of - * type #FL_VALUE_TYPE_INT64_LIST is a programming error. - * - * Returns: an array of 64 bit integers. - */ -const int64_t* fl_value_get_int64_list(FlValue* value); - -/** - * fl_value_get_float32_list: - * @value: an #FlValue of type #FL_VALUE_TYPE_FLOAT32_LIST. - * - * Gets the array of floating point numbers @value contains. The data - * contains fl_value_get_length() elements. Calling this with an #FlValue that - * is not of type #FL_VALUE_TYPE_FLOAT32_LIST is a programming error. - * - * Returns: an array of floating point numbers. - */ -const float* fl_value_get_float32_list(FlValue* value); - -/** - * fl_value_get_float_list: - * @value: an #FlValue of type #FL_VALUE_TYPE_FLOAT_LIST. - * - * Gets the array of floating point numbers @value contains. The data - * contains fl_value_get_length() elements. Calling this with an #FlValue that - * is not of type #FL_VALUE_TYPE_FLOAT_LIST is a programming error. - * - * Returns: an array of floating point numbers. - */ -const double* fl_value_get_float_list(FlValue* value); - -/** - * fl_value_get_list_value: - * @value: an #FlValue of type #FL_VALUE_TYPE_LIST. - * @index: an index in the list. - * - * Gets a child element of the list. It is a programming error to request an - * index that is outside the size of the list as returned from - * fl_value_get_length(). Calling this with an #FlValue that is not of type - * #FL_VALUE_TYPE_LIST is a programming error. - * - * Returns: an #FlValue. - */ -FlValue* fl_value_get_list_value(FlValue* value, size_t index); - -/** - * fl_value_get_map_key: - * @value: an #FlValue of type #FL_VALUE_TYPE_MAP. - * @index: an index in the map. - * - * Gets a key from the map. It is a programming error to request an index that - * is outside the size of the list as returned from fl_value_get_length(). - * Calling this with an #FlValue that is not of type #FL_VALUE_TYPE_MAP is a - * programming error. - * - * Returns: an #FlValue. - */ -FlValue* fl_value_get_map_key(FlValue* value, size_t index); - -/** - * fl_value_get_map_value: - * @value: an #FlValue of type #FL_VALUE_TYPE_MAP. - * @index: an index in the map. - * - * Gets a value from the map. It is a programming error to request an index that - * is outside the size of the list as returned from fl_value_get_length(). - * Calling this with an #FlValue that is not of type #FL_VALUE_TYPE_MAP is a - * programming error. - * - * Returns: an #FlValue. - */ -FlValue* fl_value_get_map_value(FlValue* value, size_t index); - -/** - * fl_value_lookup: - * @value: an #FlValue of type #FL_VALUE_TYPE_MAP. - * @key: a key value. - * - * Gets the map entry that matches @key. Keys are checked using - * fl_value_equal(). Calling this with an #FlValue that is not of type - * #FL_VALUE_TYPE_MAP is a programming error. - * - * Map lookups are not optimized for performance - if you have a large map or - * need frequent access you should copy the data into another structure, e.g. - * #GHashTable. - * - * Returns: (allow-none): the value with this key or %NULL if not one present. - */ -FlValue* fl_value_lookup(FlValue* value, FlValue* key); - -/** - * fl_value_lookup_string: - * @value: an #FlValue of type #FL_VALUE_TYPE_MAP. - * @key: a key value. - * - * Gets the map entry that matches @key. Keys are checked using - * fl_value_equal(). Calling this with an #FlValue that is not of type - * #FL_VALUE_TYPE_MAP is a programming error. - * - * Map lookups are not optimized for performance - if you have a large map or - * need frequent access you should copy the data into another structure, e.g. - * #GHashTable. - * - * Returns: (allow-none): the value with this key or %NULL if not one present. - */ -FlValue* fl_value_lookup_string(FlValue* value, const gchar* key); - -/** - * fl_value_to_string: - * @value: an #FlValue. - * - * Converts an #FlValue to a text representation, suitable for logging purposes. - * The text is formatted to be the equivalent of Dart toString() methods. - * - * Returns: UTF-8 text. - */ -gchar* fl_value_to_string(FlValue* value); - -G_DEFINE_AUTOPTR_CLEANUP_FUNC(FlValue, fl_value_unref) - -G_END_DECLS - -#endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_VALUE_H_ diff --git a/packages/fl_query_hooks/example/linux/flutter/ephemeral/flutter_linux/fl_view.h b/packages/fl_query_hooks/example/linux/flutter/ephemeral/flutter_linux/fl_view.h deleted file mode 100644 index f93f385..0000000 --- a/packages/fl_query_hooks/example/linux/flutter/ephemeral/flutter_linux/fl_view.h +++ /dev/null @@ -1,61 +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. - -#ifndef FLUTTER_SHELL_PLATFORM_LINUX_FL_VIEW_H_ -#define FLUTTER_SHELL_PLATFORM_LINUX_FL_VIEW_H_ - -#if !defined(__FLUTTER_LINUX_INSIDE__) && !defined(FLUTTER_LINUX_COMPILATION) -#error "Only can be included directly." -#endif - -#include - -#include "fl_dart_project.h" -#include "fl_engine.h" - -G_BEGIN_DECLS - -G_DECLARE_FINAL_TYPE(FlView, fl_view, FL, VIEW, GtkContainer) - -/** - * FlView: - * - * #FlView is a GTK widget that is capable of displaying a Flutter application. - * - * The following example shows how to set up a view in a GTK application: - * |[ - * FlDartProject *project = fl_dart_project_new (); - * FlView *view = fl_view_new (project); - * gtk_widget_show (GTK_WIDGET (view)); - * gtk_container_add (GTK_CONTAINER (parent), view); - * - * FlBinaryMessenger *messenger = - * fl_engine_get_binary_messenger (fl_view_get_engine (view)); - * setup_channels_or_plugins (messenger); - * ]| - */ - -/** - * fl_view_new: - * @project: The project to show. - * - * Creates a widget to show Flutter application. - * - * Returns: a new #FlView. - */ -FlView* fl_view_new(FlDartProject* project); - -/** - * fl_view_get_engine: - * @view: an #FlView. - * - * Gets the engine being rendered in the view. - * - * Returns: an #FlEngine. - */ -FlEngine* fl_view_get_engine(FlView* view); - -G_END_DECLS - -#endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_VIEW_H_ diff --git a/packages/fl_query_hooks/example/linux/flutter/ephemeral/flutter_linux/flutter_linux.h b/packages/fl_query_hooks/example/linux/flutter/ephemeral/flutter_linux/flutter_linux.h deleted file mode 100644 index 2d9317d..0000000 --- a/packages/fl_query_hooks/example/linux/flutter/ephemeral/flutter_linux/flutter_linux.h +++ /dev/null @@ -1,37 +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. - -#ifndef FLUTTER_SHELL_PLATFORM_LINUX_FLUTTER_LINUX_H_ -#define FLUTTER_SHELL_PLATFORM_LINUX_FLUTTER_LINUX_H_ - -#define __FLUTTER_LINUX_INSIDE__ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#undef __FLUTTER_LINUX_INSIDE__ - -#endif // FLUTTER_SHELL_PLATFORM_LINUX_FLUTTER_LINUX_H_ diff --git a/packages/fl_query_hooks/example/linux/flutter/ephemeral/generated_config.cmake b/packages/fl_query_hooks/example/linux/flutter/ephemeral/generated_config.cmake deleted file mode 100644 index 80e8c24..0000000 --- a/packages/fl_query_hooks/example/linux/flutter/ephemeral/generated_config.cmake +++ /dev/null @@ -1,21 +0,0 @@ -# Generated code do not commit. -file(TO_CMAKE_PATH "/opt/flutter" FLUTTER_ROOT) -file(TO_CMAKE_PATH "/home/krtirtho/dev/fl-query/packages/fl_query_hooks/example" PROJECT_DIR) - -set(FLUTTER_VERSION "1.0.0+1" PARENT_SCOPE) -set(FLUTTER_VERSION_MAJOR 1 PARENT_SCOPE) -set(FLUTTER_VERSION_MINOR 0 PARENT_SCOPE) -set(FLUTTER_VERSION_PATCH 0 PARENT_SCOPE) -set(FLUTTER_VERSION_BUILD 1 PARENT_SCOPE) - -# Environment variables to pass to tool_backend.sh -list(APPEND FLUTTER_TOOL_ENVIRONMENT - "FLUTTER_ROOT=/opt/flutter" - "PROJECT_DIR=/home/krtirtho/dev/fl-query/packages/fl_query_hooks/example" - "DART_DEFINES=RkxVVFRFUl9XRUJfQVVUT19ERVRFQ1Q9dHJ1ZQ==" - "DART_OBFUSCATION=false" - "TRACK_WIDGET_CREATION=true" - "TREE_SHAKE_ICONS=false" - "PACKAGE_CONFIG=/home/krtirtho/dev/fl-query/packages/fl_query_hooks/example/.dart_tool/package_config.json" - "FLUTTER_TARGET=/home/krtirtho/dev/fl-query/packages/fl_query_hooks/example/lib/main.dart" -) diff --git a/packages/fl_query_hooks/example/linux/flutter/ephemeral/icudtl.dat b/packages/fl_query_hooks/example/linux/flutter/ephemeral/icudtl.dat deleted file mode 100644 index 720a5c7..0000000 Binary files a/packages/fl_query_hooks/example/linux/flutter/ephemeral/icudtl.dat and /dev/null differ diff --git a/packages/fl_query_hooks/example/linux/flutter/ephemeral/libflutter_linux_gtk.so b/packages/fl_query_hooks/example/linux/flutter/ephemeral/libflutter_linux_gtk.so deleted file mode 100644 index 6ae4b7d..0000000 Binary files a/packages/fl_query_hooks/example/linux/flutter/ephemeral/libflutter_linux_gtk.so and /dev/null differ diff --git a/packages/fl_query_hooks/example/macos/Flutter/GeneratedPluginRegistrant.swift b/packages/fl_query_hooks/example/macos/Flutter/GeneratedPluginRegistrant.swift index be95aee..ec592a9 100644 --- a/packages/fl_query_hooks/example/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/packages/fl_query_hooks/example/macos/Flutter/GeneratedPluginRegistrant.swift @@ -5,8 +5,10 @@ import FlutterMacOS import Foundation -import connectivity_plus_macos +import connectivity_plus +import path_provider_foundation func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { ConnectivityPlugin.register(with: registry.registrar(forPlugin: "ConnectivityPlugin")) + PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) } diff --git a/packages/fl_query_hooks/example/macos/Flutter/ephemeral/Flutter-Generated.xcconfig b/packages/fl_query_hooks/example/macos/Flutter/ephemeral/Flutter-Generated.xcconfig deleted file mode 100644 index eb12cc6..0000000 --- a/packages/fl_query_hooks/example/macos/Flutter/ephemeral/Flutter-Generated.xcconfig +++ /dev/null @@ -1,11 +0,0 @@ -// This is a generated file; do not edit or check into version control. -FLUTTER_ROOT=/opt/flutter -FLUTTER_APPLICATION_PATH=/home/krtirtho/dev/fl-query/packages/fl_query_hooks/example -COCOAPODS_PARALLEL_CODE_SIGN=true -FLUTTER_BUILD_DIR=build -FLUTTER_BUILD_NAME=1.0.0 -FLUTTER_BUILD_NUMBER=1 -DART_OBFUSCATION=false -TRACK_WIDGET_CREATION=false -TREE_SHAKE_ICONS=false -PACKAGE_CONFIG=.dart_tool/package_config.json diff --git a/packages/fl_query_hooks/example/macos/Flutter/ephemeral/flutter_export_environment.sh b/packages/fl_query_hooks/example/macos/Flutter/ephemeral/flutter_export_environment.sh deleted file mode 100755 index 1ec1c91..0000000 --- a/packages/fl_query_hooks/example/macos/Flutter/ephemeral/flutter_export_environment.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh -# This is a generated file; do not edit or check into version control. -export "FLUTTER_ROOT=/opt/flutter" -export "FLUTTER_APPLICATION_PATH=/home/krtirtho/dev/fl-query/packages/fl_query_hooks/example" -export "COCOAPODS_PARALLEL_CODE_SIGN=true" -export "FLUTTER_BUILD_DIR=build" -export "FLUTTER_BUILD_NAME=1.0.0" -export "FLUTTER_BUILD_NUMBER=1" -export "DART_OBFUSCATION=false" -export "TRACK_WIDGET_CREATION=false" -export "TREE_SHAKE_ICONS=false" -export "PACKAGE_CONFIG=.dart_tool/package_config.json" diff --git a/packages/fl_query_hooks/example/macos/Runner.xcodeproj/project.pbxproj b/packages/fl_query_hooks/example/macos/Runner.xcodeproj/project.pbxproj index c84862c..d9333e4 100644 --- a/packages/fl_query_hooks/example/macos/Runner.xcodeproj/project.pbxproj +++ b/packages/fl_query_hooks/example/macos/Runner.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 51; + objectVersion = 54; objects = { /* Begin PBXAggregateTarget section */ @@ -235,6 +235,7 @@ /* Begin PBXShellScriptBuildPhase section */ 3399D490228B24CF009A79C7 /* ShellScript */ = { isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; buildActionMask = 2147483647; files = ( ); @@ -344,7 +345,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.11; + MACOSX_DEPLOYMENT_TARGET = 10.14; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = macosx; SWIFT_COMPILATION_MODE = wholemodule; @@ -423,7 +424,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.11; + MACOSX_DEPLOYMENT_TARGET = 10.14; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = macosx; @@ -470,7 +471,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.11; + MACOSX_DEPLOYMENT_TARGET = 10.14; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = macosx; SWIFT_COMPILATION_MODE = wholemodule; diff --git a/packages/fl_query_hooks/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png b/packages/fl_query_hooks/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png index 3c4935a..82b6f9d 100644 Binary files a/packages/fl_query_hooks/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png and b/packages/fl_query_hooks/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png differ diff --git a/packages/fl_query_hooks/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png b/packages/fl_query_hooks/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png index ed4cc16..13b35eb 100644 Binary files a/packages/fl_query_hooks/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png and b/packages/fl_query_hooks/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png differ diff --git a/packages/fl_query_hooks/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png b/packages/fl_query_hooks/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png index 483be61..0a3f5fa 100644 Binary files a/packages/fl_query_hooks/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png and b/packages/fl_query_hooks/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png differ diff --git a/packages/fl_query_hooks/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png b/packages/fl_query_hooks/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png index bcbf36d..bdb5722 100644 Binary files a/packages/fl_query_hooks/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png and b/packages/fl_query_hooks/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png differ diff --git a/packages/fl_query_hooks/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png b/packages/fl_query_hooks/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png index 9c0a652..f083318 100644 Binary files a/packages/fl_query_hooks/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png and b/packages/fl_query_hooks/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png differ diff --git a/packages/fl_query_hooks/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png b/packages/fl_query_hooks/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png index e71a726..326c0e7 100644 Binary files a/packages/fl_query_hooks/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png and b/packages/fl_query_hooks/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png differ diff --git a/packages/fl_query_hooks/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png b/packages/fl_query_hooks/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png index 8a31fe2..2f1632c 100644 Binary files a/packages/fl_query_hooks/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png and b/packages/fl_query_hooks/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png differ diff --git a/packages/fl_query_hooks/example/macos/Runner/Configs/AppInfo.xcconfig b/packages/fl_query_hooks/example/macos/Runner/Configs/AppInfo.xcconfig index 8b42559..dda192b 100644 --- a/packages/fl_query_hooks/example/macos/Runner/Configs/AppInfo.xcconfig +++ b/packages/fl_query_hooks/example/macos/Runner/Configs/AppInfo.xcconfig @@ -11,4 +11,4 @@ PRODUCT_NAME = example PRODUCT_BUNDLE_IDENTIFIER = com.example.example // The copyright displayed in application information -PRODUCT_COPYRIGHT = Copyright © 2022 com.example. All rights reserved. +PRODUCT_COPYRIGHT = Copyright © 2023 com.example. All rights reserved. diff --git a/packages/fl_query_hooks/example/pubspec.lock b/packages/fl_query_hooks/example/pubspec.lock index 678fc21..b1f3069 100644 --- a/packages/fl_query_hooks/example/pubspec.lock +++ b/packages/fl_query_hooks/example/pubspec.lock @@ -5,126 +5,112 @@ packages: dependency: transitive description: name: args - url: "https://pub.dartlang.org" + sha256: eef6c46b622e0494a36c5a12d10d77fb4e855501a91c1b9ef9339326e58f0596 + url: "https://pub.dev" source: hosted - version: "2.3.1" + version: "2.4.2" async: dependency: transitive description: name: async - url: "https://pub.dartlang.org" + sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" + url: "https://pub.dev" source: hosted - version: "2.9.0" + version: "2.11.0" boolean_selector: dependency: transitive description: name: boolean_selector - url: "https://pub.dartlang.org" + sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.1" characters: dependency: transitive description: name: characters - url: "https://pub.dartlang.org" + sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" + url: "https://pub.dev" source: hosted - version: "1.2.1" + version: "1.3.0" clock: dependency: transitive description: name: clock - url: "https://pub.dartlang.org" + sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf + url: "https://pub.dev" source: hosted version: "1.1.1" collection: dependency: transitive description: name: collection - url: "https://pub.dartlang.org" + sha256: f092b211a4319e98e5ff58223576de6c2803db36221657b46c82574721240687 + url: "https://pub.dev" source: hosted - version: "1.16.0" + version: "1.17.2" connectivity_plus: dependency: transitive description: name: connectivity_plus - url: "https://pub.dartlang.org" + sha256: "8599ae9edca5ff96163fca3e36f8e481ea917d1e71cdad912c084b5579913f34" + url: "https://pub.dev" source: hosted - version: "2.3.9" - connectivity_plus_linux: - dependency: transitive - description: - name: connectivity_plus_linux - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.1" - connectivity_plus_macos: - dependency: transitive - description: - name: connectivity_plus_macos - url: "https://pub.dartlang.org" - source: hosted - version: "1.2.4" + version: "4.0.1" connectivity_plus_platform_interface: dependency: transitive description: name: connectivity_plus_platform_interface - url: "https://pub.dartlang.org" + sha256: cf1d1c28f4416f8c654d7dc3cd638ec586076255d407cef3ddbdaf178272a71a + url: "https://pub.dev" source: hosted - version: "1.2.1" - connectivity_plus_web: - dependency: transitive - description: - name: connectivity_plus_web - url: "https://pub.dartlang.org" - source: hosted - version: "1.2.5" - connectivity_plus_windows: - dependency: transitive - description: - name: connectivity_plus_windows - url: "https://pub.dartlang.org" - source: hosted - version: "1.2.2" + version: "1.2.4" crypto: dependency: transitive description: name: crypto - url: "https://pub.dartlang.org" + sha256: aa274aa7774f8964e4f4f38cc994db7b6158dd36e9187aaceaddc994b35c6c67 + url: "https://pub.dev" source: hosted version: "3.0.2" cupertino_icons: dependency: "direct main" description: name: cupertino_icons - url: "https://pub.dartlang.org" + sha256: e35129dc44c9118cee2a5603506d823bab99c68393879edb440e0090d07586be + url: "https://pub.dev" source: hosted version: "1.0.5" dbus: dependency: transitive description: name: dbus - url: "https://pub.dartlang.org" + sha256: "6f07cba3f7b3448d42d015bfd3d53fe12e5b36da2423f23838efc1d5fb31a263" + url: "https://pub.dev" source: hosted - version: "0.7.7" + version: "0.7.8" fake_async: dependency: transitive description: name: fake_async - url: "https://pub.dartlang.org" + sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" + url: "https://pub.dev" source: hosted version: "1.3.1" ffi: dependency: transitive description: name: ffi - url: "https://pub.dartlang.org" + sha256: a38574032c5f1dd06c4aee541789906c12ccaab8ba01446e800d9c5b79c4a978 + url: "https://pub.dev" source: hosted version: "2.0.1" file: dependency: transitive description: name: file - url: "https://pub.dartlang.org" + sha256: "1b92bec4fc2a72f59a8e15af5f52cd441e4a7860b49499d69dfa817af20e925d" + url: "https://pub.dev" source: hosted version: "6.1.4" fl_query: @@ -133,14 +119,21 @@ packages: path: "../../fl_query" relative: true source: path - version: "0.3.1" + version: "1.0.0-alpha.4" + fl_query_connectivity_plus_adapter: + dependency: "direct main" + description: + path: "../../fl_query_connectivity_plus_adapter" + relative: true + source: path + version: "0.1.0-alpha.3" fl_query_hooks: dependency: "direct main" description: path: ".." relative: true source: path - version: "0.3.1" + version: "1.0.0-alpha.4+1" flutter: dependency: "direct main" description: flutter @@ -150,14 +143,16 @@ packages: dependency: "direct main" description: name: flutter_hooks - url: "https://pub.dartlang.org" + sha256: "4618087243264d5f745b2a719a9fc610768f723da570efc2d0eaefe1efcbae70" + url: "https://pub.dev" source: hosted - version: "0.18.5+1" + version: "0.20.2" flutter_lints: dependency: "direct dev" description: name: flutter_lints - url: "https://pub.dartlang.org" + sha256: aeb0b80a8b3709709c9cc496cdc027c5b3216796bc0af0ce1007eaf24464fd4c + url: "https://pub.dev" source: hosted version: "2.0.1" flutter_test: @@ -170,167 +165,198 @@ packages: description: flutter source: sdk version: "0.0.0" + go_router: + dependency: "direct main" + description: + name: go_router + sha256: b4bb06205ec607278b6fc23db238278417bca84a3905779cc68d1eb7afae37e2 + url: "https://pub.dev" + source: hosted + version: "6.2.0" hive: dependency: transitive description: name: hive - url: "https://pub.dartlang.org" + sha256: "8dcf6db979d7933da8217edcec84e9df1bdb4e4edc7fc77dbd5aa74356d6d941" + url: "https://pub.dev" source: hosted version: "2.2.3" hive_flutter: dependency: transitive description: name: hive_flutter - url: "https://pub.dartlang.org" + sha256: dca1da446b1d808a51689fb5d0c6c9510c0a2ba01e22805d492c73b68e33eecc + url: "https://pub.dev" source: hosted version: "1.1.0" http: dependency: "direct main" description: name: http - url: "https://pub.dartlang.org" + sha256: "6aa2946395183537c8b880962d935877325d6a09a2867c3970c05c0fed6ac482" + url: "https://pub.dev" source: hosted version: "0.13.5" http_parser: dependency: transitive description: name: http_parser - url: "https://pub.dartlang.org" + sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b" + url: "https://pub.dev" source: hosted - version: "4.0.1" + version: "4.0.2" js: dependency: transitive description: name: js - url: "https://pub.dartlang.org" + sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3 + url: "https://pub.dev" source: hosted - version: "0.6.4" + version: "0.6.7" lints: dependency: transitive description: name: lints - url: "https://pub.dartlang.org" + sha256: "5e4a9cd06d447758280a8ac2405101e0e2094d2a1dbdd3756aec3fe7775ba593" + url: "https://pub.dev" source: hosted - version: "2.0.0" + version: "2.0.1" + logging: + dependency: transitive + description: + name: logging + sha256: "04094f2eb032cbb06c6f6e8d3607edcfcb0455e2bb6cbc010cb01171dcb64e6d" + url: "https://pub.dev" + source: hosted + version: "1.1.1" matcher: dependency: transitive description: name: matcher - url: "https://pub.dartlang.org" + sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e" + url: "https://pub.dev" source: hosted - version: "0.12.12" + version: "0.12.16" material_color_utilities: dependency: transitive description: name: material_color_utilities - url: "https://pub.dartlang.org" + sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41" + url: "https://pub.dev" source: hosted - version: "0.1.5" + version: "0.5.0" meta: dependency: transitive description: name: meta - url: "https://pub.dartlang.org" + sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" + url: "https://pub.dev" source: hosted - version: "1.8.0" + version: "1.9.1" + mutex: + dependency: transitive + description: + name: mutex + sha256: "03116a4e46282a671b46c12de649d72c0ed18188ffe12a8d0fc63e83f4ad88f4" + url: "https://pub.dev" + source: hosted + version: "3.0.1" nm: dependency: transitive description: name: nm - url: "https://pub.dartlang.org" + sha256: "2c9aae4127bdc8993206464fcc063611e0e36e72018696cd9631023a31b24254" + url: "https://pub.dev" source: hosted version: "0.5.0" path: dependency: transitive description: name: path - url: "https://pub.dartlang.org" + sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" + url: "https://pub.dev" source: hosted - version: "1.8.2" + version: "1.8.3" path_provider: dependency: transitive description: name: path_provider - url: "https://pub.dartlang.org" + sha256: "04890b994ee89bfa80bf3080bfec40d5a92c5c7a785ebb02c13084a099d2b6f9" + url: "https://pub.dev" source: hosted - version: "2.0.11" + version: "2.0.13" path_provider_android: dependency: transitive description: name: path_provider_android - url: "https://pub.dartlang.org" + sha256: "7623b7d4be0f0f7d9a8b5ee6879fc13e4522d4c875ab86801dee4af32b54b83e" + url: "https://pub.dev" source: hosted - version: "2.0.22" - path_provider_ios: + version: "2.0.23" + path_provider_foundation: dependency: transitive description: - name: path_provider_ios - url: "https://pub.dartlang.org" + name: path_provider_foundation + sha256: eec003594f19fe2456ea965ae36b3fc967bc5005f508890aafe31fa75e41d972 + url: "https://pub.dev" source: hosted - version: "2.0.11" + version: "2.1.2" path_provider_linux: dependency: transitive description: name: path_provider_linux - url: "https://pub.dartlang.org" + sha256: "525ad5e07622d19447ad740b1ed5070031f7a5437f44355ae915ff56e986429a" + url: "https://pub.dev" source: hosted - version: "2.1.7" - path_provider_macos: - dependency: transitive - description: - name: path_provider_macos - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.6" + version: "2.1.9" path_provider_platform_interface: dependency: transitive description: name: path_provider_platform_interface - url: "https://pub.dartlang.org" + sha256: "57585299a729335f1298b43245842678cb9f43a6310351b18fb577d6e33165ec" + url: "https://pub.dev" source: hosted - version: "2.0.5" + version: "2.0.6" path_provider_windows: dependency: transitive description: name: path_provider_windows - url: "https://pub.dartlang.org" + sha256: "642ddf65fde5404f83267e8459ddb4556316d3ee6d511ed193357e25caa3632d" + url: "https://pub.dev" source: hosted - version: "2.1.3" + version: "2.1.4" petitparser: dependency: transitive description: name: petitparser - url: "https://pub.dartlang.org" + sha256: cb3798bef7fc021ac45b308f4b51208a152792445cce0448c9a4ba5879dd8750 + url: "https://pub.dev" source: hosted - version: "5.0.0" + version: "5.4.0" platform: dependency: transitive description: name: platform - url: "https://pub.dartlang.org" + sha256: "4a451831508d7d6ca779f7ac6e212b4023dd5a7d08a27a63da33756410e32b76" + url: "https://pub.dev" source: hosted version: "3.1.0" plugin_platform_interface: dependency: transitive description: name: plugin_platform_interface - url: "https://pub.dartlang.org" + sha256: "6a2128648c854906c53fa8e33986fc0247a1116122f9534dd20e3ab9e16a32bc" + url: "https://pub.dev" source: hosted - version: "2.1.2" + version: "2.1.4" process: dependency: transitive description: name: process - url: "https://pub.dartlang.org" + sha256: "53fd8db9cec1d37b0574e12f07520d582019cb6c44abf5479a01505099a34a09" + url: "https://pub.dev" source: hosted version: "4.2.4" - queue: - dependency: transitive - description: - name: queue - url: "https://pub.dartlang.org" - source: hosted - version: "3.1.0+1" sky_engine: dependency: transitive description: flutter @@ -340,86 +366,106 @@ packages: dependency: transitive description: name: source_span - url: "https://pub.dartlang.org" + sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" + url: "https://pub.dev" source: hosted - version: "1.9.0" + version: "1.10.0" stack_trace: dependency: transitive description: name: stack_trace - url: "https://pub.dartlang.org" + sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 + url: "https://pub.dev" source: hosted - version: "1.10.0" + version: "1.11.0" + state_notifier: + dependency: transitive + description: + name: state_notifier + sha256: "8fe42610f179b843b12371e40db58c9444f8757f8b69d181c97e50787caed289" + url: "https://pub.dev" + source: hosted + version: "0.7.2+1" stream_channel: dependency: transitive description: name: stream_channel - url: "https://pub.dartlang.org" + sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.1" string_scanner: dependency: transitive description: name: string_scanner - url: "https://pub.dartlang.org" + sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" + url: "https://pub.dev" source: hosted - version: "1.1.1" + version: "1.2.0" term_glyph: dependency: transitive description: name: term_glyph - url: "https://pub.dartlang.org" + sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 + url: "https://pub.dev" source: hosted version: "1.2.1" test_api: dependency: transitive description: name: test_api - url: "https://pub.dartlang.org" + sha256: "75760ffd7786fffdfb9597c35c5b27eaeec82be8edfb6d71d32651128ed7aab8" + url: "https://pub.dev" source: hosted - version: "0.4.12" + version: "0.6.0" typed_data: dependency: transitive description: name: typed_data - url: "https://pub.dartlang.org" + sha256: "26f87ade979c47a150c9eaab93ccd2bebe70a27dc0b4b29517f2904f04eb11a5" + url: "https://pub.dev" source: hosted version: "1.3.1" - uuid: - dependency: transitive - description: - name: uuid - url: "https://pub.dartlang.org" - source: hosted - version: "3.0.6" vector_math: dependency: transitive description: name: vector_math - url: "https://pub.dartlang.org" + sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" + url: "https://pub.dev" source: hosted - version: "2.1.2" + version: "2.1.4" + web: + dependency: transitive + description: + name: web + sha256: dc8ccd225a2005c1be616fe02951e2e342092edf968cf0844220383757ef8f10 + url: "https://pub.dev" + source: hosted + version: "0.1.4-beta" win32: dependency: transitive description: name: win32 - url: "https://pub.dartlang.org" + sha256: c9ebe7ee4ab0c2194e65d3a07d8c54c5d00bb001b76081c4a04cdb8448b59e46 + url: "https://pub.dev" source: hosted - version: "3.1.2" + version: "3.1.3" xdg_directories: dependency: transitive description: name: xdg_directories - url: "https://pub.dartlang.org" + sha256: ee1505df1426458f7f60aac270645098d318a8b4766d85fde75f76f2e21807d1 + url: "https://pub.dev" source: hosted - version: "0.2.0+2" + version: "1.0.0" xml: dependency: transitive description: name: xml - url: "https://pub.dartlang.org" + sha256: "5bc72e1e45e941d825fd7468b9b4cc3b9327942649aeb6fc5cdbf135f0a86e84" + url: "https://pub.dev" source: hosted - version: "6.1.0" + version: "6.3.0" sdks: - dart: ">=2.17.1 <3.0.0" - flutter: ">=3.0.0" + dart: ">=3.1.0-185.0.dev <4.0.0" + flutter: ">=3.3.0" diff --git a/packages/fl_query_hooks/example/pubspec.yaml b/packages/fl_query_hooks/example/pubspec.yaml index 20e843b..95b08e5 100644 --- a/packages/fl_query_hooks/example/pubspec.yaml +++ b/packages/fl_query_hooks/example/pubspec.yaml @@ -1,93 +1,30 @@ name: fl_query_hooks_example description: A new Flutter project. -# The following line prevents the package from being accidentally published to -# pub.dev using `flutter pub publish`. This is preferred for private packages. -publish_to: 'none' # Remove this line if you wish to publish to pub.dev - -# The following defines the version and build number for your application. -# A version number is three numbers separated by dots, like 1.2.43 -# followed by an optional build number separated by a +. -# Both the version and the builder number may be overridden in flutter -# build by specifying --build-name and --build-number, respectively. -# In Android, build-name is used as versionName while build-number used as versionCode. -# Read more about Android versioning at https://developer.android.com/studio/publish/versioning -# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. -# Read more about iOS versioning at -# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html version: 1.0.0+1 -environment: - sdk: ">=2.17.1 <3.0.0" +publish_to: none + +environment: + sdk: ">=2.19.2 <3.0.0" -# Dependencies specify other packages that your package needs in order to work. -# To automatically upgrade your package dependencies to the latest versions -# consider running `flutter pub upgrade --major-versions`. Alternatively, -# dependencies can be manually updated by changing the version numbers below to -# the latest version available on pub.dev. To see which dependencies have newer -# versions available, run `flutter pub outdated`. dependencies: flutter: sdk: flutter - - # The following adds the Cupertino Icons font to your application. - # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.2 - fl_query: ^0.2.0 - fl_query_hooks: ^0.2.0 - flutter_hooks: ^0.18.5+1 + fl_query: ^1.0.0-alpha.5 + fl_query_connectivity_plus_adapter: ^0.1.0-alpha.4 + fl_query_hooks: ^1.0.0-alpha.5 + go_router: ^6.0.9 http: ^0.13.5 + flutter_hooks: ^0.20.0 dev_dependencies: flutter_test: sdk: flutter - # The "flutter_lints" package below contains a set of recommended lints to - # encourage good coding practices. The lint set provided by the package is - # activated in the `analysis_options.yaml` file located at the root of your - # package. See that file for information about deactivating specific lint - # rules and activating additional ones. flutter_lints: ^2.0.0 -# For information on the generic Dart part of this file, see the -# following page: https://dart.dev/tools/pub/pubspec - -# The following section is specific to Flutter packages. flutter: - - # The following line ensures that the Material Icons font is - # included with your application, so that you can use the icons in - # the material Icons class. uses-material-design: true - - # To add assets to your application, add an assets section, like this: - # assets: - # - images/a_dot_burr.jpeg - # - images/a_dot_ham.jpeg - - # An image asset can refer to one or more resolution-specific "variants", see - # https://flutter.dev/assets-and-images/#resolution-aware - - # For details regarding adding assets from package dependencies, see - # https://flutter.dev/assets-and-images/#from-packages - - # To add custom fonts to your application, add a fonts section here, - # in this "flutter" section. Each entry in this list should have a - # "family" key with the font family name, and a "fonts" key with a - # list giving the asset and other descriptors for the font. For - # example: - # fonts: - # - family: Schyler - # fonts: - # - asset: fonts/Schyler-Regular.ttf - # - asset: fonts/Schyler-Italic.ttf - # style: italic - # - family: Trajan Pro - # fonts: - # - asset: fonts/TrajanPro.ttf - # - asset: fonts/TrajanPro_Bold.ttf - # weight: 700 - # - # For details regarding fonts from package dependencies, - # see https://flutter.dev/custom-fonts/#from-packages diff --git a/packages/fl_query_hooks/example/pubspec_overrides.yaml b/packages/fl_query_hooks/example/pubspec_overrides.yaml new file mode 100644 index 0000000..f31a131 --- /dev/null +++ b/packages/fl_query_hooks/example/pubspec_overrides.yaml @@ -0,0 +1,8 @@ +# melos_managed_dependency_overrides: fl_query,fl_query_hooks,fl_query_connectivity_plus_adapter +dependency_overrides: + fl_query: + path: ../../fl_query + fl_query_connectivity_plus_adapter: + path: ../../fl_query_connectivity_plus_adapter + fl_query_hooks: + path: .. diff --git a/packages/fl_query_hooks/example/web/index.html b/packages/fl_query_hooks/example/web/index.html index 41b3bc3..be820e8 100644 --- a/packages/fl_query_hooks/example/web/index.html +++ b/packages/fl_query_hooks/example/web/index.html @@ -46,11 +46,12 @@ _flutter.loader.loadEntrypoint({ serviceWorker: { serviceWorkerVersion: serviceWorkerVersion, + }, + onEntrypointLoaded: function(engineInitializer) { + engineInitializer.initializeEngine().then(function(appRunner) { + appRunner.runApp(); + }); } - }).then(function(engineInitializer) { - return engineInitializer.initializeEngine(); - }).then(function(appRunner) { - return appRunner.runApp(); }); }); diff --git a/packages/fl_query_hooks/example/windows/flutter/ephemeral/.plugin_symlinks/connectivity_plus_windows b/packages/fl_query_hooks/example/windows/flutter/ephemeral/.plugin_symlinks/connectivity_plus_windows deleted file mode 120000 index f0db25a..0000000 --- a/packages/fl_query_hooks/example/windows/flutter/ephemeral/.plugin_symlinks/connectivity_plus_windows +++ /dev/null @@ -1 +0,0 @@ -/opt/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_windows-1.2.2/ \ No newline at end of file diff --git a/packages/fl_query_hooks/example/windows/flutter/generated_plugin_registrant.cc b/packages/fl_query_hooks/example/windows/flutter/generated_plugin_registrant.cc index 8083d74..8777c93 100644 --- a/packages/fl_query_hooks/example/windows/flutter/generated_plugin_registrant.cc +++ b/packages/fl_query_hooks/example/windows/flutter/generated_plugin_registrant.cc @@ -6,7 +6,7 @@ #include "generated_plugin_registrant.h" -#include +#include void RegisterPlugins(flutter::PluginRegistry* registry) { ConnectivityPlusWindowsPluginRegisterWithRegistrar( diff --git a/packages/fl_query_hooks/example/windows/flutter/generated_plugins.cmake b/packages/fl_query_hooks/example/windows/flutter/generated_plugins.cmake index 8cf5d42..cc1361d 100644 --- a/packages/fl_query_hooks/example/windows/flutter/generated_plugins.cmake +++ b/packages/fl_query_hooks/example/windows/flutter/generated_plugins.cmake @@ -3,7 +3,7 @@ # list(APPEND FLUTTER_PLUGIN_LIST - connectivity_plus_windows + connectivity_plus ) list(APPEND FLUTTER_FFI_PLUGIN_LIST diff --git a/packages/fl_query_hooks/example/windows/runner/CMakeLists.txt b/packages/fl_query_hooks/example/windows/runner/CMakeLists.txt index b9e550f..394917c 100644 --- a/packages/fl_query_hooks/example/windows/runner/CMakeLists.txt +++ b/packages/fl_query_hooks/example/windows/runner/CMakeLists.txt @@ -20,12 +20,20 @@ add_executable(${BINARY_NAME} WIN32 # that need different build settings. apply_standard_settings(${BINARY_NAME}) +# Add preprocessor definitions for the build version. +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"") +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}") +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}") +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}") +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}") + # Disable Windows macros that collide with C++ standard library functions. target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") # Add dependency libraries and include directories. Add any application-specific # dependencies here. target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) +target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib") target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") # Run the Flutter tool portions of the build. This must not be removed. diff --git a/packages/fl_query_hooks/example/windows/runner/Runner.rc b/packages/fl_query_hooks/example/windows/runner/Runner.rc index 5fdea29..aecaa2b 100644 --- a/packages/fl_query_hooks/example/windows/runner/Runner.rc +++ b/packages/fl_query_hooks/example/windows/runner/Runner.rc @@ -60,14 +60,14 @@ IDI_APP_ICON ICON "resources\\app_icon.ico" // Version // -#ifdef FLUTTER_BUILD_NUMBER -#define VERSION_AS_NUMBER FLUTTER_BUILD_NUMBER +#if defined(FLUTTER_VERSION_MAJOR) && defined(FLUTTER_VERSION_MINOR) && defined(FLUTTER_VERSION_PATCH) && defined(FLUTTER_VERSION_BUILD) +#define VERSION_AS_NUMBER FLUTTER_VERSION_MAJOR,FLUTTER_VERSION_MINOR,FLUTTER_VERSION_PATCH,FLUTTER_VERSION_BUILD #else -#define VERSION_AS_NUMBER 1,0,0 +#define VERSION_AS_NUMBER 1,0,0,0 #endif -#ifdef FLUTTER_BUILD_NAME -#define VERSION_AS_STRING #FLUTTER_BUILD_NAME +#if defined(FLUTTER_VERSION) +#define VERSION_AS_STRING FLUTTER_VERSION #else #define VERSION_AS_STRING "1.0.0" #endif @@ -93,7 +93,7 @@ BEGIN VALUE "FileDescription", "example" "\0" VALUE "FileVersion", VERSION_AS_STRING "\0" VALUE "InternalName", "example" "\0" - VALUE "LegalCopyright", "Copyright (C) 2022 com.example. All rights reserved." "\0" + VALUE "LegalCopyright", "Copyright (C) 2023 com.example. All rights reserved." "\0" VALUE "OriginalFilename", "example.exe" "\0" VALUE "ProductName", "example" "\0" VALUE "ProductVersion", VERSION_AS_STRING "\0" diff --git a/packages/fl_query_hooks/example/windows/runner/flutter_window.cpp b/packages/fl_query_hooks/example/windows/runner/flutter_window.cpp index b43b909..b25e363 100644 --- a/packages/fl_query_hooks/example/windows/runner/flutter_window.cpp +++ b/packages/fl_query_hooks/example/windows/runner/flutter_window.cpp @@ -26,6 +26,11 @@ bool FlutterWindow::OnCreate() { } RegisterPlugins(flutter_controller_->engine()); SetChildContent(flutter_controller_->view()->GetNativeWindow()); + + flutter_controller_->engine()->SetNextFrameCallback([&]() { + this->Show(); + }); + return true; } diff --git a/packages/fl_query_hooks/example/windows/runner/main.cpp b/packages/fl_query_hooks/example/windows/runner/main.cpp index bcb57b0..a61bf80 100644 --- a/packages/fl_query_hooks/example/windows/runner/main.cpp +++ b/packages/fl_query_hooks/example/windows/runner/main.cpp @@ -27,7 +27,7 @@ int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, FlutterWindow window(project); Win32Window::Point origin(10, 10); Win32Window::Size size(1280, 720); - if (!window.CreateAndShow(L"example", origin, size)) { + if (!window.Create(L"example", origin, size)) { return EXIT_FAILURE; } window.SetQuitOnClose(true); diff --git a/packages/fl_query_hooks/example/windows/runner/runner.exe.manifest b/packages/fl_query_hooks/example/windows/runner/runner.exe.manifest index c977c4a..a42ea76 100644 --- a/packages/fl_query_hooks/example/windows/runner/runner.exe.manifest +++ b/packages/fl_query_hooks/example/windows/runner/runner.exe.manifest @@ -7,7 +7,7 @@ - + diff --git a/packages/fl_query_hooks/example/windows/runner/win32_window.cpp b/packages/fl_query_hooks/example/windows/runner/win32_window.cpp index c10f08d..041a385 100644 --- a/packages/fl_query_hooks/example/windows/runner/win32_window.cpp +++ b/packages/fl_query_hooks/example/windows/runner/win32_window.cpp @@ -1,13 +1,31 @@ #include "win32_window.h" +#include #include #include "resource.h" namespace { +/// Window attribute that enables dark mode window decorations. +/// +/// Redefined in case the developer's machine has a Windows SDK older than +/// version 10.0.22000.0. +/// See: https://docs.microsoft.com/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattribute +#ifndef DWMWA_USE_IMMERSIVE_DARK_MODE +#define DWMWA_USE_IMMERSIVE_DARK_MODE 20 +#endif + constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW"; +/// Registry key for app theme preference. +/// +/// A value of 0 indicates apps should use dark mode. A non-zero or missing +/// value indicates apps should use light mode. +constexpr const wchar_t kGetPreferredBrightnessRegKey[] = + L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize"; +constexpr const wchar_t kGetPreferredBrightnessRegValue[] = L"AppsUseLightTheme"; + // The number of Win32Window objects that currently exist. static int g_active_window_count = 0; @@ -31,8 +49,8 @@ void EnableFullDpiSupportIfAvailable(HWND hwnd) { GetProcAddress(user32_module, "EnableNonClientDpiScaling")); if (enable_non_client_dpi_scaling != nullptr) { enable_non_client_dpi_scaling(hwnd); - FreeLibrary(user32_module); } + FreeLibrary(user32_module); } } // namespace @@ -102,9 +120,9 @@ Win32Window::~Win32Window() { Destroy(); } -bool Win32Window::CreateAndShow(const std::wstring& title, - const Point& origin, - const Size& size) { +bool Win32Window::Create(const std::wstring& title, + const Point& origin, + const Size& size) { Destroy(); const wchar_t* window_class = @@ -117,7 +135,7 @@ bool Win32Window::CreateAndShow(const std::wstring& title, double scale_factor = dpi / 96.0; HWND window = CreateWindow( - window_class, title.c_str(), WS_OVERLAPPEDWINDOW | WS_VISIBLE, + window_class, title.c_str(), WS_OVERLAPPEDWINDOW, Scale(origin.x, scale_factor), Scale(origin.y, scale_factor), Scale(size.width, scale_factor), Scale(size.height, scale_factor), nullptr, nullptr, GetModuleHandle(nullptr), this); @@ -126,9 +144,15 @@ bool Win32Window::CreateAndShow(const std::wstring& title, return false; } + UpdateTheme(window); + return OnCreate(); } +bool Win32Window::Show() { + return ShowWindow(window_handle_, SW_SHOWNORMAL); +} + // static LRESULT CALLBACK Win32Window::WndProc(HWND const window, UINT const message, @@ -188,6 +212,10 @@ Win32Window::MessageHandler(HWND hwnd, SetFocus(child_content_); } return 0; + + case WM_DWMCOLORIZATIONCOLORCHANGED: + UpdateTheme(hwnd); + return 0; } return DefWindowProc(window_handle_, message, wparam, lparam); @@ -243,3 +271,18 @@ bool Win32Window::OnCreate() { void Win32Window::OnDestroy() { // No-op; provided for subclasses. } + +void Win32Window::UpdateTheme(HWND const window) { + DWORD light_mode; + DWORD light_mode_size = sizeof(light_mode); + LSTATUS result = RegGetValue(HKEY_CURRENT_USER, kGetPreferredBrightnessRegKey, + kGetPreferredBrightnessRegValue, + RRF_RT_REG_DWORD, nullptr, &light_mode, + &light_mode_size); + + if (result == ERROR_SUCCESS) { + BOOL enable_dark_mode = light_mode == 0; + DwmSetWindowAttribute(window, DWMWA_USE_IMMERSIVE_DARK_MODE, + &enable_dark_mode, sizeof(enable_dark_mode)); + } +} diff --git a/packages/fl_query_hooks/example/windows/runner/win32_window.h b/packages/fl_query_hooks/example/windows/runner/win32_window.h index 17ba431..c86632d 100644 --- a/packages/fl_query_hooks/example/windows/runner/win32_window.h +++ b/packages/fl_query_hooks/example/windows/runner/win32_window.h @@ -28,15 +28,16 @@ class Win32Window { Win32Window(); virtual ~Win32Window(); - // Creates and shows a win32 window with |title| and position and size using + // Creates a win32 window with |title| that is positioned and sized using // |origin| and |size|. New windows are created on the default monitor. Window // sizes are specified to the OS in physical pixels, hence to ensure a - // consistent size to will treat the width height passed in to this function - // as logical pixels and scale to appropriate for the default monitor. Returns - // true if the window was created successfully. - bool CreateAndShow(const std::wstring& title, - const Point& origin, - const Size& size); + // consistent size this function will scale the inputted width and height as + // as appropriate for the default monitor. The window is invisible until + // |Show| is called. Returns true if the window was created successfully. + bool Create(const std::wstring& title, const Point& origin, const Size& size); + + // Show the current window. Returns true if the window was successfully shown. + bool Show(); // Release OS resources associated with window. void Destroy(); @@ -86,6 +87,9 @@ class Win32Window { // Retrieves a class instance pointer for |window| static Win32Window* GetThisFromHandle(HWND const window) noexcept; + // Update the window frame's theme to match the system theme. + static void UpdateTheme(HWND const window); + bool quit_on_close_ = false; // window handle for top level window. diff --git a/packages/fl_query_hooks/lib/fl_query_hooks.dart b/packages/fl_query_hooks/lib/fl_query_hooks.dart index 0629187..deb579d 100644 --- a/packages/fl_query_hooks/lib/fl_query_hooks.dart +++ b/packages/fl_query_hooks/lib/fl_query_hooks.dart @@ -1,5 +1,6 @@ library fl_query_hooks; +export 'src/use_query_client.dart'; export 'src/use_query.dart'; -export 'src/use_mutation.dart'; export 'src/use_infinite_query.dart'; +export 'src/use_mutation.dart'; diff --git a/packages/fl_query_hooks/lib/src/use_infinite_query.dart b/packages/fl_query_hooks/lib/src/use_infinite_query.dart index f411f71..469f2b8 100644 --- a/packages/fl_query_hooks/lib/src/use_infinite_query.dart +++ b/packages/fl_query_hooks/lib/src/use_infinite_query.dart @@ -1,141 +1,74 @@ -// ignore_for_file: invalid_use_of_protected_member +import 'dart:async'; import 'package:fl_query/fl_query.dart'; -import 'package:fl_query_hooks/src/utils.dart'; -import 'package:flutter/widgets.dart'; +import 'package:fl_query_hooks/src/use_query_client.dart'; +import 'package:fl_query_hooks/src/utils/use_updater.dart'; +import 'package:flutter/material.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; -InfiniteQuery - useInfiniteQuery({ - required InfiniteQueryJob job, - required Outside externalData, - - /// Called when the query returns new data, on query - /// refetch or query gets expired - final InfiniteQueryListeners? onData, - - /// Called when the query returns error - final InfiniteQueryListeners? onError, +InfiniteQuery + useInfiniteQuery( + String queryKey, + InfiniteQueryFn queryFn, { + required InfiniteQueryNextPage nextPage, + required PageType initialPage, + RetryConfig? retryConfig, + RefreshConfig? refreshConfig, + JsonConfig? jsonConfig, + ValueChanged>? onData, + ValueChanged>? onError, + bool enabled = true, List? keys, }) { - final context = useContext(); - final mounted = useIsMounted(); - final update = useForceUpdate(); - final QueryBowl queryBowl = QueryBowl.of(context); - final ValueKey uKey = useMemoized(() => ValueKey(uuid.v4()), []); - final infiniteQuery = useRef( - useMemoized( - () => queryBowl.addInfiniteQuery( - job, - externalData: externalData, - key: uKey, - onData: onData, - onError: onError, - ), - [], - ), - ); - - final oldJob = usePrevious(job); - final oldExternalData = usePrevious(externalData); - final oldOnData = usePrevious(onData); - final oldOnError = usePrevious(onError); - - final init = useCallback(([T? previousData]) { - final hasExternalDataChanged = !isShallowEqual( - infiniteQuery.value.externalData, - infiniteQuery.value.prevUsedExternalData); - infiniteQuery.value = queryBowl.addInfiniteQuery( - job, - externalData: externalData, - key: uKey, - onData: onData, - onError: onError, + final rebuild = useUpdater(); + final client = useQueryClient(); + final query = useMemoized>(() { + final query = client.createInfiniteQuery( + queryKey, + queryFn, + initialParam: initialPage, + nextPage: nextPage, + jsonConfig: jsonConfig, + refreshConfig: refreshConfig, + retryConfig: retryConfig, ); - update(); - if (infiniteQuery.value.fetched && hasExternalDataChanged) { - infiniteQuery.value.refetchPages(); - } else if (!infiniteQuery.value.fetched) { - infiniteQuery.value.fetch(); + return query; + }, [queryKey]); + + useEffect(() { + final removeListener = query.addListener(rebuild); + if (enabled) { + query.fetch(); } - }, [ - queryBowl, - infiniteQuery.value, - uKey, - job, - externalData, - onData, - onError, - ]); - - final disposeQuery = useCallback(() { - infiniteQuery.value.unmount(uKey); - if (onData != null) infiniteQuery.value.removeDataListener(onData); - if (onError != null) infiniteQuery.value.removeErrorListener(onError); - }, [ - infiniteQuery.value, - uKey, - onData, - onError, - ]); + return removeListener; + }, [query, enabled]); useEffect(() { - WidgetsBinding.instance.addPostFrameCallback((_) { - init(); - QueryBowl.of(context).onInfiniteQueriesUpdate( - (newInfiniteQuery) async { - if (newInfiniteQuery.queryKey != job.queryKey || !mounted()) return; - infiniteQuery.value = newInfiniteQuery; - if (!infiniteQuery.value.fetched && - infiniteQuery.value.isCachedData) { - await infiniteQuery.value.refetchPages(); - } - update(); - }, - ); - }); - return disposeQuery; - }, []); - - useEffect(() { - WidgetsBinding.instance.addPostFrameCallback((_) { - final hasOnErrorChanged = oldOnError != onError && oldOnError != null; - final hasOnDataChanged = oldOnData != onData && oldOnData != null; - if (oldJob != null && oldJob.queryKey != job.queryKey) { - disposeQuery(); - init(); - } else if (!isShallowEqual(oldExternalData, externalData)) { - if (job.refetchOnExternalDataChange ?? - queryBowl.refetchOnExternalDataChange) { - QueryBowl.of(context).addInfiniteQuery( - job, - externalData: externalData, - key: uKey, - onData: onData, - onError: onError, - )..refetchPages(); - } else { - QueryBowl.of(context) - .getQuery(job.queryKey) - ?.setExternalData(externalData); - } - - if (hasOnDataChanged) infiniteQuery.value.removeDataListener(oldOnData); - if (hasOnErrorChanged) - infiniteQuery.value.removeErrorListener(oldOnError); - } else { - if (hasOnDataChanged) { - infiniteQuery.value.removeDataListener(oldOnData); - if (onData != null) infiniteQuery.value.addDataListener(onData); - } - if (hasOnErrorChanged) { - infiniteQuery.value.removeErrorListener(oldOnError); - if (onError != null) infiniteQuery.value.addErrorListener(onError); - } - } - }); + query.updateQueryFn(queryFn); return null; - }); + }, [queryFn, query]); - return infiniteQuery.value; + useEffect(() { + query.updateNextPageFn(nextPage); + return null; + }, [nextPage, query]); + + useEffect(() { + StreamSubscription>? dataSubscription; + StreamSubscription>? errorSubscription; + + if (onData != null) { + dataSubscription = query.dataStream.listen(onData); + } + if (onError != null) { + errorSubscription = query.errorStream.listen(onError); + } + + return () { + dataSubscription?.cancel(); + errorSubscription?.cancel(); + }; + }, [onData, onError, query]); + + return query; } diff --git a/packages/fl_query_hooks/lib/src/use_mutation.dart b/packages/fl_query_hooks/lib/src/use_mutation.dart index 90becf3..bf9fc9b 100644 --- a/packages/fl_query_hooks/lib/src/use_mutation.dart +++ b/packages/fl_query_hooks/lib/src/use_mutation.dart @@ -1,101 +1,84 @@ +import 'dart:async'; + import 'package:fl_query/fl_query.dart'; -import 'package:fl_query_hooks/src/utils.dart'; -import 'package:flutter/widgets.dart'; +import 'package:fl_query_hooks/src/use_query_client.dart'; +import 'package:fl_query_hooks/src/utils/use_updater.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; -Mutation useMutation({ - required MutationJob job, - - /// Called when the query returns new data, on query - /// refetch or query gets expired - MutationListener? onData, - - /// Called when the query returns error - MutationListener? onError, - - /// called right before the mutation is about to run - /// - /// perfect scenario for doing optimistic updates - MutationListenerReturnable? onMutate, +Mutation + useMutation( + String mutationKey, + MutationFn mutationFn, { + RetryConfig? retryConfig, + MutationOnDataFn? onData, + MutationOnErrorFn? onError, + MutationOnMutationFn? onMutate, + List? refreshQueries, + List? refreshInfiniteQueries, List? keys, }) { - final context = useContext(); final mounted = useIsMounted(); - final update = useForceUpdate(); - final QueryBowl queryBowl = QueryBowl.of(context); - final ValueKey uKey = useMemoized(() => ValueKey(uuid.v4()), []); - final mutation = useRef( - useMemoized( - () => queryBowl.addMutation( - job, - onData: onData, - onError: onError, - onMutate: onMutate, - key: uKey, - ), - [], - ), - ); - - final init = useCallback(() { - mutation.value = queryBowl.addMutation( - job, - onData: onData, - onError: onError, - onMutate: onMutate, - key: uKey, + final rebuild = useUpdater(); + final client = useQueryClient(); + final mutation = + useMemoized>(() { + return client.createMutation( + mutationKey, + mutationFn, + retryConfig: retryConfig, ); - update(); - }, [mutation.value, job, onData, onError, onMutate, uKey]); + }, [mutationKey]); - final disposeMutation = useCallback(() { - mutation.value.unmount(uKey); - if (onData != null) mutation.value.removeDataListener(onData); - if (onError != null) mutation.value.removeErrorListener(onError); - if (onMutate != null) mutation.value.removeMutateListener(onMutate); - }, [mutation.value, onData, onError, onMutate]); - - final oldJob = usePrevious(job); - final oldOnData = usePrevious(onData); - final oldOnError = usePrevious(onError); - final oldOnMutate = usePrevious(onMutate); + final recoveryData = useState(null); useEffect(() { - WidgetsBinding.instance.addPostFrameCallback((_) { - init(); - QueryBowl.of(context).onMutationsUpdate( - (newMutation) { - if (newMutation.mutationKey != job.mutationKey || !mounted()) return; - mutation.value = newMutation; - update(); + return mutation.addListener(rebuild); + }, [mutation]); + + useEffect(() { + mutation.updateMutationFn(mutationFn); + return null; + }, [mutationFn, mutation]); + + useEffect(() { + if (onMutate != null) { + return mutation.mutationStream.listen((event) async { + if (mounted()) { + recoveryData.value = await onMutate.call(event); + } + }).cancel; + } + return null; + }, [onMutate, mutation]); + + useEffect(() { + StreamSubscription? dataSubscription; + StreamSubscription? errorSubscription; + + dataSubscription = mutation.dataStream.listen((event) { + final data = onData?.call(event, recoveryData.value); + if (refreshQueries != null) { + client.refreshQueries(refreshQueries); + } + if (refreshInfiniteQueries != null) { + client.refreshInfiniteQueriesAllPages(refreshInfiniteQueries); + } + return data; + }); + + if (onError != null) { + errorSubscription = mutation.errorStream.listen( + (event) { + return onError(event, recoveryData.value); }, ); - }); - return disposeMutation; - }, []); + } - useEffect(() { - WidgetsBinding.instance.addPostFrameCallback((_) { - if (oldJob != null && oldJob.mutationKey != job.mutationKey) { - disposeMutation(); - init(); - } else { - if (oldOnData != onData && oldOnData != null) { - mutation.value.removeDataListener(oldOnData); - if (onData != null) mutation.value.addDataListener(onData); - } - if (oldOnError != onError && oldOnError != null) { - mutation.value.removeErrorListener(oldOnError); - if (onError != null) mutation.value.addErrorListener(onError); - } - if (oldOnMutate != onMutate && oldOnMutate != null) { - mutation.value.removeMutateListener(oldOnMutate); - if (onMutate != null) mutation.value.addMutateListener(onMutate); - } - } - }); - return null; - }); + return () { + dataSubscription?.cancel(); + errorSubscription?.cancel(); + }; + }, [onData, onError, recoveryData.value, mutation]); - return mutation.value; + return mutation; } diff --git a/packages/fl_query_hooks/lib/src/use_query.dart b/packages/fl_query_hooks/lib/src/use_query.dart index 4b20d7e..9097545 100644 --- a/packages/fl_query_hooks/lib/src/use_query.dart +++ b/packages/fl_query_hooks/lib/src/use_query.dart @@ -1,134 +1,67 @@ -// ignore_for_file: invalid_use_of_protected_member +import 'dart:async'; import 'package:fl_query/fl_query.dart'; -import 'package:fl_query_hooks/src/utils.dart'; -import 'package:flutter/widgets.dart'; +import 'package:fl_query_hooks/src/use_query_client.dart'; +import 'package:fl_query_hooks/src/utils/use_updater.dart'; +import 'package:flutter/material.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; -Query useQuery({ - required QueryJob job, - required Outside externalData, +Query useQuery( + final String queryKey, + final QueryFn queryFn, { + final DataType? initial, + final RetryConfig? retryConfig, + final RefreshConfig? refreshConfig, + final JsonConfig? jsonConfig, + final ValueChanged? onData, + final ValueChanged? onError, - /// Called when the query returns new data, on query - /// refetch or query gets expired - QueryListener? onData, - - /// Called when the query returns error - QueryListener? onError, - List? keys, + // hook specific + final bool enabled = true, }) { - final mounted = useIsMounted(); - final update = useForceUpdate(); - final context = useContext(); - final QueryBowl queryBowl = QueryBowl.of(context); - final ValueKey uKey = useMemoized(() => ValueKey(uuid.v4()), []); - final query = useRef( - useMemoized( - () => queryBowl.addQuery( - job, - externalData: externalData, - key: uKey, - onData: onData, - onError: onError, - ), - [], - ), - ); - - final oldJob = usePrevious(job); - final oldExternalData = usePrevious(externalData); - final oldOnData = usePrevious(onData); - final oldOnError = usePrevious(onError); - - final init = useCallback(([T? previousData]) { - final hasExternalDataChanged = !isShallowEqual( - query.value.externalData, - query.value.prevUsedExternalData, + final rebuild = useUpdater(); + final client = useQueryClient(); + final query = useMemoized>(() { + final query = client.createQuery( + queryKey, + queryFn, + initial: initial, + jsonConfig: jsonConfig, + refreshConfig: refreshConfig, + retryConfig: retryConfig, ); - query.value = queryBowl.addQuery( - job, - externalData: externalData, - previousData: previousData, - key: uKey, - onData: onData, - onError: onError, - ); - update(); - if (query.value.fetched && hasExternalDataChanged) { - query.value.refetch(); - } else if (!query.value.fetched) { - query.value.fetch(); - } - }, [queryBowl, query.value, uKey, onData, onError, job, externalData]); - - final disposeQuery = useCallback(() { - query.value.unmount(uKey); - if (onData != null) query.value.removeDataListener(onData); - if (onError != null) query.value.removeErrorListener(onError); - }, [query.value, onData, onError, uKey]); + return query; + }, [queryKey]); useEffect(() { - WidgetsBinding.instance.addPostFrameCallback((_) { - init(); - QueryBowl.of(context).onQueriesUpdate( - (newQuery) { - if (newQuery.queryKey != job.queryKey || !mounted()) return; - query.value = newQuery; - update(); - }, - ); - }); - return disposeQuery; - }, []); - - useEffect(() { - WidgetsBinding.instance.addPostFrameCallback((_) { - final hasOnErrorChanged = oldOnError != onError && oldOnError != null; - final hasOnDataChanged = oldOnData != onData && oldOnData != null; - if (oldJob != null && oldJob.queryKey != job.queryKey) { - disposeQuery(); - - /// setting the new query's initial data as prev query's data - /// when [job.keepPreviousData] is true and both are dynamic - if (oldJob.isDynamic && - job.isDynamic && - oldJob.keepPreviousData == true && - job.keepPreviousData == true) { - init(query.value.data); - } else { - init(); - } - } else if (!isShallowEqual(oldExternalData, externalData)) { - if (job.refetchOnExternalDataChange ?? - queryBowl.refetchOnExternalDataChange) { - QueryBowl.of(context).fetchQuery( - job, - externalData: externalData, - onData: onData, - onError: onError, - key: uKey, - ); - } else { - QueryBowl.of(context) - .getQuery(job.queryKey) - ?.setExternalData(externalData); - } - - if (hasOnDataChanged) query.value.removeDataListener(oldOnData); - if (hasOnErrorChanged) query.value.removeErrorListener(oldOnError); - } else { - if (hasOnDataChanged) { - query.value.removeDataListener(oldOnData); - if (onData != null) query.value.addDataListener(onData); - } - if (hasOnErrorChanged) { - query.value.removeErrorListener(oldOnError); - if (onError != null) query.value.addErrorListener(onError); - } - } - }); + query.updateQueryFn(queryFn); return null; - }); + }, [queryFn, query]); - return query.value; + useEffect(() { + final removeListener = query.addListener(rebuild); + if (enabled) { + query.fetch(); + } + return removeListener; + }, [query, enabled]); + + useEffect(() { + StreamSubscription? dataSubscription; + StreamSubscription? errorSubscription; + + if (onData != null) { + dataSubscription = query.dataStream.listen(onData); + } + if (onError != null) { + errorSubscription = query.errorStream.listen(onError); + } + + return () { + dataSubscription?.cancel(); + errorSubscription?.cancel(); + }; + }, [onData, onError, query]); + + return query; } diff --git a/packages/fl_query_hooks/lib/src/use_query_bowl.dart b/packages/fl_query_hooks/lib/src/use_query_client.dart similarity index 51% rename from packages/fl_query_hooks/lib/src/use_query_bowl.dart rename to packages/fl_query_hooks/lib/src/use_query_client.dart index 7df1e81..d921744 100644 --- a/packages/fl_query_hooks/lib/src/use_query_bowl.dart +++ b/packages/fl_query_hooks/lib/src/use_query_client.dart @@ -1,9 +1,7 @@ import 'package:fl_query/fl_query.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; -/// Simple hook based shorthand for [QueryBowl.of(context)] -QueryBowl useQueryBowl() { +QueryClient useQueryClient() { final context = useContext(); - - return QueryBowl.of(context); + return QueryClient.of(context); } diff --git a/packages/fl_query_hooks/lib/src/utils.dart b/packages/fl_query_hooks/lib/src/utils.dart deleted file mode 100644 index 7bfb82d..0000000 --- a/packages/fl_query_hooks/lib/src/utils.dart +++ /dev/null @@ -1,18 +0,0 @@ -import 'package:flutter_hooks/flutter_hooks.dart'; -import 'package:uuid/uuid.dart'; - -const uuid = Uuid(); - -// a flutter hook that can force update the ui -// -// Usage: -// final forceUpdate = useForceUpdate(); -// forceUpdate(); - -useForceUpdate() { - final state = useState(false); - final isMounted = useIsMounted(); - return () { - if (isMounted()) state.value = !state.value; - }; -} diff --git a/packages/fl_query_hooks/lib/src/utils/use_updater.dart b/packages/fl_query_hooks/lib/src/utils/use_updater.dart new file mode 100644 index 0000000..0a16aca --- /dev/null +++ b/packages/fl_query_hooks/lib/src/utils/use_updater.dart @@ -0,0 +1,20 @@ +import 'package:flutter/scheduler.dart'; +import 'package:flutter/widgets.dart'; +import 'package:flutter_hooks/flutter_hooks.dart'; + +ValueChanged useUpdater() { + final state = useState(false); + final isMounted = useIsMounted(); + return ([_]) async { + if (!isMounted()) return; + + // if there's a current frame, + if (SchedulerBinding.instance.schedulerPhase != SchedulerPhase.idle) { + // wait for the end of that frame. + await SchedulerBinding.instance.endOfFrame; + if (!isMounted()) return; + } + + state.value = !state.value; + }; +} diff --git a/packages/fl_query_hooks/pubspec.yaml b/packages/fl_query_hooks/pubspec.yaml index 28a6d01..a46425d 100644 --- a/packages/fl_query_hooks/pubspec.yaml +++ b/packages/fl_query_hooks/pubspec.yaml @@ -1,25 +1,24 @@ name: fl_query_hooks -description: Elite flutter_hooks compatible library for fl_query, the Asynchronous data caching, refetching & invalidation library for Flutter -version: 0.3.1 +description: Elite flutter_hooks compatible library for fl_query, the + Asynchronous data caching, refetching & invalidation library for Flutter +version: 1.0.0-alpha.5 + homepage: https://fl-query.vercel.app - issue_tracker: https://github.com/KRTirtho/fl-query/issues +repository: https://github.com/KRTirtho/fl-query/tree/main/packages/fl_query_hooks -repository: https://github.com/KRTirtho/fl-query environment: - sdk: ">=2.17.1 <3.0.0" + sdk: ">=2.17.1 <4.0.0" flutter: ">=1.17.0" dependencies: flutter: sdk: flutter - flutter_hooks: ^0.18.5+1 - uuid: ^3.0.6 - fl_query: - path: ../fl_query + fl_query: ^1.0.0-alpha.5 + flutter_hooks: ^0.20.0 dev_dependencies: + flutter_lints: ^2.0.0 flutter_test: sdk: flutter - flutter_lints: ^2.0.0 diff --git a/packages/fl_query_hooks/pubspec_overrides.yaml b/packages/fl_query_hooks/pubspec_overrides.yaml new file mode 100644 index 0000000..07a1730 --- /dev/null +++ b/packages/fl_query_hooks/pubspec_overrides.yaml @@ -0,0 +1,4 @@ +# melos_managed_dependency_overrides: fl_query +dependency_overrides: + fl_query: + path: ../fl_query diff --git a/packages/fl_query_hooks/test/fl_query_hooks_test.dart b/packages/fl_query_hooks/test/fl_query_hooks_test.dart deleted file mode 100644 index 0da434d..0000000 --- a/packages/fl_query_hooks/test/fl_query_hooks_test.dart +++ /dev/null @@ -1,5 +0,0 @@ -import 'package:flutter_test/flutter_test.dart'; - -void main() { - test('adds one to input values', () {}); -} diff --git a/pubspec.lock b/pubspec.lock new file mode 100644 index 0000000..6131bff --- /dev/null +++ b/pubspec.lock @@ -0,0 +1,317 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + ansi_styles: + dependency: transitive + description: + name: ansi_styles + sha256: "9c656cc12b3c27b17dd982b2cc5c0cfdfbdabd7bc8f3ae5e8542d9867b47ce8a" + url: "https://pub.dev" + source: hosted + version: "0.3.2+1" + args: + dependency: transitive + description: + name: args + sha256: c372bb384f273f0c2a8aaaa226dad84dc27c8519a691b888725dec59518ad53a + url: "https://pub.dev" + source: hosted + version: "2.4.1" + async: + dependency: transitive + description: + name: async + sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" + url: "https://pub.dev" + source: hosted + version: "2.11.0" + boolean_selector: + dependency: transitive + description: + name: boolean_selector + sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" + url: "https://pub.dev" + source: hosted + version: "2.1.1" + charcode: + dependency: transitive + description: + name: charcode + sha256: fb98c0f6d12c920a02ee2d998da788bca066ca5f148492b7085ee23372b12306 + url: "https://pub.dev" + source: hosted + version: "1.3.1" + cli_launcher: + dependency: transitive + description: + name: cli_launcher + sha256: "5e7e0282b79e8642edd6510ee468ae2976d847a0a29b3916e85f5fa1bfe24005" + url: "https://pub.dev" + source: hosted + version: "0.3.1" + cli_util: + dependency: transitive + description: + name: cli_util + sha256: b8db3080e59b2503ca9e7922c3df2072cf13992354d5e944074ffa836fba43b7 + url: "https://pub.dev" + source: hosted + version: "0.4.0" + collection: + dependency: transitive + description: + name: collection + sha256: f092b211a4319e98e5ff58223576de6c2803db36221657b46c82574721240687 + url: "https://pub.dev" + source: hosted + version: "1.17.2" + conventional_commit: + dependency: transitive + description: + name: conventional_commit + sha256: dec15ad1118f029c618651a4359eb9135d8b88f761aa24e4016d061cd45948f2 + url: "https://pub.dev" + source: hosted + version: "0.6.0+1" + file: + dependency: transitive + description: + name: file + sha256: "1b92bec4fc2a72f59a8e15af5f52cd441e4a7860b49499d69dfa817af20e925d" + url: "https://pub.dev" + source: hosted + version: "6.1.4" + glob: + dependency: transitive + description: + name: glob + sha256: "0e7014b3b7d4dac1ca4d6114f82bf1782ee86745b9b42a92c9289c23d8a0ab63" + url: "https://pub.dev" + source: hosted + version: "2.1.2" + graphs: + dependency: transitive + description: + name: graphs + sha256: aedc5a15e78fc65a6e23bcd927f24c64dd995062bcd1ca6eda65a3cff92a4d19 + url: "https://pub.dev" + source: hosted + version: "2.3.1" + http: + dependency: transitive + description: + name: http + sha256: "5895291c13fa8a3bd82e76d5627f69e0d85ca6a30dcac95c4ea19a5d555879c2" + url: "https://pub.dev" + source: hosted + version: "0.13.6" + http_parser: + dependency: transitive + description: + name: http_parser + sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b" + url: "https://pub.dev" + source: hosted + version: "4.0.2" + io: + dependency: transitive + description: + name: io + sha256: "2ec25704aba361659e10e3e5f5d672068d332fc8ac516421d483a11e5cbd061e" + url: "https://pub.dev" + source: hosted + version: "1.0.4" + json_annotation: + dependency: transitive + description: + name: json_annotation + sha256: b10a7b2ff83d83c777edba3c6a0f97045ddadd56c944e1a23a3fdf43a1bf4467 + url: "https://pub.dev" + source: hosted + version: "4.8.1" + matcher: + dependency: transitive + description: + name: matcher + sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e" + url: "https://pub.dev" + source: hosted + version: "0.12.16" + melos: + dependency: "direct main" + description: + name: melos + sha256: ccbb6ecd8bb3f08ae8f9ce22920d816bff325a98940c845eda0257cd395503ac + url: "https://pub.dev" + source: hosted + version: "3.1.0" + meta: + dependency: transitive + description: + name: meta + sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" + url: "https://pub.dev" + source: hosted + version: "1.9.1" + mustache_template: + dependency: transitive + description: + name: mustache_template + sha256: a46e26f91445bfb0b60519be280555b06792460b27b19e2b19ad5b9740df5d1c + url: "https://pub.dev" + source: hosted + version: "2.0.0" + path: + dependency: transitive + description: + name: path + sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" + url: "https://pub.dev" + source: hosted + version: "1.8.3" + platform: + dependency: transitive + description: + name: platform + sha256: "4a451831508d7d6ca779f7ac6e212b4023dd5a7d08a27a63da33756410e32b76" + url: "https://pub.dev" + source: hosted + version: "3.1.0" + pool: + dependency: transitive + description: + name: pool + sha256: "20fe868b6314b322ea036ba325e6fc0711a22948856475e2c2b6306e8ab39c2a" + url: "https://pub.dev" + source: hosted + version: "1.5.1" + process: + dependency: transitive + description: + name: process + sha256: "53fd8db9cec1d37b0574e12f07520d582019cb6c44abf5479a01505099a34a09" + url: "https://pub.dev" + source: hosted + version: "4.2.4" + prompts: + dependency: transitive + description: + name: prompts + sha256: "3773b845e85a849f01e793c4fc18a45d52d7783b4cb6c0569fad19f9d0a774a1" + url: "https://pub.dev" + source: hosted + version: "2.0.0" + pub_semver: + dependency: transitive + description: + name: pub_semver + sha256: "40d3ab1bbd474c4c2328c91e3a7df8c6dd629b79ece4c4bd04bee496a224fb0c" + url: "https://pub.dev" + source: hosted + version: "2.1.4" + pub_updater: + dependency: transitive + description: + name: pub_updater + sha256: "42890302ab2672adf567dc2b20e55b4ecc29d7e19c63b6b98143ab68dd717d3a" + url: "https://pub.dev" + source: hosted + version: "0.2.4" + pubspec: + dependency: transitive + description: + name: pubspec + sha256: f534a50a2b4d48dc3bc0ec147c8bd7c304280fff23b153f3f11803c4d49d927e + url: "https://pub.dev" + source: hosted + version: "2.3.0" + quiver: + dependency: transitive + description: + name: quiver + sha256: b1c1ac5ce6688d77f65f3375a9abb9319b3cb32486bdc7a1e0fdf004d7ba4e47 + url: "https://pub.dev" + source: hosted + version: "3.2.1" + source_span: + dependency: transitive + description: + name: source_span + sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" + url: "https://pub.dev" + source: hosted + version: "1.10.0" + stack_trace: + dependency: transitive + description: + name: stack_trace + sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 + url: "https://pub.dev" + source: hosted + version: "1.11.0" + stream_channel: + dependency: transitive + description: + name: stream_channel + sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" + url: "https://pub.dev" + source: hosted + version: "2.1.1" + string_scanner: + dependency: transitive + description: + name: string_scanner + sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" + url: "https://pub.dev" + source: hosted + version: "1.2.0" + term_glyph: + dependency: transitive + description: + name: term_glyph + sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 + url: "https://pub.dev" + source: hosted + version: "1.2.1" + test_api: + dependency: transitive + description: + name: test_api + sha256: "75760ffd7786fffdfb9597c35c5b27eaeec82be8edfb6d71d32651128ed7aab8" + url: "https://pub.dev" + source: hosted + version: "0.6.0" + typed_data: + dependency: transitive + description: + name: typed_data + sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c + url: "https://pub.dev" + source: hosted + version: "1.3.2" + uri: + dependency: transitive + description: + name: uri + sha256: "889eea21e953187c6099802b7b4cf5219ba8f3518f604a1033064d45b1b8268a" + url: "https://pub.dev" + source: hosted + version: "1.0.0" + yaml: + dependency: transitive + description: + name: yaml + sha256: "75769501ea3489fca56601ff33454fe45507ea3bfb014161abc3b43ae25989d5" + url: "https://pub.dev" + source: hosted + version: "3.1.2" + yaml_edit: + dependency: transitive + description: + name: yaml_edit + sha256: "1579d4a0340a83cf9e4d580ea51a16329c916973bffd5bd4b45e911b25d46bfd" + url: "https://pub.dev" + source: hosted + version: "2.1.1" +sdks: + dart: ">=2.19.0 <4.0.0" diff --git a/pubspec.yaml b/pubspec.yaml new file mode 100644 index 0000000..d2b4150 --- /dev/null +++ b/pubspec.yaml @@ -0,0 +1,12 @@ +name: fl_query_packages +description: Asynchronous data caching, refetching & invalidation libraries for Flutter +homepage: https://fl-query.vercel.app + +issue_tracker: https://github.com/KRTirtho/fl-query/issues +repository: https://github.com/KRTirtho/fl-query + +environment: + sdk: ">=2.17.1 <4.0.0" + +dependencies: + melos: ^3.1.0