mirror of
https://github.com/nisrulz/flutter-examples.git
synced 2026-08-24 16:50:47 +00:00
Convert 20 more single-file apps to the validated pattern: lib/main.dart holds only the runApp + MaterialApp bootstrap, while a new lib/example.dart holds the full screen (Scaffold, AppBar) and the focused example code. Apps: enabling_splash_screen, getx_counter_app, image_from_network, infinite_list, load_local_image, load_local_json, persist_key_value, push_notifications, sliver_app_bar_example, stateless_widgets, tic_tac_toe, tip_calculator, using_alert_dialog, using_edittext, using_expansionpanel, using_http_get, using_interactiveviewer, using_snackbar, using_stepper, using_theme
39 lines
1.1 KiB
Dart
39 lines
1.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
// Example: a collapsing SliverAppBar over a scrolling list of items.
|
|
class Example extends StatelessWidget {
|
|
const Example({super.key});
|
|
|
|
// This widget is the root of your application.
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
body: NestedScrollView(
|
|
floatHeaderSlivers: true,
|
|
headerSliverBuilder: (context, innerBoxIsScrolled) => [
|
|
const SliverAppBar(
|
|
expandedHeight: 240,
|
|
flexibleSpace: FlexibleSpaceBar(
|
|
title: Text('Sliver App Bar Demo'),
|
|
background: Image(
|
|
image: AssetImage('assets/sample.jpg'),
|
|
fit: BoxFit.cover,
|
|
),
|
|
),
|
|
floating: true,
|
|
),
|
|
],
|
|
body: ListView.separated(
|
|
padding: const EdgeInsets.all(12),
|
|
itemCount: 30,
|
|
itemBuilder: (context, index) => ListTile(
|
|
title: Text('Item $index'),
|
|
),
|
|
separatorBuilder: (context, index) => const SizedBox(
|
|
height: 10,
|
|
)),
|
|
),
|
|
);
|
|
}
|
|
}
|