Advertisement
Hitesh_jadhav

flutter_null

Feb 12th, 2022
21
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.77 KB | None | 0 0
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_proj/model/weather_model.dart';
  3. import 'package:flutter_proj/services/weather_api_client.dart';
  4. import 'package:flutter_proj/views/additional_info.dart';
  5. import 'package:flutter_proj/views/current_wheather.dart';
  6.  
  7. void main() => runApp(MaterialApp(
  8. home: Homepage(),
  9. ));
  10.  
  11. class Homepage extends StatefulWidget {
  12. const Homepage({Key? key}) : super(key: key);
  13.  
  14. @override
  15. _HomepageState createState() => _HomepageState();
  16. }
  17.  
  18. class _HomepageState extends State<Homepage> {
  19. Weatherapiclient client = Weatherapiclient();
  20. Weather? data;
  21.  
  22. // @override
  23. // void initState() {
  24. // // TODO: implement initState
  25. // super.initState();
  26. // client.getcurrentweather("London");
  27. // }
  28. Future<void> getdata() async {
  29. data = await client.getcurrentweather("Georgia");
  30. }
  31.  
  32. @override
  33. Widget build(BuildContext context) {
  34. return Scaffold(
  35. backgroundColor: Color(0xFFf9f9f9),
  36. appBar: AppBar(
  37. backgroundColor: Color(0xFFf9f9f9),
  38. elevation: 0,
  39. title: const Text("Weather App"),
  40. centerTitle: true,
  41. leading: IconButton(
  42. onPressed: () {},
  43. icon: Icon(Icons.menu),
  44. color: Colors.black,
  45. ),
  46. ),
  47. body: FutureBuilder(
  48. future: getdata(),
  49. builder: (context, snapshot) {
  50. if (snapshot.connectionState == ConnectionState.done) {
  51. print("in builder");
  52. return Column(
  53. crossAxisAlignment: CrossAxisAlignment.center,
  54. children: [
  55. currentweather(Icons.wb_sunny_rounded, "${data!.temp} K",
  56. "${data!.cityname}"),
  57. SizedBox(
  58. height: 20,
  59. ),
  60. Text(
  61. "Additional Information",
  62. style: TextStyle(
  63. fontSize: 24,
  64. color: Color(0xdd212121),
  65. fontWeight: FontWeight.bold,
  66. ),
  67. ),
  68. Divider(),
  69. SizedBox(
  70. height: 20,
  71. ),
  72. additionalinofrmation("${data!.wind}", "${data!.humidity}",
  73. "${data!.pressure}", "${data!.feels_like}"),
  74. ],
  75. );
  76. } else if (snapshot.connectionState == ConnectionState.waiting) {
  77. return Center(
  78. child: CircularProgressIndicator.adaptive(),
  79. );
  80. }
  81. return Container(
  82. child:
  83. Text("hityyedcwfuvweyvfuweybfuweybfuyewbfuyew"),
  84. );
  85. },
  86. ));
  87. }
  88. }
  89.  
  90.  
  91.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement