-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Closed
Labels
d: api docsIssues with https://api.flutter.dev/Issues with https://api.flutter.dev/f: material designflutter/packages/flutter/material repository.flutter/packages/flutter/material repository.found in release: 3.28Found to occur in 3.28Found to occur in 3.28found in release: 3.29Found to occur in 3.29Found to occur in 3.29frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer versionteam-frameworkOwned by Framework teamOwned by Framework team
Description
Steps to reproduce
- With the code sample below press
Navigate - Press
Show snackbar - Observe log prints
Expected results
onVisible should be called once.
Actual results
onVisible is called twice.
Code sample
Code sample
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: const Page1(),
);
}
}
class Page1 extends StatelessWidget {
const Page1({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: ElevatedButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => Page2()),
);
},
child: Text("Navigate"),
),
),
);
}
}
class Page2 extends StatelessWidget {
const Page2({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: ElevatedButton(
onPressed: () {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text("text"),
onVisible: () {
print("onVisible");
},
),
);
},
child: Text("Show snackbar"),
),
),
);
}
}
Screenshots or Video
Logs
Logs
I/flutter (12733): onVisible
I/flutter (12733): onVisibleFlutter Doctor output
Doctor output
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.27.3, on macOS 15.2 24C101 darwin-x64, locale en-IL)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 16.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2024.2)
[✓] IntelliJ IDEA Ultimate Edition (version 2024.1.1)
[✓] VS Code (version 1.96.2)
[✓] Connected device (4 available)
[✓] Network resourcesMetadata
Metadata
Assignees
Labels
d: api docsIssues with https://api.flutter.dev/Issues with https://api.flutter.dev/f: material designflutter/packages/flutter/material repository.flutter/packages/flutter/material repository.found in release: 3.28Found to occur in 3.28Found to occur in 3.28found in release: 3.29Found to occur in 3.29Found to occur in 3.29frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer versionteam-frameworkOwned by Framework teamOwned by Framework team
Type
Projects
Status
Done (PR merged)