Fix FlexibleSpaceBar.title
doesn't respect the leading widget (#132573)
fixes [Long `FlexibleSpaceBar.title` doesn't respect the leading widget
](https://github.com/flutter/flutter/issues/132030)
### Description
- This adds `FlexibleSpaceBarSettings.hasLeading` for the `FlexibleSpaceBar`'s title to respect the leading widget.
- Use the new `FlexibleSpaceBarSettings.hasLeading` property in the `SliverAppBar` for its `FlexibleSpaceBar`.
### 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 MaterialApp(
debugShowCheckedModeBanner: false,
theme: ThemeData(
useMaterial3: true,
brightness: Brightness.dark,
),
home: const Example(),
);
}
}
class Example extends StatelessWidget {
const Example({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Text('TargetPlatform.Android'),
Theme(
data: Theme.of(context).copyWith(
platform: TargetPlatform.android,
),
child: Container(
height: 250,
padding: const EdgeInsets.all(8),
decoration: BoxDecoration(
border: Border.all(
color: Colors.amber,
width: 4,
),
),
child: const AppBarLeading(
showLeading: true,
showTitle: false,
),
),
),
const Text('TargetPlatform.iOS'),
Theme(
data: Theme.of(context).copyWith(
platform: TargetPlatform.iOS,
),
child: Container(
height: 250,
padding: const EdgeInsets.all(8),
decoration: BoxDecoration(
border: Border.all(
color: Colors.amber,
width: 2,
),
),
child: const AppBarLeading(
showLeading: true,
showTitle: false,
),
),
),
],
),
);
}
}
class AppBarLeading extends StatelessWidget {
const AppBarLeading({
super.key,
required this.showLeading,
required this.showTitle,
});
final bool showLeading;
final bool showTitle;
@override
Widget build(BuildContext context) {
return Scaffold(
drawer: const Drawer(),
body: CustomScrollView(
slivers: [
SliverAppBar(
automaticallyImplyLeading: showLeading,
iconTheme: const IconThemeData(
color: Colors.amber,
),
title: showTitle ? const Text('AppBar') : null,
flexibleSpace: FlexibleSpaceBar(
title: Text('Title ' * 15),
// centerTitle: true,
),
toolbarHeight: showTitle ? 170 : 100,
),
],
),
);
}
}
```
</details>
### Before

### After
