-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Closed
Labels
c: regressionIt was better in the past than it is nowIt was better in the past than it is nowf: material designflutter/packages/flutter/material repository.flutter/packages/flutter/material repository.found in release: 2.10Found to occur in 2.10Found to occur in 2.10found in release: 2.11Found to occur in 2.11Found to occur in 2.11frameworkflutter/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 version
Description
Steps to Reproduce
This was checked inside DartPad and the behaviour is the same so it doesn't require me to run 'flutter doctor' or any flutter commands; the bug is also quite simple.
- Use the Stack widget inside the icon label in the NavigationRailDestionation in a NavigationRail Widget.
- Ensure that the labeltype of NavigationRail is set to none (labelType: NavigationRailLabelType.none). See code below for more details.
- The Stack Widget creates an unwanted spacing and doesn't behave as expected.
- See the code below in dartpad for a visual demostration. Code is Commented.
Expected results:
Run Dart Pad linked below.
Actual results:
Run Dart Pad linked below.
Code sample
import 'package:flutter/material.dart';
const Color darkBlue = Color.fromARGB(255, 18, 32, 47);
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData.dark().copyWith(
scaffoldBackgroundColor: darkBlue,
),
debugShowCheckedModeBanner: false,
home: const Scaffold(
body: Center(
child: TestScreenBody(),
),
),
);
}
}
class TestScreenBody extends StatelessWidget {
const TestScreenBody({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Column(
mainAxisSize: MainAxisSize.min,
children: [
const Spacer(
flex: 1,
),
Flexible(
flex: 9,
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Flexible(
flex: 9,
child: Padding(
padding: const EdgeInsets.all(15),
/*
We see the Stack Widget behaving properly when using inside a generic 'icon:'
In this example an IconButton.
*/
child: IconButton(
onPressed: null,
icon: Stack(
children: const [
Icon(Icons.umbrella),
Positioned(
top: 0,
right: 0,
child: Text(
'Test',
style: TextStyle(fontSize: 10, color: Colors.red),
),
),
],
),
),
),
),
Flexible(
flex: 3,
child: NavigationRail(
labelType: NavigationRailLabelType.none, /* <-------------- ONLY HAPPENS WHEN LABEL TYPE IS NONE */
destinations: [
NavigationRailDestination(
/*
We are inside the NavigationRail.
We see the Stack Widget behaving in an unwanted way inside the 'icon:',
there exist some unwanted spacing.
*/
icon: Stack(
children: const [
Icon(Icons.umbrella),
Positioned(
top: 0,
right: 0,
child: Text(
'Test',
style:
TextStyle(fontSize: 10, color: Colors.red),
),
),
],
),
label: const Text('Bugged'),
),
const NavigationRailDestination(
/*
We are inside the NavigationRail.
Normal Icon given to the 'icon:' widget behaves as expected.
*/
icon: Icon(Icons.umbrella),
label: Text('Umbrella'),
),
NavigationRailDestination(
/*
We are inside the NavigationRail.
Temporary Fix is to wrap it inside a Center Widget
*/
icon: Center(
child: Stack(
children: const [
Icon(Icons.umbrella),
Positioned(
top: 0,
right: 0,
child: Text(
'Test',
style: TextStyle(
fontSize: 10, color: Colors.red),
),
),
],
),
),
label: const Text('Bug'),
),
],
selectedIndex: 0),
),
],
),
),
],
);
}
}Temporary Solution
Wrap the Stack Widget inside a Center Widget.
Metadata
Metadata
Assignees
Labels
c: regressionIt was better in the past than it is nowIt was better in the past than it is nowf: material designflutter/packages/flutter/material repository.flutter/packages/flutter/material repository.found in release: 2.10Found to occur in 2.10Found to occur in 2.10found in release: 2.11Found to occur in 2.11Found to occur in 2.11frameworkflutter/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 version
Type
Projects
Status
Done (PR merged)