设备为iPhone时如何显示后退按钮

时间:2018-09-19 17:37:31

标签: android ios dart flutter dart-2

我正在使用Flutter开发一个应用程序。但我陷入一种困境,即Android设备具有默认的后退按钮,而iPhone没有。因此,当我在iOS设备中打开应用程序时,需要显示后退按钮。 另外,如果还有其他内置功能可用,请指导我。

2 个答案:

答案 0 :(得分:0)

默认情况下,我们将为Android和iOS的两者 获取backButton 。如果我们不想要它,可以通过将空容器(Container())赋予appBar的leading值来删除。有关更多详细信息,请参见this

答案 1 :(得分:0)

tsconfig.jsonfunc setCurrentLocation(location: CLLocation) { let encodedLocation = NSKeyedArchiver.archivedData(withRootObject: location) UserDefaults.standard.set(encodedLocation, forKey: UserDefaultKey.previousVisitedLocation) } func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { guard locations.count > 0 else { return } guard let location = locations.last else { return } guard location.horizontalAccuracy > 0 else { return } guard location.horizontalAccuracy < DISTANCE_LIMIT else { //DISTANCE_LIMIT is the value you have set for your distance filter return } let previousLocationEncoded = UserDefaults.standard.object(forKey: UserDefaultKey.previousVisitedLocation) as? Data if previousLocationEncoded == nil { setCurrentLocation(location: location) //do your tasks } else { let previousLocationDecoded = NSKeyedUnarchiver.unarchiveObject(with: previousLocationEncoded!) as! CLLocation let distanceBetweenVisits = previousLocationDecoded.distance(from: location) if distanceBetweenVisits > DISTANCE_LIMIT { let timeIntervalBetweenVisits = location.timestamp.timeIntervalSince(previousLocationDecoded.timestamp) guard timeIntervalBetweenVisits > 0 else { return } setCurrentLocation(location: location) //do your tasks } } } 一起使用,它将自动在屏幕的右上方创建虚拟后退按钮。 (假设您从另一个屏幕上Scaffold小部件了。)

AppBar