You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[CP] Add ability to customize NavigationBar indicator overlay and fix in… (flutter#139162)
�dicator shape for the overlay (flutter#138901)
fixes [Provide ability to override `NavigationBar` indicator ink response overlay](flutter#138850) fixes [`NavigationBar.indicatorShape` is ignored, `NavigationBarThemeData.indicatorShape` is applied to the indicator inkwell](flutter#138900)
---
Cherry pick fixesflutter#139159
---
### Code sample
<details>
<summary>expand to view the code sample</summary>
```dart
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({super.key});
@OverRide
Widget build(BuildContext context) {
return const MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
bottomNavigationBar: NavigationBarExample(),
),
);
}
}
class NavigationBarExample extends StatefulWidget {
const NavigationBarExample({super.key});
@OverRide
State<NavigationBarExample> createState() => _NavigationBarExampleState();
}
class _NavigationBarExampleState extends State<NavigationBarExample> {
int index = 0;
@OverRide
Widget build(BuildContext context) {
return NavigationBar(
elevation: 0,
overlayColor: const MaterialStatePropertyAll<Color>(Colors.transparent),
// indicatorShape: RoundedRectangleBorder(
// borderRadius: BorderRadius.circular(4.0),
// ),
indicatorColor: Colors.transparent,
selectedIndex: index,
onDestinationSelected: (int index) {
setState(() {
this.index = index;
});
},
destinations: const <Widget>[
NavigationDestination(
selectedIcon: Icon(Icons.home_filled),
icon: Icon(Icons.home_outlined),
label: 'Home',
),
NavigationDestination(
selectedIcon: Icon(Icons.favorite),
icon: Icon(Icons.favorite_outline),
label: 'Favorites',
),
],
);
}
}
```
</details>
### Before
#### Cannot override `NavigationBar` Indicator ink well overlay

#### Indicator shape is ignored for the indicator overlay

### After
#### Can use `NavigationBar.overlayColor` or `NavigationBarThemeData.NavigationBar` to override default indicator overlay
`overlayColor: MaterialStatePropertyAll<Color>(Colors.red.withOpacity(0.33)),`

`overlayColor: MaterialStatePropertyAll<Color>(Colors.transparent),`

#### Indicator shape is respected for the indicator overlay

*Replace this paragraph with a description of what this PR is changing or adding, and why. Consider including before/after screenshots.*
*List which issues are fixed by this PR. You must list at least one issue. An issue is not required if the PR fixes something trivial like a typo.*
*If you had to change anything in the [flutter/tests] repo, include a link to the migration guide as per the [breaking change policy].*
0 commit comments