Die Verwendung von PopScope für Predictive Back-Animationen in Flutter Android funktioniert nicht, sondern geht ohne PreAndroid

Forum für diejenigen, die für Android programmieren
Guest
 Die Verwendung von PopScope für Predictive Back-Animationen in Flutter Android funktioniert nicht, sondern geht ohne Pre

Post by Guest »

Wenn ich PopScope verwende, um prädiktive Back-Animationen zu verarbeiten (wie in der offiziellen Dokumentation), erhalte ich keine prädiktiven Back-Animationen und stattdessen kehrt die App einfach normal zurück, wie sie sollte.
Hier ist mein Hauptbildschirm (settings_screen.dart):

Code: Select all

import 'package:flutter/material.dart';
import 'package:weatherfast/about_screen.dart';
import 'package:weatherfast/help_screen.dart';

class SettingsScreen extends StatelessWidget {
const SettingsScreen({super.key});

@override
Widget build(BuildContext context) {
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Icon(Icons.settings, size: 50, color: Colors.blue),
const SizedBox(height: 10),
const Text(
'Settings',
style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold),
),
const SizedBox(height: 20),
ListView(
shrinkWrap: true,
children: [
ListTile(
leading: const Icon(Icons.info_rounded),
title: const Text('About App'),
onTap: () {
Navigator.push(
context,
MaterialPageRoute(builder: (_) => AboutScreen()),
);
},
),
ListTile(
leading: const Icon(Icons.question_answer_rounded),
title: const Text('Help and Feedback'),
onTap: () {
Navigator.push(
context,
MaterialPageRoute(builder: (_) => const HelpScreen()),
);
},
),
],
),
],
),
);
}
}
Und hier ist der Bildschirm, zu dem ich hin und zurück navigieren möchte (help_screen.dart):

Code: Select all

import 'package:flutter/material.dart';
import 'webview_screen.dart'; // Import your WebViewScreen here

class HelpScreen extends StatelessWidget {
const HelpScreen({super.key});

@override
Widget build(BuildContext context) {
// Define URLs for Feature Request and Bug Report
const featureRequestUrl = 'https://forms.gle/yWgLvBr2vMagmFbQ8';
const bugReportUrl = 'https://forms.gle/vmdA2oyWtLtDu8jA8';

// List items for the screen
final List items = [
{'title': 'Feature Request', 'url': featureRequestUrl},
{'title': 'Bug Report', 'url': bugReportUrl},
];

return PopScope(
canPop: true,
child: Scaffold(
appBar: AppBar(title: const Text('Help and Feedback')),
body: ListView.builder(
itemCount: items.length,
itemBuilder: (context, index) {
final item = items[index];
return ListTile(
title: Text(item['title']!),
trailing: const Icon(Icons.arrow_forward),
onTap: () {
// Navigate to WebViewScreen with the selected URL
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => WebViewScreen(url: item['url']!),
),
);
},
);
},
),
),
);
}
}
Diese Frage unterscheidet sich von den anderen, die ich finden kann, da sie sich speziell auf die Vorhersage zurück bezieht und nicht auf die Verwendung von PopScope für andere Verhaltensweisen.
Gerät, das ich bin Getestet auf: Samsung S24 FE mit Android 14.
Hilfe wäre sehr dankbar.

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post