flutter_appbar 1.10.0
flutter_appbar: ^1.10.0 copied to clipboard
This package implements the flexible appbar behavior, And we pursue higher performance and responsiveness than the appbar generally provided by Flutter.
// Must be hide the Flutter default material or cupertino app bar.
import 'package:flutter/material.dart' hide AppBar;
import 'package:flutter_appbar/flutter_appbar.dart';
void main() {
runApp(const MainApp());
}
class MainApp extends StatelessWidget {
const MainApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
body: SafeArea(
child: Example(),
),
),
);
}
}
/// Example widget demonstrating multiple AppBars with nested scrolling.
class Example extends StatelessWidget {
const Example({super.key});
@override
Widget build(BuildContext context) {
return AppBarConnection(
// Connect multiple AppBars with a scrollable child.
appBars: [
AppBar(
behavior: const MaterialAppBarBehavior(dragOnlyExpanding: true),
alignment: .center,
body: const HeaderAppBar(),
),
AppBar(
behavior: const MaterialAppBarBehavior(floating: true),
body: const FloatingAppBar(),
),
],
child: ListView.builder(
itemCount: 100,
itemBuilder: (context, index) {
return Text("Hello, World! $index");
},
),
);
}
}
class HeaderAppBar extends StatelessWidget {
const HeaderAppBar({super.key});
@override
Widget build(BuildContext context) {
return Container(
width: .infinity,
height: 300,
color: Colors.red,
alignment: .center,
child: const Column(
mainAxisAlignment: .center,
children: [
Text(
"Header",
style: TextStyle(fontSize: 32, fontWeight: .bold),
),
Text(
"dragOnlyExpanding: true",
style: TextStyle(fontSize: 16),
),
],
),
);
}
}
class FloatingAppBar extends StatelessWidget {
const FloatingAppBar({super.key});
@override
Widget build(BuildContext context) {
return Container(
width: .infinity,
padding: const .all(15),
color: Colors.blue,
alignment: .center,
child: const Column(
children: [
Text(
"AppBar",
style: TextStyle(fontSize: 20, fontWeight: .bold),
),
Text(
"floating: true",
style: TextStyle(fontSize: 16),
),
],
),
);
}
}