Git Product home page Git Product logo

flutter_os_wear's Introduction

Flutter OS (Android Wear OS app)

Checkout my Medium article "Flutter: Building Wear OS app".

First of all I want to state that it is not an OS, it is just an app.

This is an app for Wear OS devices which is inspired from the Medium article written by Matt Sullivan, "Experimenting with Flutter on Wear OS". This article really helped me to understand, how to manage the screen size of the app properly and inheriting it to different classes.

In this app, I tried to optimize the relax app created by Erin Morrissey (made as a Flutter Create Submission 2019, which got nominated for Visual Beauty), to run on Wear OS devices.

The wear app has two modes:

  1. Normal Mode
  2. Ambient Mode (which is the battery saving mode)

You can checkout some snaps of the app below.

Screenshots

App in Action

Plugin

The plugin used in this project is "wear".

Add this to your package's pubspec.yaml file to use wear:

dependencies:
  wear: ^0.0.3

Import using:

import 'package:wear/wear.dart';

Set Up (Important)

Matt has already discussed, in his GitHub project of flutter_wear_plugin, how to set up the project for Flutter Wear OS apps. But, I faced a lot of difficulty while following the steps. So, I recommend that you clone my project or Matt's example project and then work on it, after deleting the UI files which you don't require, because in this way you do not need to set up the whole project which consumes a huge amount of time and you will face a lot of challenges.

I am again stating the set up process below (not recommended):

App Gradle File

Change the min SDK version to API 23:

minSdkVersion 23

Then, add the following dependencies to the Android Gradle file for the app:

dependencies {
    // Wear libraries
    implementation 'com.android.support:wear:27.1.1'
    implementation 'com.google.android.support:wearable:2.3.0'
    compileOnly 'com.google.android.wearable:wearable:2.3.0'
}

Manifest File

Add the following to your AndroidManifest.xml file:

<!-- Required for ambient mode support -->
<uses-permission android:name="android.permission.WAKE_LOCK" />

<!-- Flags the app as a Wear app -->
<uses-feature android:name="android.hardware.type.watch" />

<!-- Flags that the app doesn't require a companion phone app -->
<application>
<meta-data
    android:name="com.google.android.wearable.standalone"
    android:value="true" />
</application>

Update Android's MainActivity

The ambient mode widget needs some initialization in Android's MainActivity code. Update your code as follows:

class MainActivity: FlutterActivity(), AmbientMode.AmbientCallbackProvider {
  override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    GeneratedPluginRegistrant.registerWith(this)

    // Wire up the activity for ambient callbacks
    AmbientMode.attachAmbientSupport(this)
  }

  override fun getAmbientCallback(): AmbientMode.AmbientCallback {
    return FlutterAmbientCallback(getChannel(flutterView))
  }
}

Conclusion

After creating this project, I admit that Flutter is not optimized for Wear OS devices till now as many of the simple things are not working on Wear OS like all material Icons which are included in Flutter are not displaying on Wear OS devices, instead a Placeholder image is getting displayed. For this reason, I had to download the material Icons for the Material Design website and add it to assets.

Though after facing a lot of difficulties I have finally done this project.

If you like the project please give star ⭐️.

License

Copyright (c) 2019 Souvik Biswas

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

flutter_os_wear's People

Contributors

sbis04 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

flutter_os_wear's Issues

Not an issue but a question

I got your example working on the android wear emulator.

However I need a lot more functionality in my app because I would like to be able to login with firebase and receive FCM notification.

But the problem is that the login returns "firebaseAuth: API not available" and I am stuck. There are no other Flutter tutorials with wear OS on the internet and therefore I hoped that it would be ok if I asked you if you possibly can help since you know how wearOS works with flutter.

Invalid `Podfile` file: no implicit conversion of nil into String. I am trying to build for Apple Watch

Running pod install...
CocoaPods' output:

[!] Invalid `Podfile` file: no implicit conversion of nil into String.

 #  from /Volumes/Storage/Bottle/Wearables/flutter_os_wear/ios/Podfile:60
 #  -------------------------------------------
 #      unless File.exist?(copied_podspec_path)
 >        FileUtils.cp(File.join(cached_framework_dir, 'Flutter.podspec'), copied_flutter_dir)
 #      end
 #  -------------------------------------------

/Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.9.3/lib/cocoapods-core/podfile.rb:301:in `rescue in block in from_ruby'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.9.3/lib/cocoapods-core/podfile.rb:295:in `block in from_ruby'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.9.3/lib/cocoapods-core/podfile.rb:50:in `instance_eval'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.9.3/lib/cocoapods-core/podfile.rb:50:in `initialize'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.9.3/lib/cocoapods-core/podfile.rb:293:in `new'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.9.3/lib/cocoapods-core/podfile.rb:293:in `from_ruby'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.9.3/lib/cocoapods-core/podfile.rb:259:in `from_file'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/config.rb:200:in `podfile'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/command.rb:150:in `verify_podfile_exists!'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/command/install.rb:46:in `run'
/Library/Ruby/Gems/2.6.0/gems/claide-1.0.3/lib/claide/command.rb:334:in `run'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/command.rb:52:in `run'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.3/bin/pod:55:in `<top (required)>'
/usr/local/bin/pod:23:in `load'
/usr/local/bin/pod:23:in `<main>'

Error output from CocoaPods:

Ignoring ffi-1.12.2 because its extensions are not built. Try: gem pristine ffi --version 1.12.2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.