Skip to content

Commit 299b29c

Browse files
author
Csongor Keller
committed
better documentation added to comply with public_member_api_docs
1 parent dcd0d52 commit 299b29c

24 files changed

+647
-203
lines changed

analysis_options.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
linter:
2+
rules:
3+
- public_member_api_docs

example/lib/main.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,13 @@ void main() {
55
runApp(const MyApp());
66
}
77

8+
/// A simple Flutter application that demonstrates the usage of prebuilt widgets.
9+
///
10+
/// This widget is the root of the application and sets up the main [MaterialApp].
11+
812
class MyApp extends StatelessWidget {
13+
/// The [MyApp] class is a stateless widget that represents the entire application.
14+
/// It is marked as `const` to indicate that it is immutable and can be instantiated as a compile-time constant.
915
const MyApp({super.key});
1016

1117
@override

example/lib/modules/location_view_widget.dart

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,42 @@
11
import 'package:flutter/material.dart';
22
import 'package:intl/intl.dart';
33

4+
/// A widget that displays a location view with a title and the current date.
5+
///
6+
/// The [LocationViewWidget] is a stateless widget that takes a [title] and a [color]
7+
/// as required parameters. It displays the [title] in uppercase with a specified
8+
/// [color] and the current date and time in the format 'yyyy/MM/dd – kk:mm'.
9+
///
10+
/// {@tool snippet}
11+
/// This example shows how to use the [LocationViewWidget] with a title and color:
12+
///
13+
/// ```dart
14+
/// LocationViewWidget(
15+
/// title: 'New York',
16+
/// color: Colors.blue,
17+
/// )
18+
/// ```
19+
/// {@end-tool}
20+
///
21+
/// The [title] is displayed in uppercase with a font size of 40 and a font weight
22+
/// of 300. The current date and time are displayed below the title.
23+
///
24+
/// See also:
25+
/// * [DateFormat], which is used to format the current date and time.
426
class LocationViewWidget extends StatelessWidget {
27+
/// Creates a [LocationViewWidget].
28+
///
29+
/// The [title] and [color] parameters must not be null.
530
const LocationViewWidget({
631
super.key,
732
required this.title,
833
required this.color,
934
});
1035

36+
/// The color to use for the title text.
1137
final Color color;
38+
39+
/// The title to display in the widget.
1240
final String title;
1341

1442
@override

example/lib/modules/weather_summary_widget.dart

Lines changed: 41 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,24 @@
11
import 'package:flutter/material.dart';
22
import 'package:transparent_image/transparent_image.dart';
33

4+
/// A widget that displays a summary of the weather information.
5+
///
6+
/// The [WeatherSummary] widget shows an image representing the weather,
7+
/// the current temperature, maximum and minimum temperatures, humidity,
8+
/// and pressure.
9+
///
10+
/// The widget requires the following parameters:
11+
/// - [imageUrl]: The URL of the image representing the weather.
12+
/// - [currentTemperature]: The current temperature.
13+
/// - [color]: The color to be used for the text and icons.
14+
/// - [maxTemperature]: The maximum temperature.
15+
/// - [minTemperature]: The minimum temperature.
16+
/// - [humidity]: The humidity percentage.
17+
/// - [pressure]: The atmospheric pressure in hPa.
418
class WeatherSummary extends StatelessWidget {
19+
/// The [WeatherSummary] widget shows an image representing the weather,
20+
/// the current temperature, maximum and minimum temperatures, humidity,
21+
/// and pressure.
522
const WeatherSummary({
623
super.key,
724
required this.imageUrl,
@@ -13,14 +30,31 @@ class WeatherSummary extends StatelessWidget {
1330
required this.pressure,
1431
});
1532

33+
/// The color to be used for the text and icons.
1634
final Color color;
35+
36+
/// The current temperature.
1737
final String currentTemperature;
38+
39+
/// The humidity percentage.
1840
final String humidity;
41+
42+
/// The URL of the image representing the weather.
1943
final String imageUrl;
44+
45+
/// The maximum temperature.
2046
final String maxTemperature;
47+
48+
/// The minimum temperature.
2149
final String minTemperature;
50+
51+
/// The atmospheric pressure in hPa.
2252
final String pressure;
2353

54+
/// Builds a row displaying an icon and a temperature.
55+
///
56+
/// The [icon] parameter specifies the icon to be displayed.
57+
/// The [temperature] parameter specifies the temperature to be displayed.
2458
Widget _buildMinMaxRow({
2559
required IconData icon,
2660
required String temperature,
@@ -38,6 +72,10 @@ class WeatherSummary extends StatelessWidget {
3872
);
3973
}
4074

75+
/// Builds a row displaying the humidity and pressure.
76+
///
77+
/// The [humidity] parameter specifies the humidity percentage to be displayed.
78+
/// The [pressure] parameter specifies the atmospheric pressure to be displayed.
4179
Widget _buildHumidutyAndPressureRow({
4280
required String humidity,
4381
required String pressure,
@@ -100,22 +138,17 @@ class WeatherSummary extends StatelessWidget {
100138
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
101139
children: [
102140
Container(
103-
child: _buildMinMaxRow(
104-
icon: Icons.arrow_drop_up_sharp,
105-
temperature: maxTemperature),
141+
child: _buildMinMaxRow(icon: Icons.arrow_drop_up_sharp, temperature: maxTemperature),
106142
),
107143
Container(
108-
child: _buildMinMaxRow(
109-
icon: Icons.arrow_drop_down_sharp,
110-
temperature: minTemperature),
144+
child: _buildMinMaxRow(icon: Icons.arrow_drop_down_sharp, temperature: minTemperature),
111145
),
112146
],
113147
),
114148
),
115149
Padding(
116150
padding: const EdgeInsets.only(top: 20),
117-
child: _buildHumidutyAndPressureRow(
118-
humidity: humidity, pressure: pressure),
151+
child: _buildHumidutyAndPressureRow(humidity: humidity, pressure: pressure),
119152
)
120153
],
121154
);

example/lib/screens/prebuilt_functions_demo_screen.dart

Lines changed: 38 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1+
// ignore_for_file: unused_element
2+
13
import 'package:example/modules/location_view_widget.dart';
24
import 'package:example/modules/weather_summary_widget.dart';
35
import 'package:flutter/material.dart';
46
import 'package:open_weather_client/open_weather.dart';
57

8+
/// A screen that demonstrates the use of prebuilt functions from the OpenWeather package.
69
class PrebuiltFunctionScreen extends StatefulWidget {
10+
/// Creates a [PrebuiltFunctionScreen].
711
const PrebuiltFunctionScreen({super.key});
812

913
@override
@@ -33,49 +37,55 @@ class _PrebuiltFunctionScreenState extends State<PrebuiltFunctionScreen> {
3337
// });
3438
}
3539

36-
// ignore: unused_element
40+
/// Fetches the current weather data by city name.
41+
///
42+
/// Returns a [WeatherData] object containing the current weather information.
3743
Future<WeatherData> _getCurrentweatherByCity() async {
38-
return openWeather.currentWeatherByCityName(
39-
cityName: _cityName, weatherUnits: WeatherUnits.METRIC);
44+
return openWeather.currentWeatherByCityName(cityName: _cityName, weatherUnits: WeatherUnits.METRIC);
4045
}
4146

42-
// ignore: unused_element
47+
/// Fetches the current weather data by geographic location.
48+
///
49+
/// Returns a [WeatherData] object containing the current weather information.
4350
Future<WeatherData> _getCurrentweatherByLocation() async {
4451
return openWeather.currentWeatherByLocation(
45-
latitude: _latitude,
46-
longitude: _longitude,
47-
weatherUnits: WeatherUnits.METRIC);
52+
latitude: _latitude, longitude: _longitude, weatherUnits: WeatherUnits.METRIC);
4853
}
4954

55+
/// Fetches the current weather data by zip code.
56+
///
57+
/// Returns a [WeatherData] object containing the current weather information.
5058
Future<WeatherData> _getCurrentweatherByZipCode() async {
5159
return openWeather.currentWeatherByZipCode(
52-
zipCode: _zipCode,
53-
countryCode: _countryCode,
54-
weatherUnits: WeatherUnits.METRIC);
60+
zipCode: _zipCode, countryCode: _countryCode, weatherUnits: WeatherUnits.METRIC);
5561
}
5662

57-
// ignore: unused_element
63+
/// Fetches the five-day weather forecast by city name.
64+
///
65+
/// Returns a [WeatherForecastData] object containing the weather forecast information.
5866
Future<WeatherForecastData> _getFiveDaysForecastByCityName() async {
59-
return openWeather.fiveDaysWeatherForecastByCityName(
60-
cityName: _cityName, weatherUnits: WeatherUnits.METRIC);
67+
return openWeather.fiveDaysWeatherForecastByCityName(cityName: _cityName, weatherUnits: WeatherUnits.METRIC);
6168
}
6269

63-
// ignore: unused_element
70+
/// Fetches the five-day weather forecast by geographic location.
71+
///
72+
/// Returns a [WeatherForecastData] object containing the weather forecast information.
6473
Future<WeatherForecastData> _getFiveDaysForecastByLocation() async {
6574
return openWeather.fiveDaysWeatherForecastByLocation(
66-
latitude: _latitude,
67-
longitude: _longitude,
68-
weatherUnits: WeatherUnits.METRIC);
75+
latitude: _latitude, longitude: _longitude, weatherUnits: WeatherUnits.METRIC);
6976
}
7077

71-
// ignore: unused_element
78+
/// Fetches the five-day weather forecast by zip code.
79+
///
80+
/// Returns a [WeatherForecastData] object containing the weather forecast information.
7281
Future<WeatherForecastData> _getFiveDaysForecastByZipCode() async {
7382
return openWeather.fiveDaysWeatherForecastByZipCode(
74-
zipCode: _zipCode,
75-
countryCode: _countryCode,
76-
weatherUnits: WeatherUnits.METRIC);
83+
zipCode: _zipCode, countryCode: _countryCode, weatherUnits: WeatherUnits.METRIC);
7784
}
7885

86+
/// Builds a button that navigates back to the previous screen.
87+
///
88+
/// Returns an [ElevatedButton] widget.
7989
Widget _buildButton() {
8090
return ElevatedButton(
8191
child: const Text('Check with prebuilt widgets'),
@@ -93,9 +103,7 @@ class _PrebuiltFunctionScreenState extends State<PrebuiltFunctionScreen> {
93103
backgroundColor: Colors.white,
94104
elevation: 0,
95105
title: const Text('OpenWeather prebuilt functions',
96-
style: TextStyle(color: Colors.black),
97-
maxLines: 2,
98-
textAlign: TextAlign.center),
106+
style: TextStyle(color: Colors.black), maxLines: 2, textAlign: TextAlign.center),
99107
),
100108
body: Container(
101109
width: double.infinity,
@@ -113,19 +121,12 @@ class _PrebuiltFunctionScreenState extends State<PrebuiltFunctionScreen> {
113121
),
114122
WeatherSummary(
115123
color: Colors.black,
116-
imageUrl:
117-
'https://openweathermap.org/img/wn/${snapshot.data!.details.first.icon}@2x.png',
118-
currentTemperature: snapshot
119-
.data!.temperature.currentTemperature
120-
.toString(),
121-
maxTemperature:
122-
snapshot.data!.temperature.tempMax.toString(),
123-
minTemperature:
124-
snapshot.data!.temperature.tempMin.toString(),
125-
humidity:
126-
snapshot.data!.temperature.humidity.toString(),
127-
pressure:
128-
snapshot.data!.temperature.pressure.toString(),
124+
imageUrl: 'https://openweathermap.org/img/wn/${snapshot.data!.details.first.icon}@2x.png',
125+
currentTemperature: snapshot.data!.temperature.currentTemperature.toString(),
126+
maxTemperature: snapshot.data!.temperature.tempMax.toString(),
127+
minTemperature: snapshot.data!.temperature.tempMin.toString(),
128+
humidity: snapshot.data!.temperature.humidity.toString(),
129+
pressure: snapshot.data!.temperature.pressure.toString(),
129130
),
130131
_buildButton()
131132
],

example/lib/screens/prebuilt_widgets_demo_screen.dart

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,34 @@ import 'package:flutter/material.dart';
33
import 'package:open_weather_client/enums/languages.dart';
44
import 'package:open_weather_client/open_weather.dart';
55

6+
/// A screen that demonstrates the use of prebuilt widgets from the OpenWeather package.
67
class PrebuiltWidgetsScreen extends StatefulWidget {
8+
/// Creates a [PrebuiltWidgetsScreen].
79
const PrebuiltWidgetsScreen({super.key});
810

911
@override
1012
State<PrebuiltWidgetsScreen> createState() => _PrebuiltWidgetsScreenState();
1113
}
1214

1315
class _PrebuiltWidgetsScreenState extends State<PrebuiltWidgetsScreen> {
16+
/// The name of the city for which to display weather information.
1417
final String _cityName = 'Miami';
18+
19+
/// The API key for accessing the OpenWeather API.
1520
final String _key = 'c4bbb94f9fcfede0eb5219111804b040';
21+
22+
/// The latitude of the location for which to display weather information.
1623
final double _latitude = 52.3545828;
24+
25+
/// The longitude of the location for which to display weather information.
1726
final double _longitude = 4.7638781;
1827

28+
/// Builds a button that navigates to the [PrebuiltFunctionScreen].
1929
Widget _buildButton() {
2030
return ElevatedButton(
2131
child: const Text('Check with prebuilt functions'),
22-
onPressed: () => Navigator.push(
23-
context,
24-
MaterialPageRoute(
25-
builder: (BuildContext context) =>
26-
const PrebuiltFunctionScreen())),
32+
onPressed: () =>
33+
Navigator.push(context, MaterialPageRoute(builder: (BuildContext context) => const PrebuiltFunctionScreen())),
2734
);
2835
}
2936

0 commit comments

Comments
 (0)