Skip to content

Instantly share code, notes, and snippets.

@b-cancel
Last active November 24, 2019 19:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save b-cancel/8b57edb0e8957fe3ee8761c70097ba57 to your computer and use it in GitHub Desktop.
Save b-cancel/8b57edb0e8957fe3ee8761c70097ba57 to your computer and use it in GitHub Desktop.
FLUTTER select contact page setup
import 'package:flutter/material.dart';
import 'package:flutter_sticky_header/flutter_sticky_header.dart';
//-----Start App
void main() => runApp(MyApp());
//-----Entry Point
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return StatelessLink();
}
}
//-----Statless Link Required Between Entry Point And App
class StatelessLink extends StatelessWidget{
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Nested Picker Link',
home: Test(),
);
}
}
//-----Test Widget
class Test extends StatefulWidget {
@override
_TestState createState() => _TestState();
}
class _TestState extends State<Test> {
@override
Widget build(BuildContext context) {
double toolBarSize = 50;
Widget toolBar = Container(
width: MediaQuery.of(context).size.width,
height: toolBarSize,
color: Colors.blue,
child: Text("tool bar"),
);
Widget banner = Container(
width: MediaQuery.of(context).size.width,
height: 300,
color: Colors.orange,
child: Text("banner"),
);
Widget aSection = SliverStickyHeader(
header: Container(
color: Colors.pink,
width: MediaQuery.of(context).size.width,
height: 35,
child: Text("section"),
),
sliver: new SliverList(
delegate: new SliverChildListDelegate([
Container(
color: Colors.yellow,
width: MediaQuery.of(context).size.width,
height: 500,
),
]),
),
);
List<Widget> sections = new List<Widget>();
sections.add(aSection);
sections.add(aSection);
sections.add(aSection);
sections = new List.from([
SliverToBoxAdapter(
child: banner,
),
SliverAppBar(
pinned: true, //avoid strange padding
floating: true, //avoid strange padding
expandedHeight: 0, //avoid strange padding
bottom: PreferredSize(
preferredSize: Size(
MediaQuery.of(context).size.width,
toolBarSize,
),
child: toolBar,
),
),
])..addAll(sections);
return Scaffold(
backgroundColor: Colors.green,
body: SafeArea(
child: CustomScrollView(
slivers: sections,
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment