Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'package:flutter/material.dart';
- import 'package:flutter_proj/model/weather_model.dart';
- import 'package:flutter_proj/services/weather_api_client.dart';
- import 'package:flutter_proj/views/additional_info.dart';
- import 'package:flutter_proj/views/current_wheather.dart';
- void main() => runApp(MaterialApp(
- home: Homepage(),
- ));
- class Homepage extends StatefulWidget {
- const Homepage({Key? key}) : super(key: key);
- @override
- _HomepageState createState() => _HomepageState();
- }
- class _HomepageState extends State<Homepage> {
- Weatherapiclient client = Weatherapiclient();
- Weather? data;
- // @override
- // void initState() {
- // // TODO: implement initState
- // super.initState();
- // client.getcurrentweather("London");
- // }
- Future<void> getdata() async {
- data = await client.getcurrentweather("Georgia");
- }
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- backgroundColor: Color(0xFFf9f9f9),
- appBar: AppBar(
- backgroundColor: Color(0xFFf9f9f9),
- elevation: 0,
- title: const Text("Weather App"),
- centerTitle: true,
- leading: IconButton(
- onPressed: () {},
- icon: Icon(Icons.menu),
- color: Colors.black,
- ),
- ),
- body: FutureBuilder(
- future: getdata(),
- builder: (context, snapshot) {
- if (snapshot.connectionState == ConnectionState.done) {
- print("in builder");
- return Column(
- crossAxisAlignment: CrossAxisAlignment.center,
- children: [
- currentweather(Icons.wb_sunny_rounded, "${data!.temp} K",
- "${data!.cityname}"),
- SizedBox(
- height: 20,
- ),
- Text(
- "Additional Information",
- style: TextStyle(
- fontSize: 24,
- color: Color(0xdd212121),
- fontWeight: FontWeight.bold,
- ),
- ),
- Divider(),
- SizedBox(
- height: 20,
- ),
- additionalinofrmation("${data!.wind}", "${data!.humidity}",
- "${data!.pressure}", "${data!.feels_like}"),
- ],
- );
- } else if (snapshot.connectionState == ConnectionState.waiting) {
- return Center(
- child: CircularProgressIndicator.adaptive(),
- );
- }
- return Container(
- child:
- Text("hityyedcwfuvweyvfuweybfuweybfuyewbfuyew"),
- );
- },
- ));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement