生成函数返回null。扑应用

时间:2020-04-17 01:02:09

标签: flutter dart flutter-layout

导航器试图通过菜单制作地图,但返回错误

没有功能。我不知道该怎么办。 没有功能。我不知道该怎么办。可以帮我 没有功能。我不知道该怎么办。可以帮我 没有功能。我不知道该怎么办。可以帮我 没有功能。我不知道该怎么办。可以帮助我

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_map/flutter_map.dart';
import 'package:latlong/latlong.dart';

class DefaultContainerScreen extends StatelessWidget {
  DefaultContainerScreen();
  @override
  Widget build(BuildContext context) {
    new FlutterMap(
        options: new MapOptions(
            center: new LatLng(40.71, -74.00), minZoom: 10.0),
        layers: [
          new TileLayerOptions(
              urlTemplate:
              "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
              subdomains: ['a', 'b', 'c']),
          new MarkerLayerOptions(markers: [
            new Marker(
                width: 45.0,
                height: 45.0,
                point: new LatLng(40.73, -74.00),
                builder: (context) =>
                new Container(
                  child: IconButton(
                    icon: Icon(Icons.location_on),
                    color: Colors.red,
                    iconSize: 45.0,
                    onPressed: () {
                      print('Marker tapped');
                    },
                  ),
                )
            )
          ])
        ]);

  }

}

导航器

    import 'package:app/Constant/Constant.dart';
import 'package:app/Screens/DefaultContainer.dart';
import 'package:app/Screens/PhotoContainerScreen.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';


class HomeScreen extends StatefulWidget {
  @override
  HomeScreenState createState() => new HomeScreenState();
}

class HomeScreenState extends State<HomeScreen> {
  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: AppBar(
        title: const Text("app"),
        actions: <Widget>[
          new IconButton(
              icon: new Icon(Icons.search), onPressed: () {}),
          new IconButton(
              icon: new Icon(Icons.more_vert), onPressed: () {})
        ],
      ),
      drawer: new Drawer(
          child: new ListView(
        children: <Widget>[

          new Container(child: Padding(
            padding: const EdgeInsets.all(30.0),
            child: new Image.asset('assets/images/logo.png'),
          ),color: Color(0xFFf0f0f0),)

          ,
          new ListTile(
            leading: new Icon(Icons.account_circle),
            title: new Text("Account"),
            trailing: new Text("96",style: TextStyle(fontWeight: FontWeight.bold),),

            onTap: () {
              Navigator.pop(context);
              Navigator.of(context).pushNamed(PHOTO_CONTAINER_SCREEN);
            },
          ),
          new ListTile(
            leading: new Icon(Icons.settings),
            title: new Text("settings"),
            trailing: new Text("58",style: TextStyle(fontWeight: FontWeight.bold),),

            onTap: () {
              Navigator.pop(context);
              Navigator.of(context).pushNamed(VIDEO_CONTAINER_SCREEN);
            },
          ),
          new ListTile(
            leading: new Icon(Icons.vpn_key),
            trailing: new Text("56",style: TextStyle(fontWeight: FontWeight.bold),),

            title: new Text("login"),
            onTap: () {
              Navigator.pop(context);
              Navigator.of(context).pushNamed(ALBUM_CONTAINER_SCREEN);
            },
          )
        ],
      )),
      body: new DefaultContainerScreen()
    );
    // TODO: implement build
  }
}

1 个答案:

答案 0 :(得分:1)

好吧,首先添加一个return关键字:

Widget build(BuildContext context) {
    return new FlutterMap(