create-flutterinit 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/index.ts +3 -0
- package/package.json +46 -0
- package/templates/base/.cursor/rules/flutter-project.mdc.hbs +132 -0
- package/templates/base/AGENTS.md.hbs +137 -0
- package/templates/base/DESIGN.md.hbs +149 -0
- package/templates/base/README.md.hbs +19 -0
- package/templates/base/SETUP.md.hbs +253 -0
- package/templates/base/analysis_options.yaml +88 -0
- package/templates/base/assets/.keep +1 -0
- package/templates/base/assets/icons/apple.svg +1 -0
- package/templates/base/assets/icons/facebook.svg +1 -0
- package/templates/base/assets/icons/google.svg +1 -0
- package/templates/base/assets/images/.gitkeep +0 -0
- package/templates/base/flutter_native_splash.yaml.hbs +8 -0
- package/templates/base/lib/main.dart.hbs +43 -0
- package/templates/base/lib/src/app.dart.hbs +105 -0
- package/templates/base/lib/src/config/app_config.dart.hbs +112 -0
- package/templates/base/lib/src/extensions/collection_extension.dart.hbs +55 -0
- package/templates/base/lib/src/extensions/context_extension.dart.hbs +167 -0
- package/templates/base/lib/src/extensions/date_time_extension.dart.hbs +40 -0
- package/templates/base/lib/src/extensions/extensions.dart.hbs +6 -0
- package/templates/base/lib/src/extensions/num_extension.dart.hbs +14 -0
- package/templates/base/lib/src/extensions/string_extension.dart.hbs +91 -0
- package/templates/base/lib/src/extensions/widget_extension.dart.hbs +47 -0
- package/templates/base/lib/src/imports/core_imports.dart.hbs +50 -0
- package/templates/base/lib/src/imports/imports.dart.hbs +2 -0
- package/templates/base/lib/src/imports/packages_imports.dart.hbs +110 -0
- package/templates/base/lib/src/routing/(isGetX)@app_bindings.dart.hbs +23 -0
- package/templates/base/lib/src/routing/app_router.dart.hbs +252 -0
- package/templates/base/lib/src/routing/app_routes.dart.hbs +46 -0
- package/templates/base/lib/src/routing/global_navigator.dart.hbs +15 -0
- package/templates/base/lib/src/services/auth_service.dart.hbs +78 -0
- package/templates/base/lib/src/services/copy_service.dart.hbs +16 -0
- package/templates/base/lib/src/services/internet_connection_service.dart.hbs +10 -0
- package/templates/base/lib/src/services/services.dart.hbs +45 -0
- package/templates/base/lib/src/shared/app_assets.dart.hbs +15 -0
- package/templates/base/lib/src/shared/enums/app_status.dart.hbs +40 -0
- package/templates/base/lib/src/shared/enums/button_enums.dart.hbs +22 -0
- package/templates/base/lib/src/shared/enums/enums.dart.hbs +3 -0
- package/templates/base/lib/src/shared/enums/snack_bar_type.dart.hbs +22 -0
- package/templates/base/lib/src/shared/helpers/format_number.dart.hbs +18 -0
- package/templates/base/lib/src/shared/helpers/imports.dart.hbs +3 -0
- package/templates/base/lib/src/shared/helpers/show_app_sheet.dart.hbs +42 -0
- package/templates/base/lib/src/shared/helpers/show_dialog.dart.hbs +49 -0
- package/templates/base/lib/src/shared/helpers/show_toast.dart.hbs +92 -0
- package/templates/base/lib/src/shared/hooks/hooks.dart.hbs +13 -0
- package/templates/base/lib/src/shared/hooks/use_copy.dart.hbs +41 -0
- package/templates/base/lib/src/shared/hooks/use_timer.dart.hbs +158 -0
- package/templates/base/lib/src/shared/shared.dart.hbs +12 -0
- package/templates/base/lib/src/shared/widgets/app_button.dart.hbs +144 -0
- package/templates/base/lib/src/shared/widgets/app_card.dart.hbs +126 -0
- package/templates/base/lib/src/shared/widgets/app_divider.dart.hbs +88 -0
- package/templates/base/lib/src/shared/widgets/app_empty_state.dart.hbs +73 -0
- package/templates/base/lib/src/shared/widgets/app_error_widget.dart.hbs +69 -0
- package/templates/base/lib/src/shared/widgets/app_icon.dart.hbs +25 -0
- package/templates/base/lib/src/shared/widgets/app_loading.dart.hbs +54 -0
- package/templates/base/lib/src/shared/widgets/app_text_field.dart.hbs +89 -0
- package/templates/base/lib/src/shared/widgets/app_top_bar.dart.hbs +105 -0
- package/templates/base/lib/src/shared/widgets/common_image.dart.hbs +120 -0
- package/templates/base/lib/src/shared/widgets/toast/imports.dart.hbs +4 -0
- package/templates/base/lib/src/shared/widgets/toast/raw_toast.dart.hbs +109 -0
- package/templates/base/lib/src/shared/widgets/toast/toast.dart.hbs +142 -0
- package/templates/base/lib/src/shared/widgets/toast/toast_card.dart.hbs +57 -0
- package/templates/base/lib/src/shared/widgets/widgets.dart.hbs +14 -0
- package/templates/base/lib/src/shared/wrappers/(isRiverpod,isProvider,isBloc,isGetX,isMobX)@state_wrapper.dart.hbs +51 -0
- package/templates/base/lib/src/shared/wrappers/(supportsLocalization)@localization_wrapper.dart.hbs +25 -0
- package/templates/base/lib/src/shared/wrappers/(usesScreenutil)@screen_util_wrapper.dart.hbs +27 -0
- package/templates/base/lib/src/shared/wrappers/(usesSkeletonizer)@skeleton_wrapper.dart.hbs +81 -0
- package/templates/base/lib/src/shared/wrappers/session_listener_wrapper.dart.hbs +258 -0
- package/templates/base/lib/src/shared/wrappers/wrappers.dart.hbs +15 -0
- package/templates/base/lib/src/theme/app_borders.dart.hbs +70 -0
- package/templates/base/lib/src/theme/app_curves.dart.hbs +69 -0
- package/templates/base/lib/src/theme/app_durations.dart.hbs +48 -0
- package/templates/base/lib/src/theme/app_shadows.dart.hbs +73 -0
- package/templates/base/lib/src/theme/app_spacing.dart.hbs +80 -0
- package/templates/base/lib/src/theme/color_schemes.dart.hbs +126 -0
- package/templates/base/lib/src/theme/text_theme.dart.hbs +167 -0
- package/templates/base/lib/src/theme/theme.dart.hbs +431 -0
- package/templates/base/lib/src/theme/theme_constants.dart.hbs +20 -0
- package/templates/base/lib/src/utils/app_utils.dart.hbs +46 -0
- package/templates/base/lib/src/utils/debouncer.dart.hbs +31 -0
- package/templates/base/lib/src/utils/error_handler.dart.hbs +14 -0
- package/templates/base/lib/src/utils/failure.dart.hbs +30 -0
- package/templates/base/lib/src/utils/input_formatters.dart.hbs +27 -0
- package/templates/base/lib/src/utils/logger.dart.hbs +37 -0
- package/templates/base/lib/src/utils/platform_info.dart.hbs +13 -0
- package/templates/base/lib/src/utils/task_runner.dart.hbs +42 -0
- package/templates/base/lib/src/utils/typedefs.dart.hbs +6 -0
- package/templates/base/lib/src/utils/utils.dart.hbs +9 -0
- package/templates/base/pubspec.yaml.hbs +256 -0
- package/templates/base/test/widget_test.dart.hbs +56 -0
- package/templates/overlays/architecture/clean/architecture.md +6 -0
- package/templates/overlays/architecture/clean/lib/src/features/auth/data/models/user_model.dart.hbs +1 -0
- package/templates/overlays/architecture/clean/lib/src/features/auth/data/repositories/auth_repository_impl.dart.hbs +1 -0
- package/templates/overlays/architecture/clean/lib/src/features/auth/domain/entities/user.dart.hbs +1 -0
- package/templates/overlays/architecture/clean/lib/src/features/auth/domain/repositories/auth_repository.dart.hbs +1 -0
- package/templates/overlays/architecture/clean/lib/src/features/auth/presentation/providers/(isBloc)@auth_bloc.dart.hbs +1 -0
- package/templates/overlays/architecture/clean/lib/src/features/auth/presentation/providers/(isBloc)@session_bloc.dart.hbs +1 -0
- package/templates/overlays/architecture/clean/lib/src/features/auth/presentation/providers/(isGetX)@auth_controller.dart.hbs +1 -0
- package/templates/overlays/architecture/clean/lib/src/features/auth/presentation/providers/(isGetX)@session_controller.dart.hbs +1 -0
- package/templates/overlays/architecture/clean/lib/src/features/auth/presentation/providers/(isMobX)@auth_store.dart.hbs +1 -0
- package/templates/overlays/architecture/clean/lib/src/features/auth/presentation/providers/(isMobX)@session_store.dart.hbs +1 -0
- package/templates/overlays/architecture/clean/lib/src/features/auth/presentation/providers/(isNoneState)@session_manager.dart.hbs +1 -0
- package/templates/overlays/architecture/clean/lib/src/features/auth/presentation/providers/(isProvider,isRiverpod)@auth_provider.dart.hbs +1 -0
- package/templates/overlays/architecture/clean/lib/src/features/auth/presentation/providers/(isProvider,isRiverpod)@session_provider.dart.hbs +1 -0
- package/templates/overlays/architecture/clean/lib/src/features/auth/presentation/screens/forgot_password_screen.dart.hbs +1 -0
- package/templates/overlays/architecture/clean/lib/src/features/auth/presentation/screens/login_screen.dart.hbs +1 -0
- package/templates/overlays/architecture/clean/lib/src/features/auth/presentation/screens/signup_screen.dart.hbs +1 -0
- package/templates/overlays/architecture/clean/lib/src/features/home/presentation/screens/home_page.dart.hbs +1 -0
- package/templates/overlays/architecture/clean/lib/src/features/onboarding/presentation/screens/onboarding_page.dart.hbs +1 -0
- package/templates/overlays/architecture/feature-first/architecture.md +5 -0
- package/templates/overlays/architecture/feature-first/lib/src/features/auth/data/models/user_model.dart.hbs +1 -0
- package/templates/overlays/architecture/feature-first/lib/src/features/auth/data/repositories/auth_repository_impl.dart.hbs +1 -0
- package/templates/overlays/architecture/feature-first/lib/src/features/auth/domain/entities/user.dart.hbs +1 -0
- package/templates/overlays/architecture/feature-first/lib/src/features/auth/domain/repositories/auth_repository.dart.hbs +1 -0
- package/templates/overlays/architecture/feature-first/lib/src/features/auth/presentation/providers/(isBloc)@auth_bloc.dart.hbs +1 -0
- package/templates/overlays/architecture/feature-first/lib/src/features/auth/presentation/providers/(isBloc)@session_bloc.dart.hbs +1 -0
- package/templates/overlays/architecture/feature-first/lib/src/features/auth/presentation/providers/(isGetX)@auth_controller.dart.hbs +1 -0
- package/templates/overlays/architecture/feature-first/lib/src/features/auth/presentation/providers/(isGetX)@session_controller.dart.hbs +1 -0
- package/templates/overlays/architecture/feature-first/lib/src/features/auth/presentation/providers/(isMobX)@auth_store.dart.hbs +1 -0
- package/templates/overlays/architecture/feature-first/lib/src/features/auth/presentation/providers/(isMobX)@session_store.dart.hbs +1 -0
- package/templates/overlays/architecture/feature-first/lib/src/features/auth/presentation/providers/(isNoneState)@session_manager.dart.hbs +1 -0
- package/templates/overlays/architecture/feature-first/lib/src/features/auth/presentation/providers/(isProvider,isRiverpod)@auth_provider.dart.hbs +1 -0
- package/templates/overlays/architecture/feature-first/lib/src/features/auth/presentation/providers/(isProvider,isRiverpod)@session_provider.dart.hbs +1 -0
- package/templates/overlays/architecture/feature-first/lib/src/features/auth/presentation/screens/forgot_password_screen.dart.hbs +1 -0
- package/templates/overlays/architecture/feature-first/lib/src/features/auth/presentation/screens/login_screen.dart.hbs +1 -0
- package/templates/overlays/architecture/feature-first/lib/src/features/auth/presentation/screens/signup_screen.dart.hbs +1 -0
- package/templates/overlays/architecture/feature-first/lib/src/features/home/presentation/screens/home_page.dart.hbs +1 -0
- package/templates/overlays/architecture/feature-first/lib/src/features/onboarding/presentation/screens/onboarding_page.dart.hbs +1 -0
- package/templates/overlays/architecture/layer-first/architecture.md +6 -0
- package/templates/overlays/architecture/layer-first/lib/src/data/datasources/local/.gitkeep +0 -0
- package/templates/overlays/architecture/layer-first/lib/src/data/datasources/remote/.gitkeep +0 -0
- package/templates/overlays/architecture/layer-first/lib/src/data/models/user_model.dart.hbs +1 -0
- package/templates/overlays/architecture/layer-first/lib/src/data/repositories/auth_repository_impl.dart.hbs +1 -0
- package/templates/overlays/architecture/layer-first/lib/src/domain/entities/user.dart.hbs +1 -0
- package/templates/overlays/architecture/layer-first/lib/src/domain/repositories/auth_repository.dart.hbs +1 -0
- package/templates/overlays/architecture/layer-first/lib/src/domain/usecases/auth/.gitkeep +0 -0
- package/templates/overlays/architecture/layer-first/lib/src/presentation/providers/(isBloc)@auth_bloc.dart.hbs +1 -0
- package/templates/overlays/architecture/layer-first/lib/src/presentation/providers/(isBloc)@session_bloc.dart.hbs +1 -0
- package/templates/overlays/architecture/layer-first/lib/src/presentation/providers/(isGetX)@auth_controller.dart.hbs +1 -0
- package/templates/overlays/architecture/layer-first/lib/src/presentation/providers/(isGetX)@session_controller.dart.hbs +1 -0
- package/templates/overlays/architecture/layer-first/lib/src/presentation/providers/(isMobX)@auth_store.dart.hbs +1 -0
- package/templates/overlays/architecture/layer-first/lib/src/presentation/providers/(isMobX)@session_store.dart.hbs +1 -0
- package/templates/overlays/architecture/layer-first/lib/src/presentation/providers/(isNoneState)@auth_view_model.dart.hbs +1 -0
- package/templates/overlays/architecture/layer-first/lib/src/presentation/providers/(isNoneState)@session_manager.dart.hbs +1 -0
- package/templates/overlays/architecture/layer-first/lib/src/presentation/providers/(isProvider,isRiverpod)@auth_provider.dart.hbs +1 -0
- package/templates/overlays/architecture/layer-first/lib/src/presentation/providers/(isProvider,isRiverpod)@session_provider.dart.hbs +1 -0
- package/templates/overlays/architecture/layer-first/lib/src/presentation/screens/auth/forgot_password_screen.dart.hbs +1 -0
- package/templates/overlays/architecture/layer-first/lib/src/presentation/screens/auth/login_screen.dart.hbs +1 -0
- package/templates/overlays/architecture/layer-first/lib/src/presentation/screens/auth/signup_screen.dart.hbs +1 -0
- package/templates/overlays/architecture/layer-first/lib/src/presentation/screens/home/home_page.dart.hbs +1 -0
- package/templates/overlays/architecture/layer-first/lib/src/presentation/screens/onboarding/onboarding_page.dart.hbs +1 -0
- package/templates/overlays/architecture/layer-first/lib/src/presentation/widgets/.gitkeep +0 -0
- package/templates/overlays/architecture/mvc/architecture.md +5 -0
- package/templates/overlays/architecture/mvc/lib/src/controllers/auth/(isBloc)@auth_bloc.dart.hbs +1 -0
- package/templates/overlays/architecture/mvc/lib/src/controllers/auth/(isBloc)@session_bloc.dart.hbs +1 -0
- package/templates/overlays/architecture/mvc/lib/src/controllers/auth/(isGetX)@auth_controller.dart.hbs +1 -0
- package/templates/overlays/architecture/mvc/lib/src/controllers/auth/(isGetX)@session_controller.dart.hbs +1 -0
- package/templates/overlays/architecture/mvc/lib/src/controllers/auth/(isMobX)@auth_store.dart.hbs +1 -0
- package/templates/overlays/architecture/mvc/lib/src/controllers/auth/(isMobX)@session_store.dart.hbs +1 -0
- package/templates/overlays/architecture/mvc/lib/src/controllers/auth/(isNoneState)@session_manager.dart.hbs +1 -0
- package/templates/overlays/architecture/mvc/lib/src/controllers/auth/(isProvider,isRiverpod)@auth_provider.dart.hbs +1 -0
- package/templates/overlays/architecture/mvc/lib/src/controllers/auth/(isProvider,isRiverpod)@session_provider.dart.hbs +1 -0
- package/templates/overlays/architecture/mvc/lib/src/models/user_model.dart.hbs +1 -0
- package/templates/overlays/architecture/mvc/lib/src/services/auth_repository.dart.hbs +1 -0
- package/templates/overlays/architecture/mvc/lib/src/services/auth_repository_impl.dart.hbs +1 -0
- package/templates/overlays/architecture/mvc/lib/src/views/auth/forgot_password_screen.dart.hbs +1 -0
- package/templates/overlays/architecture/mvc/lib/src/views/auth/login_screen.dart.hbs +1 -0
- package/templates/overlays/architecture/mvc/lib/src/views/auth/signup_screen.dart.hbs +1 -0
- package/templates/overlays/architecture/mvc/lib/src/views/home/home_page.dart.hbs +1 -0
- package/templates/overlays/architecture/mvc/lib/src/views/onboarding/onboarding_page.dart.hbs +1 -0
- package/templates/overlays/architecture/mvvm/architecture.md +6 -0
- package/templates/overlays/architecture/mvvm/lib/src/data/models/user_model.dart.hbs +1 -0
- package/templates/overlays/architecture/mvvm/lib/src/data/repositories/auth_repository.dart.hbs +1 -0
- package/templates/overlays/architecture/mvvm/lib/src/data/repositories/auth_repository_impl.dart.hbs +1 -0
- package/templates/overlays/architecture/mvvm/lib/src/ui/auth/(isBloc)@bloc/auth_bloc.dart.hbs +1 -0
- package/templates/overlays/architecture/mvvm/lib/src/ui/auth/(isBloc)@bloc/session_bloc.dart.hbs +1 -0
- package/templates/overlays/architecture/mvvm/lib/src/ui/auth/(isGetX)@controllers/auth_controller.dart.hbs +1 -0
- package/templates/overlays/architecture/mvvm/lib/src/ui/auth/(isGetX)@controllers/session_controller.dart.hbs +1 -0
- package/templates/overlays/architecture/mvvm/lib/src/ui/auth/(isMobX)@stores/auth_store.dart.hbs +1 -0
- package/templates/overlays/architecture/mvvm/lib/src/ui/auth/(isMobX)@stores/session_store.dart.hbs +1 -0
- package/templates/overlays/architecture/mvvm/lib/src/ui/auth/(isNoneState)@view_models/auth_view_model.dart.hbs +1 -0
- package/templates/overlays/architecture/mvvm/lib/src/ui/auth/(isNoneState)@view_models/session_manager.dart.hbs +1 -0
- package/templates/overlays/architecture/mvvm/lib/src/ui/auth/(isProvider,isRiverpod)@providers/auth_provider.dart.hbs +1 -0
- package/templates/overlays/architecture/mvvm/lib/src/ui/auth/(isProvider,isRiverpod)@providers/session_provider.dart.hbs +1 -0
- package/templates/overlays/architecture/mvvm/lib/src/ui/auth/forgot_password_screen.dart.hbs +1 -0
- package/templates/overlays/architecture/mvvm/lib/src/ui/auth/login_screen.dart.hbs +1 -0
- package/templates/overlays/architecture/mvvm/lib/src/ui/auth/signup_screen.dart.hbs +1 -0
- package/templates/overlays/architecture/mvvm/lib/src/ui/home/home_page.dart.hbs +1 -0
- package/templates/overlays/architecture/mvvm/lib/src/ui/onboarding/onboarding_page.dart.hbs +1 -0
- package/templates/overlays/backend/appwrite/lib/src/services/(usesAppwriteAuth)@auth_service.dart.hbs +101 -0
- package/templates/overlays/backend/custom/lib/src/services/auth_service.dart.hbs +158 -0
- package/templates/overlays/backend/firebase/lib/src/services/(usesFirebaseAuth)@auth_service.dart.hbs +96 -0
- package/templates/overlays/backend/supabase/lib/src/services/(usesSupabaseAuth)@auth_service.dart.hbs +97 -0
- package/templates/overlays/device/app_version_update/lib/src/services/(usesAppVersionUpdate)@version_update_service.dart.hbs +118 -0
- package/templates/overlays/device/device_info/lib/src/services/(usesDeviceInfoPlus)@device_info_service.dart.hbs +54 -0
- package/templates/overlays/extras/dotenv/.env.hbs +33 -0
- package/templates/overlays/extras/flavors/lib/src/flavors.dart.hbs +15 -0
- package/templates/overlays/extras/localization/assets/translations/en.json.hbs +47 -0
- package/templates/overlays/media/lib/src/services/(usesImagePicker,usesFilePicker)@media_service.dart.hbs +148 -0
- package/templates/overlays/networking/cached_image/lib/src/shared/widgets/app_cached_image.dart.hbs +160 -0
- package/templates/overlays/networking/dio/lib/src/services/(usesDio)@dio_service.dart.hbs +50 -0
- package/templates/overlays/networking/http/lib/src/services/(usesHttp)@http_service.dart.hbs +82 -0
- package/templates/overlays/storage/hive/lib/src/services/(usesHive)@hive_service.dart.hbs +59 -0
- package/templates/overlays/storage/secure_storage/lib/src/services/(usesSecureStorage)@secure_storage_service.dart.hbs +39 -0
- package/templates/overlays/storage/shared_preferences/lib/src/services/(usesSharedPreferences)@storage_service.dart.hbs +53 -0
- package/templates/overlays/utilities/geolocator/lib/src/services/(usesGeolocator)@location_service.dart.hbs +78 -0
- package/templates/overlays/utilities/path_provider/lib/src/services/(usesPathProvider)@path_service.dart.hbs +30 -0
- package/templates/overlays/utilities/permission_handler/lib/src/services/(usesPermissionHandler)@permission_service.dart.hbs +28 -0
- package/templates/overlays/utilities/permission_handler/lib/src/shared/hooks/use_permission.dart.hbs +44 -0
- package/templates/overlays/utilities/share_plus/lib/src/services/(usesSharePlus)@share_service.dart.hbs +22 -0
- package/templates/overlays/utilities/share_plus/lib/src/shared/hooks/use_share.dart.hbs +26 -0
- package/templates/overlays/utilities/url_launcher/lib/src/services/(usesUrlLauncher)@url_launcher_service.dart.hbs +37 -0
- package/templates/overlays/utilities/url_launcher/lib/src/shared/hooks/use_launch_url.dart.hbs +52 -0
- package/templates/partials/features/auth/auth_logic.hbs +611 -0
- package/templates/partials/features/auth/auth_repository.hbs +32 -0
- package/templates/partials/features/auth/auth_repository_impl.hbs +116 -0
- package/templates/partials/features/auth/forgot_password_screen.hbs +368 -0
- package/templates/partials/features/auth/login_screen.hbs +540 -0
- package/templates/partials/features/auth/session_provider.hbs +437 -0
- package/templates/partials/features/auth/signup_screen.hbs +511 -0
- package/templates/partials/features/auth/user_model.hbs +23 -0
- package/templates/partials/features/home/home_page.hbs +156 -0
- package/templates/partials/features/onboarding/onboarding_page.hbs +264 -0
- package/templates/partials/llm/add-feature-workflow.hbs +38 -0
- package/templates/partials/llm/architecture-rules.hbs +92 -0
- package/templates/partials/llm/backend-rules.hbs +30 -0
- package/templates/partials/llm/build-runner-note.hbs +15 -0
- package/templates/partials/llm/design-quick-ref.hbs +14 -0
- package/templates/partials/llm/design-quick-reference.hbs +14 -0
- package/templates/partials/llm/navigation-rules.hbs +27 -0
- package/templates/partials/llm/networking-rules.hbs +16 -0
- package/templates/partials/llm/packages-list.hbs +26 -0
- package/templates/partials/llm/services-conventions.hbs +20 -0
- package/templates/partials/llm/stack-summary.hbs +22 -0
- package/templates/partials/llm/state-management-rules.hbs +40 -0
- package/templates/partials/state_label.hbs +1 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import 'package:geolocator/geolocator.dart';
|
|
2
|
+
import '../utils/utils.dart';
|
|
3
|
+
|
|
4
|
+
/// A service to handle device location requests and status checks.
|
|
5
|
+
class LocationService {
|
|
6
|
+
LocationService._();
|
|
7
|
+
static final LocationService instance = LocationService._();
|
|
8
|
+
|
|
9
|
+
/// Check the status of location permission.
|
|
10
|
+
FutureEither<LocationPermission> checkPermission() async {
|
|
11
|
+
return runTask(() => Geolocator.checkPermission());
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/// Request location permission.
|
|
15
|
+
FutureEither<LocationPermission> requestPermission() async {
|
|
16
|
+
return runTask(() => Geolocator.requestPermission());
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/// Check if location services are enabled.
|
|
20
|
+
FutureEither<bool> isLocationServiceEnabled() async {
|
|
21
|
+
return runTask(() => Geolocator.isLocationServiceEnabled());
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/// Open the location settings.
|
|
25
|
+
FutureEither<bool> openLocationSettings() async {
|
|
26
|
+
return runTask(() => Geolocator.openLocationSettings());
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/// Get the current position.
|
|
30
|
+
FutureEither<Position> getCurrentPosition({
|
|
31
|
+
LocationAccuracy accuracy = LocationAccuracy.high,
|
|
32
|
+
}) async {
|
|
33
|
+
return runTask(() async {
|
|
34
|
+
bool serviceEnabled;
|
|
35
|
+
LocationPermission permission;
|
|
36
|
+
|
|
37
|
+
serviceEnabled = await Geolocator.isLocationServiceEnabled();
|
|
38
|
+
if (!serviceEnabled) {
|
|
39
|
+
throw Exception('Location services are disabled.');
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
permission = await Geolocator.checkPermission();
|
|
43
|
+
if (permission == LocationPermission.denied) {
|
|
44
|
+
permission = await Geolocator.requestPermission();
|
|
45
|
+
if (permission == LocationPermission.denied) {
|
|
46
|
+
throw Exception('Location permissions are denied.');
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (permission == LocationPermission.deniedForever) {
|
|
51
|
+
throw Exception(
|
|
52
|
+
'Location permissions are permanently denied, we cannot request permissions.');
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return await Geolocator.getCurrentPosition(
|
|
56
|
+
locationSettings: LocationSettings(accuracy: accuracy),
|
|
57
|
+
);
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/// Get the last known position.
|
|
62
|
+
FutureEither<Position?> getLastKnownPosition() async {
|
|
63
|
+
return runTask(() => Geolocator.getLastKnownPosition());
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/// Get a stream of position updates.
|
|
67
|
+
Stream<Position> getPositionStream({
|
|
68
|
+
LocationAccuracy accuracy = LocationAccuracy.high,
|
|
69
|
+
int distanceFilter = 0,
|
|
70
|
+
}) {
|
|
71
|
+
return Geolocator.getPositionStream(
|
|
72
|
+
locationSettings: LocationSettings(
|
|
73
|
+
accuracy: accuracy,
|
|
74
|
+
distanceFilter: distanceFilter,
|
|
75
|
+
),
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import 'dart:io';
|
|
2
|
+
import 'package:path_provider/path_provider.dart';
|
|
3
|
+
import '../utils/utils.dart';
|
|
4
|
+
|
|
5
|
+
/// A service to easily access platform-specific file system locations.
|
|
6
|
+
class PathService {
|
|
7
|
+
PathService._();
|
|
8
|
+
static final PathService instance = PathService._();
|
|
9
|
+
|
|
10
|
+
/// Get the directory where the application may place data that is user-generated.
|
|
11
|
+
FutureEither<Directory> getDocumentsDirectory() async =>
|
|
12
|
+
runTask(() => getApplicationDocumentsDirectory());
|
|
13
|
+
|
|
14
|
+
/// Get the directory where the application may place application-specific cache files.
|
|
15
|
+
FutureEither<Directory> getTempDirectory() async =>
|
|
16
|
+
runTask(() => getTemporaryDirectory());
|
|
17
|
+
|
|
18
|
+
/// Get the directory where the application may place data that is specific to
|
|
19
|
+
/// the application and not meant to be seen by the user.
|
|
20
|
+
FutureEither<Directory> getAppSupportDirectory() async =>
|
|
21
|
+
runTask(() => getApplicationSupportDirectory());
|
|
22
|
+
|
|
23
|
+
/// Get the directory where current application-specific data may be found.
|
|
24
|
+
FutureEither<Directory> getAppLibraryDirectory() async =>
|
|
25
|
+
runTask(() => getLibraryDirectory());
|
|
26
|
+
|
|
27
|
+
/// Get the path to the external storage directory (Android only).
|
|
28
|
+
FutureEither<Directory?> getExternalStorageDirectoryPath() async =>
|
|
29
|
+
runTask(() => getExternalStorageDirectory());
|
|
30
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import 'package:permission_handler/permission_handler.dart';
|
|
2
|
+
import '../utils/utils.dart';
|
|
3
|
+
|
|
4
|
+
/// A service to handle device permission requests and status checks.
|
|
5
|
+
class PermissionService {
|
|
6
|
+
PermissionService._();
|
|
7
|
+
static final PermissionService instance = PermissionService._();
|
|
8
|
+
|
|
9
|
+
/// Check the status of a specific permission.
|
|
10
|
+
FutureEither<PermissionStatus> checkStatus(Permission permission) async {
|
|
11
|
+
return runTask(() => permission.status);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/// Request a specific permission.
|
|
15
|
+
FutureEither<PermissionStatus> request(Permission permission) async {
|
|
16
|
+
return runTask(() => permission.request());
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/// Request multiple permissions at once.
|
|
20
|
+
FutureEither<Map<Permission, PermissionStatus>> requestMultiple(List<Permission> permissions) async {
|
|
21
|
+
return runTask(() => permissions.request());
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/// Open the app settings.
|
|
25
|
+
FutureEither<bool> openSettings() async {
|
|
26
|
+
return runTask(() => openAppSettings());
|
|
27
|
+
}
|
|
28
|
+
}
|
package/templates/overlays/utilities/permission_handler/lib/src/shared/hooks/use_permission.dart.hbs
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{{#if flags.usesFlutterHooks}}
|
|
2
|
+
import 'package:flutter_hooks/flutter_hooks.dart';
|
|
3
|
+
import 'package:permission_handler/permission_handler.dart';
|
|
4
|
+
import '../../services/permission_service.dart';
|
|
5
|
+
|
|
6
|
+
/// A hook to manage permission lifecycle and status with loading state.
|
|
7
|
+
(PermissionStatus, bool, Future<void> Function()) usePermission(Permission permission) {
|
|
8
|
+
final status = useState<PermissionStatus>(PermissionStatus.denied);
|
|
9
|
+
final isLoading = useState(false);
|
|
10
|
+
|
|
11
|
+
Future<void> check() async {
|
|
12
|
+
isLoading.value = true;
|
|
13
|
+
try {
|
|
14
|
+
final result = await PermissionService.instance.checkStatus(permission);
|
|
15
|
+
result.fold(
|
|
16
|
+
(f) => null,
|
|
17
|
+
(s) => status.value = s,
|
|
18
|
+
);
|
|
19
|
+
} finally {
|
|
20
|
+
isLoading.value = false;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
Future<void> request() async {
|
|
25
|
+
isLoading.value = true;
|
|
26
|
+
try {
|
|
27
|
+
final result = await PermissionService.instance.request(permission);
|
|
28
|
+
result.fold(
|
|
29
|
+
(f) => null,
|
|
30
|
+
(s) => status.value = s,
|
|
31
|
+
);
|
|
32
|
+
} finally {
|
|
33
|
+
isLoading.value = false;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
useEffect(() {
|
|
38
|
+
check();
|
|
39
|
+
return null;
|
|
40
|
+
}, [permission]);
|
|
41
|
+
|
|
42
|
+
return (status.value, isLoading.value, request);
|
|
43
|
+
}
|
|
44
|
+
{{/if}}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import 'package:share_plus/share_plus.dart';
|
|
2
|
+
import '../utils/utils.dart';
|
|
3
|
+
|
|
4
|
+
/// A service to handle sharing content via the platform's native share dialog.
|
|
5
|
+
class ShareService {
|
|
6
|
+
ShareService._();
|
|
7
|
+
static final ShareService instance = ShareService._();
|
|
8
|
+
|
|
9
|
+
/// Share plain text content.
|
|
10
|
+
FutureEither<ShareResult> shareText(String text, {String? subject}) async {
|
|
11
|
+
return runTask(() => Share.share(text, subject: subject));
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/// Share files.
|
|
15
|
+
FutureEither<ShareResult> shareFiles(List<String> paths, {String? text, String? subject}) async {
|
|
16
|
+
return runTask(() => Share.shareXFiles(
|
|
17
|
+
paths.map((p) => XFile(p)).toList(),
|
|
18
|
+
text: text,
|
|
19
|
+
subject: subject,
|
|
20
|
+
));
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{{#if flags.usesFlutterHooks}}
|
|
2
|
+
import 'package:flutter_hooks/flutter_hooks.dart';
|
|
3
|
+
import '../../utils/utils.dart';
|
|
4
|
+
import '../../services/share_service.dart';
|
|
5
|
+
|
|
6
|
+
/// A hook to simplify sharing logic within widgets with loading state.
|
|
7
|
+
(bool, Future<void> Function(String, {String? subject})) useShare() {
|
|
8
|
+
final isLoading = useState(false);
|
|
9
|
+
final service = ShareService.instance;
|
|
10
|
+
|
|
11
|
+
Future<void> share(String text, {String? subject}) async {
|
|
12
|
+
isLoading.value = true;
|
|
13
|
+
try {
|
|
14
|
+
final result = await service.shareText(text, subject: subject);
|
|
15
|
+
result.fold(
|
|
16
|
+
(failure) => AppLogger.error('Sharing failed: ${failure.message}'),
|
|
17
|
+
(success) => AppLogger.info('Sharing result: ${success.status}'),
|
|
18
|
+
);
|
|
19
|
+
} finally {
|
|
20
|
+
isLoading.value = false;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return (isLoading.value, share);
|
|
25
|
+
}
|
|
26
|
+
{{/if}}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import 'dart:io';
|
|
2
|
+
import '../imports/imports.dart';
|
|
3
|
+
|
|
4
|
+
/// A service to handle URL launching operations.
|
|
5
|
+
class UrlLauncherService {
|
|
6
|
+
UrlLauncherService._();
|
|
7
|
+
static final UrlLauncherService instance = UrlLauncherService._();
|
|
8
|
+
|
|
9
|
+
/// Launch a URL string.
|
|
10
|
+
FutureEither<void> launch(String url, {LaunchMode? mode}) async {
|
|
11
|
+
return runTask(() async {
|
|
12
|
+
final formattedUrl = _formatUrl(url);
|
|
13
|
+
final uri = Uri.parse(formattedUrl);
|
|
14
|
+
|
|
15
|
+
if (await canLaunchUrl(uri)) {
|
|
16
|
+
await launchUrl(
|
|
17
|
+
uri,
|
|
18
|
+
mode: mode ?? LaunchMode.externalApplication,
|
|
19
|
+
);
|
|
20
|
+
} else {
|
|
21
|
+
throw Exception('Could not launch url: $formattedUrl');
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
String _formatUrl(String url) {
|
|
27
|
+
if (url.isValidUrl && !url.contains('://')) {
|
|
28
|
+
return 'https://$url';
|
|
29
|
+
}
|
|
30
|
+
if (url.isValidPhoneNumber) {
|
|
31
|
+
return Platform.isAndroid
|
|
32
|
+
? 'whatsapp://send?phone=$url'
|
|
33
|
+
: 'https://wa.me/$url';
|
|
34
|
+
}
|
|
35
|
+
return url;
|
|
36
|
+
}
|
|
37
|
+
}
|
package/templates/overlays/utilities/url_launcher/lib/src/shared/hooks/use_launch_url.dart.hbs
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{{#if flags.usesFlutterHooks}}
|
|
2
|
+
import 'dart:io';
|
|
3
|
+
import '../../imports/imports.dart';
|
|
4
|
+
|
|
5
|
+
/// A hook to handle URL launching with state feedback.
|
|
6
|
+
(bool, Future<void> Function(String)) useLaunchUrl({LaunchMode? mode}) {
|
|
7
|
+
final isLoading = useState(false);
|
|
8
|
+
|
|
9
|
+
Future<void> launch(String url) async {
|
|
10
|
+
isLoading.value = true;
|
|
11
|
+
try {
|
|
12
|
+
final formattedUrl = _formatUrl(url);
|
|
13
|
+
final uri = Uri.parse(formattedUrl);
|
|
14
|
+
|
|
15
|
+
if (await canLaunchUrl(uri)) {
|
|
16
|
+
await launchUrl(
|
|
17
|
+
uri,
|
|
18
|
+
mode: mode ?? LaunchMode.externalApplication,
|
|
19
|
+
);
|
|
20
|
+
} else {
|
|
21
|
+
AppLogger.error('Could not launch url: $formattedUrl');
|
|
22
|
+
showGlobalToast(
|
|
23
|
+
message: 'Could not launch url',
|
|
24
|
+
status: 'error',
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
} catch (e) {
|
|
28
|
+
AppLogger.error('Error launching URL: $e');
|
|
29
|
+
showGlobalToast(
|
|
30
|
+
message: 'Could not launch url',
|
|
31
|
+
status: 'error',
|
|
32
|
+
);
|
|
33
|
+
} finally {
|
|
34
|
+
isLoading.value = false;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return (isLoading.value, launch);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
String _formatUrl(String url) {
|
|
42
|
+
if (url.isValidUrl && !url.contains('://')) {
|
|
43
|
+
return 'https://$url';
|
|
44
|
+
}
|
|
45
|
+
if (url.isValidPhoneNumber) {
|
|
46
|
+
return Platform.isAndroid
|
|
47
|
+
? 'whatsapp://send?phone=$url'
|
|
48
|
+
: 'https://wa.me/$url';
|
|
49
|
+
}
|
|
50
|
+
return url;
|
|
51
|
+
}
|
|
52
|
+
{{/if}}
|