-
Taha Tesser authored
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 ![Screenshot 2023-08-15 at 18 11 34](https://github.com/flutter/flutter/assets/48603081/4b798998-8549-43aa-b564-933ea14f494c) ### After ![Screenshot 2023-08-15 at 18 11 45](https://github.com/flutter/flutter/assets/48603081/b085a33a-db7d-40d4-8a12-ee37197b5bd4)