weather_kit 0.3.0 copy "weather_kit: ^0.3.0" to clipboard
weather_kit: ^0.3.0 copied to clipboard

A dart library for interfacing with the Apple WeatherKit API.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:weather_kit/weather_kit.dart';

void main() {
  runApp(const MyApp());
}

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Weather Kit DEMO',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(),
    );
  }
}

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

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('weather kit demo'),
      ),
      body: Center(
          child: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          ElevatedButton(
            onPressed: () async {
              const pem = """
""";
              final weatherKit = WeatherKit();
              final jwt = weatherKit.generateJWT(
                bundleId: 'com.ai.hokusai',
                teamId: 'T4W85DPBVX',
                keyId: 'RFC9H5A57J',
                pem: pem,
                expiresIn: const Duration(hours: 1),
              );
              final now = DateTime.now();
              // final currentWeather = await weatherKit.obtainWeatherData(
              //   jwt: jwt,
              //   language: 'ja',
              //   latitude: 35.91238777,
              //   longitude: 139.60285321,
              //   dataSets: DataSet.currentWeather,
              //   timezone: 'Asia/Tokyo',
              //   countryCode: 'JP',
              //   currentAsOf: now.add(
              //     const Duration(days: -1),
              //   ),
              // );
              // final availability = await weatherKit.obtainAvailability(
              //   country: 'JP',
              //   jwt: jwt,
              //   latitude: 35.91238777,
              //   longitude: 139.60285321,
              // );
            },
            child: const Text('Generate JWT'),
          )
        ],
      )),
    );
  }
}
15
likes
160
pub points
57%
popularity

Publisher

verified publishermafreud.dev

A dart library for interfacing with the Apple WeatherKit API.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

dart_jsonwebtoken, flutter, http

More

Packages that depend on weather_kit