{"id":16109004,"url":"https://github.com/sbis04/flutter_wear","last_synced_at":"2025-03-18T09:30:40.938Z","repository":{"id":45002657,"uuid":"264393634","full_name":"sbis04/flutter_wear","owner":"sbis04","description":"Flutter WearOS plugin","archived":false,"fork":false,"pushed_at":"2020-05-17T13:30:05.000Z","size":356,"stargazers_count":7,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-28T08:33:00.609Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://pub.dev/packages/flutter_wear","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sbis04.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-05-16T08:35:56.000Z","updated_at":"2024-05-31T01:08:29.000Z","dependencies_parsed_at":"2022-08-04T01:30:38.369Z","dependency_job_id":null,"html_url":"https://github.com/sbis04/flutter_wear","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sbis04%2Fflutter_wear","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sbis04%2Fflutter_wear/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sbis04%2Fflutter_wear/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sbis04%2Fflutter_wear/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sbis04","download_url":"https://codeload.github.com/sbis04/flutter_wear/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243910666,"owners_count":20367546,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-09T19:29:24.222Z","updated_at":"2025-03-18T09:30:40.290Z","avatar_url":"https://github.com/sbis04.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://github.com/sbis04/flutter_wear/raw/master/screenshots/cover.png\" alt=\"Flutter Wear\"/\u003e\n\u003c/p\u003e \n\n\u003ch4 align=\"center\"\u003eThis is a Flutter plugin for WearOS devices\u003c/h4\u003e\n\n## Features\n\n* Helps in getting the **shape** (square or round) of the watch face\n* Handles the mode changes, **Active Mode** and **Ambient Mode**\n\nMore features will be arriving soon.\n\n\u003ch4 align=\"center\"\u003eEXAMPLE APP\u003c/h4\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://github.com/sbis04/flutter_wear/raw/master/screenshots/wear_example.png\" alt=\"Flutter Wear App\"/\u003e\n\u003c/p\u003e\n\n\u003e ***NOTE:*** The project is not using *Fluter Embedding v2*\n\n## Usage\n\n* Add the dependency `flutter_wear` to your **pubspec.yaml** file.\n\n* Go to `\u003cproject root\u003e/android/app/build.gradle` and set the `minSdkVersion` to **23**:\n\n   ```gradle\n   minSdkVersion 23\n   ```\n\n* Also add the following dependencies to the same file:\n  ```gradle\n  dependencies {\n    // Wear dependencies\n    implementation 'com.android.support:wear:27.1.1'\n    implementation 'com.google.android.support:wearable:2.3.0'\n    compileOnly 'com.google.android.wearable:wearable:2.3.0'\n  }\n  ```\n\n* Go to `\u003cproject root\u003e/android/app/src/main/AndroidManifest.xml` and add the following inside the `manifest` tag:\n  ```xml\n  \u003c!-- Required for ambient mode support --\u003e\n  \u003cuses-permission android:name=\"android.permission.WAKE_LOCK\" /\u003e\n  \n  \u003c!-- Flags the app as a Wear app --\u003e\n  \u003cuses-feature android:name=\"android.hardware.type.watch\" /\u003e\n  ```\n\n* Inside the same file, update the contents of the `application` tag like this:\n  ```xml\n  \u003c!-- KEEP THE application tag ATTRIBUTES AS IT IS --\u003e\n  \u003capplication\n        android:name=\"io.flutter.app.FlutterApplication\"\n        android:label=\"wear_demo\"\n        android:icon=\"@mipmap/ic_launcher\"\u003e\n\n        \u003c!-- REPLACE THE PART STARTING FROM BELOW --\u003e\n        \u003c!-- Flags that the app doesn't require a companion phone app --\u003e\n        \u003cmeta-data\n        android:name=\"com.google.android.wearable.standalone\"\n        android:value=\"true\" /\u003e\n\n        \u003cactivity\n            android:name=\".MainActivity\"\n            android:launchMode=\"singleTop\"\n            android:theme=\"@style/LaunchTheme\"\n            android:configChanges=\"orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode\"\n            android:hardwareAccelerated=\"true\"\n            android:windowSoftInputMode=\"adjustResize\"\u003e\n\n            \u003cmeta-data\n              android:name=\"io.flutter.app.android.NormalTheme\"\n              android:resource=\"@style/NormalTheme\"\n              /\u003e\n\n            \u003cmeta-data\n              android:name=\"io.flutter.app.android.SplashScreenDrawable\"\n              android:resource=\"@drawable/launch_background\"\n              /\u003e\n            \u003cintent-filter\u003e\n                \u003caction android:name=\"android.intent.action.MAIN\"/\u003e\n                \u003ccategory android:name=\"android.intent.category.LAUNCHER\"/\u003e\n            \u003c/intent-filter\u003e\n        \u003c/activity\u003e\n        \u003c!-- TILL THE ABOVE LINE --\u003e\n    \u003c/application\u003e\n  ```\n\n\n* Go to `\u003cproject root\u003e/android/app/src/main/kotlin/\u003capp_id\u003e/MainActivity.kt` and update the `MainActivity` code as following:\n  ```kotlin\n  // Except the package name\n  // Replace everything\n\n  import android.os.Bundle\n\n  // Do not import this package: \n  // io.flutter.embedding.android.FlutterActivity\n\n  // Make sure that you import the exact same packages here\n  import io.flutter.app.FlutterActivity\n  import io.flutter.plugins.GeneratedPluginRegistrant\n  \n  import androidx.wear.ambient.AmbientMode\n  \n  // Here, replace the app id with yours or, \n  // just open the android folder using Android Studio \u0026 \n  // import the following two packages\n  import com.souvikbiswas.flutter_wear.FlutterAmbientCallback\n  import com.souvikbiswas.flutter_wear.getChannel\n  \n  class MainActivity: FlutterActivity(), AmbientMode.AmbientCallbackProvider {\n      override fun onCreate(savedInstanceState: Bundle?) {\n          super.onCreate(savedInstanceState)\n          GeneratedPluginRegistrant.registerWith(this)\n  \n          // Wire up the activity for ambient callbacks\n          AmbientMode.attachAmbientSupport(this)\n      }\n  \n      override fun getAmbientCallback(): AmbientMode.AmbientCallback {\n          return FlutterAmbientCallback(getChannel(flutterView))\n      }\n  }\n  ```\n\n## Widgets\n\nThere are three primary widgets:\n\n* **WearShape**: Determines the *shape* of the watch face, whether it is square or round.\n* **WearMode**: Determines the *current mode* of the watch (*Active Mode* or *Ambient Mode*). The widgets inside it rebuilds whenever the mode changes.\n* **WearInheritedShape**: It can be used for passing the shape of the watch down the widget tree.\n\n## Example\n\n```dart\nimport 'package:flutter/material.dart';\nimport 'package:flutter_wear/mode.dart';\nimport 'package:flutter_wear/shape.dart';\nimport 'package:flutter_wear/wear_mode.dart';\nimport 'package:flutter_wear/wear_shape.dart';\n\nvoid main() =\u003e runApp(MyApp());\n\nclass MyApp extends StatefulWidget {\n  @override\n  _MyAppState createState() =\u003e _MyAppState();\n}\n\nclass _MyAppState extends State\u003cMyApp\u003e {\n  Color _containerColor;\n  Color _textColor;\n\n  @override\n  void initState() {\n    super.initState();\n\n    _containerColor = Colors.white;\n    _textColor = Colors.black;\n  }\n\n  @override\n  Widget build(BuildContext context) {\n    return MaterialApp(\n      home: Scaffold(\n        body: Center(\n          child: WearShape(\n            builder: (context, shape) =\u003e WearMode(builder: (context, mode) {\n              if (mode == Mode.active) {\n                _containerColor = Colors.white;\n                _textColor = Colors.black;\n              } else {\n                _containerColor = Colors.black;\n                _textColor = Colors.white;\n              }\n              return Container(\n                color: _containerColor,\n                child: Column(\n                  mainAxisAlignment: MainAxisAlignment.center,\n                  children: \u003cWidget\u003e[\n                    Row(),\n                    FlutterLogo(size: 100),\n                    Text(\n                      'Shape: ${shape == Shape.round ? 'round' : 'square'}',\n                      style: TextStyle(color: _textColor),\n                    ),\n                    Text(\n                      'Mode: ${mode == Mode.active ? 'Active' : 'Ambient'}',\n                      style: TextStyle(color: _textColor),\n                    ),\n                  ],\n                ),\n              );\n            }),\n          ),\n        ),\n      ),\n    );\n  }\n}\n```\n## License\n\nCopyright (c) 2020 Souvik Biswas\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsbis04%2Fflutter_wear","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsbis04%2Fflutter_wear","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsbis04%2Fflutter_wear/lists"}