Created
January 23, 2022 19:42
-
-
Save EArminjon/fd596079fb157c8bb9a96c7f273af3f0 to your computer and use it in GitHub Desktop.
Sliver
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:math'; | |
import 'package:flutter/material.dart'; | |
class Home extends StatefulWidget { | |
const Home({Key? key}) : super(key: key); | |
@override | |
_HomeState createState() => _HomeState(); | |
} | |
class SimpleBloc extends StatelessWidget { | |
const SimpleBloc({Key? key}) : super(key: key); | |
@override | |
Widget build(BuildContext context) { | |
return Container( | |
alignment: Alignment.center, | |
color: Colors.primaries[Random().nextInt(Colors.primaries.length)], | |
width: double.maxFinite, | |
height: 100, | |
); | |
} | |
} | |
class _HomeState extends State<Home> { | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
body: CustomScrollView( | |
slivers: [ | |
const SliverToBoxAdapter(child: SimpleBloc()), | |
const SliverToBoxAdapter(child: SimpleBloc()), | |
const SliverToBoxAdapter(child: SimpleBloc()), | |
SliverPadding( | |
padding: const EdgeInsets.all(16), | |
sliver: SliverList( | |
delegate: SliverChildListDelegate( | |
[ | |
const SimpleBloc(), | |
const SimpleBloc(), | |
const SimpleBloc(), | |
const SimpleBloc(), | |
const SimpleBloc(), | |
const SimpleBloc(), | |
], | |
), | |
), | |
), | |
const SliverToBoxAdapter(child: SimpleBloc()), | |
const SliverToBoxAdapter(child: SimpleBloc()), | |
const SliverToBoxAdapter(child: SimpleBloc()), | |
], | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment