wearthat 0.0.2-alpha1 copy "wearthat: ^0.0.2-alpha1" to clipboard
wearthat: ^0.0.2-alpha1 copied to clipboard

PlatformAndroid

A one-stop shop for all things related to WearOS (Including sending messages between devices, tiles, fitted widgets and more).

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:wearthat/tiles.dart';
import 'package:wear_example/models/todo.dart';
import 'package:wear_example/repositories/todo.dart';
import 'package:wear_example/tiles/progress.dart';
import 'package:wear_example/tiles/reminder.dart';
import 'package:wear_example/views/mark_as_done.dart';
import 'package:wear_example/views/watch.dart';

@pragma('vm:entry-point')
void maintile(List<String> args) {
  runTiles(
    [
      TileService(
        name: "ExampleTile",
        routes: {
          '/': () => ProgressTile(),
          '/reminder': () => ReminderTile(),
        },
      ),
    ],
  );
}

Future<void> main(List<String> args) async {
  WidgetsFlutterBinding.ensureInitialized();

  const repo = TodoRepository();
  if (await repo.count() == 0) {
    final todos = [
      Todo(id: 1, title: "Buy some milk"),
      Todo(id: 2, title: "Read a book", done: true),
      Todo(
          id: 3,
          title: "Call mom",
          due: DateTime.now().add(const Duration(days: 3))),
      Todo(
          id: 4,
          title: "Call dad",
          due: DateTime.now().add(const Duration(days: -2))),
    ];
    repo.setAll(todos);
  }

  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData.light(),
      home: SafeArea(
        child: Scaffold(
          body: LayoutBuilder(
            builder: (context, constraints) {
              //return constraints.maxWidth >= 350 ? const PhoneView() : const WearView();
              return const WearView();
            },
          ),
        ),
      ),
      routes: {
        '/mark': (context) {
          return const Scaffold(
            body: MarkTodoAsDone(),
          );
        },
      },
    );
  }
}
13
likes
150
points
48
downloads

Publisher

unverified uploader

Weekly Downloads

A one-stop shop for all things related to WearOS (Including sending messages between devices, tiles, fitted widgets and more).

Repository (GitHub)
View/report issues

Documentation

API reference

License

Apache-2.0 (license)

Dependencies

flutter, plugin_platform_interface, xml, yaml

More

Packages that depend on wearthat

Packages that implement wearthat