包:google_maps_flutter_platform_interface/src/types/camera.dart':失败的断言:第 24 行 pos 16:'target != null':不是真的

时间:2021-04-27 13:31:05

标签: android flutter

我遇到以下错误

MainScreen file:///C:/Users/Chris/AndroidStudioProjects/taxi_rider/lib/main.dart:77:32
When the exception was thrown, this was the stack: 
#2      new CameraPosition (package:google_maps_flutter_platform_interface/src/types/camera.dart:24:16)
#3      _MainScreenState.build (package:taxi_rider/UI/views/MainScreen.dart:180:40)
#4      StatefulElement.build (package:flutter/src/widgets/framework.dart:4612:27)
#5      ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4495:15)
#6      StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4667:11)

相关的导致错误的小部件是:

    class MainScreen extends StatefulWidget {
      // Material Page Route
      static const route = "/mainScreen";
    
      // Tag for logging
      static const TAG = "MainScreen";
    
      @override
      _MainScreenState createState() => _MainScreenState();
    }
    
    class _MainScreenState extends State<MainScreen> with TickerProviderStateMixin {
      AnimationController loadingController;
      Animation<double> animation;
    
      final mapScreenScaffoldKey = GlobalKey<ScaffoldState>();
    
      static final CameraPosition _kGooglePlex = CameraPosition(
        target: LatLng(37.42796133580664, -122.085749655962),
        zoom: 14.4746,
      );
    
    
    
    
    
      bool drawerOpen = true;
    
      resetApp()
      {
        setState(() {
          drawerOpen = true;
    
    
        });
    
    
      }
    
    
      @override
      void initState() {
        super.initState();
        loadingController =
            AnimationController(vsync: this, duration: Duration(seconds: 35));
        animation = Tween<double>(begin: 0, end: 40).animate(new CurvedAnimation(
            parent: loadingController, curve: Curves.easeInOutCirc));
        loadingController.addStatusListener((AnimationStatus status) {
          if (status == AnimationStatus.completed) {
            loadingController.reverse(from: 5);
          }
        });
        //to activate later
        //loadingController.forward();
      }
    
      @override
      void dispose() {
        super.dispose();
        loadingController.dispose();
      }
    
      @override
      Widget build(BuildContext context) {
        final mapModel = Provider.of<MapModel>(context);
        final userDetailsModel = Provider.of<UserDetailsModel>(context);
        final uiNotifiersModel = Provider.of<UINotifiersModel>(context);
    
    
    
        return Material(
          child: Scaffold(
              resizeToAvoidBottomInset: true,
    
              key: scaffoldkey,
    
              drawer: Container(
                color: Colors.white,
                width: 270.0,
                child: Drawer(
                  child: ListView(
                    children: [
                      //Drawer Header
                      Container(
                        height: 165.0,
                        child: DrawerHeader(
                          decoration: BoxDecoration(color: Colors.white),
                          child: Row(
                            children: [
                              Image.asset("images/user_icon.png", height: 65.0, width: 65.0,),
                              SizedBox(width: 16.0,),
                              Column(
                                mainAxisAlignment: MainAxisAlignment.center,
                                children: [
                                  Text("Profile Name", style: TextStyle(fontSize: 16.0, fontFamily: "Brand-Bold"),),
                                  SizedBox(height: 6.0,),
                                  Text("View Profile"),
                                ],
                              ),
                            ],
                          ),
                        ),
    
                      ),
    
                      DividerMap(),
    
                      SizedBox(height: 12.0,),
    
                      //Drawer Body Controllers
                      ListTile(
                        leading: Icon(Icons.payments_outlined),
                        title: Text("Payments", style: TextStyle(fontSize: 15.0),),
                      ),
                      ListTile(
                        leading: Icon(Icons.history),
                        title: Text("Ride History", style: TextStyle(fontSize: 15.0),),
                      ),
                      ListTile(
                        leading: Icon(Icons.chat_outlined),
                        title: Text("Support", style: TextStyle(fontSize: 15.0),),
                      ),
                      ListTile(
                        leading: Icon(Icons.add_business_outlined),
                        title: Text("About Us", style: TextStyle(fontSize: 15.0),),
                      ),
                      GestureDetector(
                        onTap: ()
                        {
                          FirebaseAuth.instance.signOut();
                          Navigator.pushNamedAndRemoveUntil(context, SignInPage.route, (route) => false);
                        },
                        child: ListTile(
                          leading: Icon(Icons.add_business_outlined),
                          title: Text("Sign Out", style: TextStyle(fontSize: 15.0),),
                        ),
                      ),
    
    
                    ],
                  ),
                ),
              ),
    
              body: Stack(
                children: <Widget>[
    
                  GoogleMap(
    
                    padding: EdgeInsets.only(bottom: 150.0, top: 100.0),
                    initialCameraPosition: CameraPosition(
                        target: mapModel.currentPosition,
                        zoom: mapModel.currentZoom),
                    onMapCreated: mapModel.onMapCreated,
    
    
                    myLocationButtonEnabled: true,
                    mapType: MapType.normal,
                    rotateGesturesEnabled: false,
                    tiltGesturesEnabled: false,
                    zoomGesturesEnabled: true,
                    zoomControlsEnabled: true,
                    markers: mapModel.markers,
                    onCameraMove: mapModel.onCameraMove,
                    polylines: mapModel.polyLines,
    
                  ),
    
                  //hamburger menue draw
                  Positioned(
                    top: 38.0,
                    left: 22.0,
                    child: GestureDetector(
                      onTap: ()
                      {
                        if(drawerOpen)
                        {
                          scaffoldkey.currentState.openDrawer();
                        }
    
                        else
                        {
                          resetApp();
                        }
    
    
                      },
                      child: Container(
                        decoration: BoxDecoration(
                          color: Colors.white,
                          borderRadius: BorderRadius.circular(22.0),
                          boxShadow: [
                            BoxShadow(
                              color: Colors.black26,
                              blurRadius: 6.0,
                              spreadRadius: 0.5,
                              offset: Offset(0.7, 0.7),
                            ),
                          ],
                        ),
    
                        child: CircleAvatar(
    
                          backgroundColor: Colors.white,
                          child: Icon((drawerOpen) ? Icons.menu : Icons.close, color: Colors.cyan[500], ),
                          radius: 30.0,
                        ),
    
                      ),
                    ),
                  ),
    
    
    
    
    
    
    
                  SlidingUpPanel(
                    onPanelSlide: uiNotifiersModel.setOriginDestinationVisibility,
                    onPanelOpened: () {
                      uiNotifiersModel.onPanelOpen();
                      mapModel.panelIsOpened();
                    },
                    onPanelClosed: () {
                      uiNotifiersModel.onPanelClosed();
                      mapModel.panelIsClosed();
                    },
                    maxHeight: MediaQuery
                        .of(context)
                        .size
                        .height / 1.3,
                    parallaxEnabled: true,
                    parallaxOffset: 0.5,
                    color: Colors.transparent,
                    boxShadow: const <BoxShadow>[
                      BoxShadow(
                        blurRadius: 8.0,
                        color: Color.fromRGBO(0, 0, 0, 0),
                      )
                    ],
                    controller: uiNotifiersModel.panelController,
                    borderRadius: ShapeUtils.borderRadiusGeometry,
    
    
                    collapsed: Row(
                      crossAxisAlignment: CrossAxisAlignment.center,
                      mainAxisSize: MainAxisSize.max,
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: <Widget>[
                        Expanded(child: SizedBox()),
                        Padding(
                          padding: const EdgeInsets.all(20.0),
                          child: FloatingActionButton(
                            onPressed: mapModel.onMyLocationFabClicked,
                            backgroundColor: ConstantColors.PrimaryColor,
                            child: Icon(Icons.my_location),
                          ),
                        )
                      ],
                    ),
                    panel: BottomSheetMapMenu(),
                  ),
    
    
    
                  SingleChildScrollView(
                    child: Column(
                      crossAxisAlignment: CrossAxisAlignment.end,
                      children: <Widget>[
                        Row(
                          children: <Widget>[
                            Expanded(
                              child: SizedBox(),
                            ),
                            Padding(
                              padding: const EdgeInsets.only(top: 80.0, right: 20),
                              child: SizedBox(
                                height: 50,
                                child: InkResponse(
                                  onTap: ()  {
    
                                    Navigator.push(context,
                                        MaterialPageRoute(
                                            builder: (context) => ProfileScreen()
                                        )
                                    );
    
    
                                  },
                                  child: ClipOval(
                                    child: FadeInImage(
                                        placeholder: AssetImage(
                                            "images/destinationIcon.png"),
                                        image: NetworkImage(
                                            userDetailsModel.photoUrl,
                                            scale: 0.5)),
                                  ),
                                ),
                              ),
                            ),
                          ],
                        ),
                        Visibility(
                          visible:
                          uiNotifiersModel.originDestinationVisibility < 0.2 ||
                              uiNotifiersModel.searchingRide
                              ? false
                              : true,
                          child: Opacity(
                            opacity: uiNotifiersModel.originDestinationVisibility,
                            child: Padding(
                              padding: const EdgeInsets.all(15.0),
                              child: Card(
                                shape: RoundedRectangleBorder(
                                  borderRadius: BorderRadius.circular(15.0),
                                ),
                                child: Row(
                                  crossAxisAlignment: CrossAxisAlignment.start,
                                  mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                                  children: <Widget>[
                                    Padding(
                                      padding: const EdgeInsets.only(
                                          top: 12.0,
                                          right: 10,
                                          left: 10,
                                          bottom: 10),
                                      child: SizedBox(
                                          width: 30,
                                          child: Image.asset(
                                            "images/originDestinationDistanceIcon.png",
                                            fit: BoxFit.fitWidth,
                                          )),
                                    ),
                                    Expanded(
                                      child: Column(
                                        children: <Widget>[
                                          PredictionListAutoComplete(
                                            data: mapModel.pickupPredictions,
                                            textField: TextField(
                                              cursorColor: Colors.black,
                                              onSubmitted:
                                              mapModel.onPickupTextFieldChanged,
                                              //onChanged: mapModel.onPickupTextFieldChanged, not using it for now
                                              controller: mapModel
                                                  .pickupFormFieldController,
                                              decoration: InputDecoration(
                                                labelText: "Origin",
                                                border: InputBorder.none,
                                                contentPadding: EdgeInsets.only(
                                                    top: 15, right: 20, bottom: 10),
                                              ),
                                            ),
                                            itemTap: mapModel
                                                .onPickupPredictionItemClick,
                                          ),
    
                                          PredictionListAutoComplete(
                                            data: mapModel.destinationPredictions,
                                            textField: TextField(
                                              cursorColor: Colors.black,
                                              onSubmitted: mapModel
                                                  .onDestinationTextFieldChanged,
                                              //onChanged:mapModel.onDestinationTextFieldChanged,
                                              controller: mapModel
                                                  .destinationFormFieldController,
                                              decoration: InputDecoration(
                                                labelText: "Destination",
                                                border: InputBorder.none,
                                                contentPadding: EdgeInsets.only(
                                                    right: 20, bottom: 15),
                                              ),
                                            ),
                                            itemTap: mapModel
                                                .onDestinationPredictionItemClick,
                                          )
    
                                        ],
                                      ),
                                    ),
                                  ],
                                ),
                              ),
                            ),
                          ),
                        ),
                      ],
                    ),
                  ),
                  Visibility(
                    visible: uiNotifiersModel.searchingRide,
                    child: Align(
                      alignment: Alignment.bottomCenter,
                      child: SearchingRideBox(),
                    ),
                  ),
                  Align(
                    alignment: Alignment.bottomCenter,
                    child: NoInternetWidget(),
                  ),
                ],
              )),
        );
      }
    
 }

这是我的代码

function onEdit(e){
  const src = e.source.getActiveSheet();
  const r = e.range;
  if (r.rowStart == 1 || r.columnStart != 1) return;
  let dest;
  if (src.getName() == "Sheet1")
    dest = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sheet2");
  else if (src.getName() == "Sheet2")
    dest = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sheet1");  
  src.getRange(r.rowStart,1,1,1).moveTo(dest.getRange(dest.getLastRow()+1,1,1,1));
  src.deleteRow(r.rowStart);
}

0 个答案:

没有答案