flutter_weather_forecast

用于土耳其的天气预报小部件。天气数据由气象总局提供。

演示

安装

dependencies:
  flutter_weather_forecast: ^1.1.2

使用方法

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

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

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(title: 'Weather Forecast by @coskuncay'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key, required this.title}) : super(key: key);

  final String title;

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

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: SingleChildScrollView(
        child: Column(
          children: const [
            WeatherForecast(),
            WeatherForecast(
              stationNo: '32',
            ),
            WeatherForecast(
              stationNo: '34',
            ),
            WeatherForecast(
              stationNo: '36',
            ),
            WeatherForecast(
              stationNo: '01',
            ),
            WeatherForecast(
              stationNo: '43',
            ),
          ],
        ),
      ),
    );
  }
}

天气预报

名称 类型 默认值
stationNo 字符串 必需
keyFontSize 双精度 13
valueFontSize 双精度 11
statusFontSize 双精度 16
weatherFontSize 双精度 26
timeFontSize 双精度 13
refreshIconSize 双精度 20
imageScale 双精度 .8
containerHeight 双精度 ScreenHeight * .15
borderColor 颜色 Color(0XFFACAEBA)
keyColor 颜色 Color(0XFFACAEBA)
valueColor 颜色 Colors.black
weatherColor 颜色 Colors.black
timeColor 颜色 Color(0XFFACAEBA)
backgroundColor 颜色 Colors.white
statusColor 颜色 Colors.black
verticalPadding 双精度 8
horizontalPadding 双精度 8

许可证

MIT 版权所有 (c) 2022,Emre Coşkunçay

GitHub

查看 Github