Flutter实战1 --- 写一个天气查询的APP,推荐给大家

2.运行Flutter工程

  1. 连接手机
  • 这里不建议用模拟器,因为模拟器在用GPU渲染时可能会出问题,导致图片渲染不出来。
  1. 然后按Run 在手机上把程序跑起来。

3.天气API接口申请

注册地址console.heweather.com/register

注册完后,再看API文档 www.heweather.com/documents

demo这里用的是,获取当天天气情况的API:www.heweather.com/documents/a…

用的请求URL如下:

https://free-api.heweather.com/s6/weather/now?location=广州&key=****** 

4.界面编写

在创建的工程里,有个main.dart里面有一段显示界面的代码如下:

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        // This is the theme of your application.
        //
        // Try running your application with "flutter run". You'll see the
        // application has a blue toolbar. Then, without quitting the app, try
        // changing the primarySwatch below to Colors.green and then invoke
        // "hot reload" (press "r" in the console where you ran "flutter run",
        // or press Run > Flutter Hot Reload in a Flutter IDE). Notice that the
        // counter 

你可能感兴趣的:(Android,flutter,小程序,html,移动开发)