PreferredSize Widget
Project Preview
- Interested in seeing the live demo? Click here to explore.
- Want to view the source code? Visit the project on GitHub.
Code Snippet
import 'package:flutter/material.dart';
class PreferredSizeWidget extends StatelessWidget {
const PreferredSizeWidget({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: PreferredSize(
preferredSize: const Size.fromHeight(80.0),
child: Container(
height: 120,
decoration: const BoxDecoration(
gradient: LinearGradient(
colors: <Color>[
Colors.redAccent,
Colors.orangeAccent,
],
),
),
child: SafeArea(
child: Center(
child: ListTile(
textColor: Colors.white,
title: const Text('Flutter Mapp'),
trailing: IconButton(
icon: const Icon(
Icons.search,
size: 20,
),
color: Colors.white,
onPressed: () {},
),
),
),
),
),
),
body: const Center(
child: Text('Learn Smart'),
),
);
}
}