Skip to content

Instantly share code, notes, and snippets.

@mosluce
Created August 23, 2022 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mosluce/c2275bf16218d7fc9c18566c1de79167 to your computer and use it in GitHub Desktop.
Save mosluce/c2275bf16218d7fc9c18566c1de79167 to your computer and use it in GitHub Desktop.
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
// This is the theme of your application.
//
// Try running your application with "flutter run". You'll see the
// application has a blue toolbar. Then, without quitting the app, try
// changing the primarySwatch below to Colors.green and then invoke
// "hot reload" (press "r" in the console where you ran "flutter run",
// or simply save your changes to "hot reload" in a Flutter IDE).
// Notice that the counter didn't reset back to zero; the application
// is not restarted.
primarySwatch: Colors.blue,
),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
final String title;
const MyHomePage({super.key, required this.title});
@override
State<StatefulWidget> createState() => MyHomePageState();
}
class MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: DefaultTabController(
length: 2,
child: Container(
color: Colors.grey.shade50,
child: Column(
children: [
buildAppBar(context),
Expanded(
child: NestedScrollView(
headerSliverBuilder:
(BuildContext context, bool innerBoxIsScrolled) {
return [
SliverToBoxAdapter(
child: Container(
child: buildHeader(context),
),
),
];
},
body: Column(
children: [
buildTabBar(context),
Expanded(
child: TabBarView(
children: [
buildView1(context),
buildView2(context),
],
))
],
),
),
),
],
),
),
),
);
}
buildAppBar(BuildContext context) {
return Container(
height: 100,
color: const Color.fromARGB(255, 0, 49, 90),
);
}
buildAvatar(BuildContext context) {
return Container(
width: 180,
height: 180,
margin: const EdgeInsets.symmetric(vertical: 16),
color: Colors.blueGrey,
child: const Center(
child: Text("Avatar"),
),
);
}
buildDisplayName(BuildContext context) {
return Center(
child: Container(
margin: const EdgeInsets.only(bottom: 8),
width: 120,
height: 30,
color: Colors.blueGrey,
),
);
}
buildTabBar(BuildContext context) {
return Container(
color: Colors.grey,
child: Row(
children: const [
TabBar(
labelPadding: EdgeInsets.symmetric(vertical: 0, horizontal: 24),
isScrollable: true,
tabs: [
Tab(
text: 'Tab 1111111',
),
Tab(
text: 'Tab 2',
),
],
),
],
),
);
}
buildHeader(BuildContext context) {
return Column(
children: [
buildAvatar(context),
buildDisplayName(context),
],
);
}
buildView1(BuildContext context) {
return Container(
padding: EdgeInsets.zero,
child: MediaQuery.removePadding(
context: context,
removeTop: true,
child: ListView(
children: [
buildListItem(context),
buildListItem(context, color: Colors.blueGrey.shade200),
buildListItem(context),
buildListItem(context, color: Colors.blueGrey.shade200),
buildListItem(context),
buildListItem(context, color: Colors.blueGrey.shade200),
buildListItem(context),
buildListItem(context, color: Colors.blueGrey.shade200),
buildListItem(context),
buildListItem(context, color: Colors.blueGrey.shade200),
buildListItem(context),
buildListItem(context, color: Colors.blueGrey.shade200),
buildListItem(context),
buildListItem(context, color: Colors.blueGrey.shade200),
buildListItem(context),
buildListItem(context, color: Colors.blueGrey.shade200),
buildListItem(context),
],
),
),
);
}
buildView2(BuildContext context) {
return Container();
}
buildListItem(BuildContext context,
{double height = 64, Color color = Colors.blueGrey}) {
return Container(height: height, color: color);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment