inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

묻고 답해요

173만명의 커뮤니티!! 함께 토론해봐요.

한 페이지에서 벗어나지지 않습니다 ㅠ

미해결

[코드팩토리] [초급] Flutter 3.0 앱 개발 - 10개의 프로젝트로 오늘 초보 탈출!

그대로 따라 했는데, 이 페이지에서 벗어나 지지 않습니다. 어떻게 해야 벗어나 질까요?; 코드 하단에 있습니다. import 'package:flutter/material.dart'; import 'package:geolocator/geolocator.dart'; import 'package:google_maps_flutter/google_maps_flutter.dart'; class HomeScreen extends StatefulWidget { const HomeScreen({Key? key}) : super(key: key); @override State<HomeScreen> createState() => HomeScreenState(); } class HomeScreenState extends State<HomeScreen> { static final LatLng companyLatLng = LatLng( 37.4493182, 126.6601906, ); //위도 경도 지정하기 static final CameraPosition initialPosition = CameraPosition( target: companyLatLng, zoom: 15, ); static final Circle circle = Circle( circleId: CircleId('circle'), ); @override Widget build(BuildContext context) { return Scaffold( appBar: renderAppBar(), body: FutureBuilder( future: checkPermission(), builder: (BuildContext context, AsyncSnapshot snapshot){ if(snapshot.connectionState == ConnectionState.waiting){ return Center( child: CircularProgressIndicator(), ); } if( snapshot.data == '위치 권한이 허가되었습니다.'){ return Column( children: [ _CustomGoogleMap( initialPosition: initialPosition, ), _ ChoolcheckButton(), ], ); } return Center( child: Text( snapshot.data ), ); }, ), ); } Future<String> checkPermission() async { final isLocationEnabled = await Geolocator.isLocationServiceEnabled(); if (!isLocationEnabled) { return '위치 서비스를 활성화 해주세요.'; } LocationPermission checkPermission = await Geolocator.checkPermission(); if (checkPermission == LocationPermission.denied) { checkPermission = await Geolocator.requestPermission(); if (checkPermission == LocationPermission.denied) { return '위치 권한을 허가해주세요.'; } } if (checkPermission == LocationPermission.deniedForever) { return '앱의 위치 권한을 세팅에서 허가해주세요.'; } return '앱의 위치 권한이 허가되었습니다.'; } AppBar renderAppBar() { return AppBar( title: Center( child: Text( '오늘도 출근', style: TextStyle( color: Colors.blue , fontWeight: FontWeight.w700, ), ), ), backgroundColor: Colors.white, ); } } class _ CustomGoogleMap extends StatelessWidget { final CameraPosition initialPosition; const _ CustomGoogleMap({ required this.initialPosition, Key? key }) : super(key: key); @override Widget build(BuildContext context) { return Expanded( flex: 2, child: GoogleMap( mapType: MapType.normal, initialCameraPosition: initialPosition, myLocationEnabled: true, myLocationButtonEnabled: false, ), ); } } class ChoolcheckButton extends StatelessWidget { const ChoolcheckButton({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return Expanded( child: Text( '출근', ), ); } }

  • flutter
  • 클론코딩
  • 맵만들기
김지현 댓글 3 좋아요 0 조회수 498

인기 태그

인프런 TOP Writers

주간 인기글