Skip to content

Commit 5d1d840

Browse files
committed
Remove nested scroll and modify RWD for app bar.
1 parent 6299651 commit 5d1d840

File tree

5 files changed

+55
-35
lines changed

5 files changed

+55
-35
lines changed

README.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,7 @@ It's using Flutter to create web for GDG.
55
## What is Kirin?
66
Kirin is an animal of imagination, combination of Dragon, Phoenix...
77

8-
And Flutter also build Android, iOS, and Web(even if not support perfectly and just a dart)
8+
And Flutter also build Android, iOS, and Web(even if not support perfectly and just a dart)
9+
10+
### Flutter Web RWD
11+
[Documents](https://github.com/flutter/flutter/wiki/Creating-Responsive-Apps)

lib/main.dart

+20-26
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import 'package:flutter_web/material.dart';
2-
import 'dart:convert';
2+
33
import 'views/HomeAppBar.dart';
4-
import 'views/TabButton.dart';
54

65
void main() => runApp(MyApp());
76

@@ -32,34 +31,29 @@ class MyHomePage extends StatelessWidget {
3231
// fast, so that you can just rebuild anything that needs updating rather
3332
// than having to individually change instances of widgets.
3433
return Scaffold(
35-
appBar: PreferredSize(child: HomeAppBar(title), preferredSize: Size.fromHeight(50)),
36-
body: Center(
37-
// Center is a layout widget. It takes a single child and positions it
38-
// in the middle of the parent.
39-
child: Column(
40-
// Column is also layout widget. It takes a list of children and
41-
// arranges them vertically. By default, it sizes itself to fit its
42-
// children horizontally, and tries to be as tall as its parent.
43-
//
44-
// Invoke "debug painting" (choose the "Toggle Debug Paint" action
45-
// from the Flutter Inspector in Android Studio, or the "Toggle Debug
46-
// Paint" command in Visual Studio Code) to see the wireframe for each
47-
// widget.
48-
//
49-
// Column has various properties to control how it sizes itself and
50-
// how it positions its children. Here we use mainAxisAlignment to
51-
// center the children vertically; the main axis here is the vertical
52-
// axis because Columns are vertical (the cross axis would be
53-
// horizontal).
54-
mainAxisAlignment: MainAxisAlignment.center,
34+
appBar: PreferredSize(child: HomeAppBar(title), preferredSize: Size.fromHeight(56)),
35+
body: ListView(
5536
children: <Widget>[
56-
Text(
57-
'Hello, Google World!',
58-
style: TextStyle(color: Colors.blueAccent, fontFamily: labelFontFamily)
37+
Center(
38+
child: Text(
39+
"Hello GDG World.",
40+
style: TextStyle(fontFamily: labelFontFamily),
41+
),
42+
),
43+
Center(
44+
child: Text(
45+
"Hello GDG World.",
46+
style: TextStyle(fontFamily: labelFontFamily),
47+
),
48+
),
49+
Center(
50+
child: Text(
51+
"Hello GDG World.",
52+
style: TextStyle(fontFamily: labelFontFamily),
53+
),
5954
),
6055
],
6156
),
62-
), // This trailing comma makes auto-formatting nicer for build methods.
6357
);
6458
}
6559
}

lib/views/HomeAppBar.dart

+18-8
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,24 @@ class _HomeAppBarWidgetState extends State<HomeAppBar> {
5858

5959
@override
6060
Widget build(BuildContext context) {
61-
return AppBar(
62-
leading: Container(
63-
child: Image.asset("images/logo-GDG.png"),
64-
padding: const EdgeInsets.fromLTRB(16.0, 0.0, 0.0, 0.0),
65-
),
66-
title: Text(title, style: TextStyle(color: Colors.black54, fontFamily: labelFontFamily, fontStyle: FontStyle.normal)),
67-
backgroundColor: Color.fromARGB(1, 255, 255, 255),
68-
actions: getTabs(),
61+
return LayoutBuilder(
62+
builder: (context, constraints) {
63+
if (constraints.maxWidth > 750) {
64+
return AppBar(
65+
leading: Container(
66+
child: Image.asset("images/logo-GDG.png"),
67+
padding: const EdgeInsets.fromLTRB(16.0, 0.0, 0.0, 0.0),
68+
),
69+
title: Text(title, style: TextStyle(color: Colors.black54, fontFamily: labelFontFamily, fontStyle: FontStyle.normal)),
70+
backgroundColor: Color.fromARGB(1, 255, 255, 255),
71+
actions: getTabs(),
72+
);
73+
} else {
74+
return Center(
75+
child: Text("GDG"),
76+
);
77+
}
78+
},
6979
);
7080
}
7181

lib/views/HomeHeader.dart

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
import 'package:flutter_web/material.dart';
3+
4+
class HomeHeader extends StatelessWidget {
5+
@override
6+
Widget build(BuildContext context) {
7+
return Row(
8+
9+
);
10+
}
11+
12+
}

pubspec.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ flutter:
1616
dependencies:
1717
flutter_web: any
1818
flutter_web_ui: any
19+
firebase: ^5.0.0
1920
# flutter_svg: ^0.12.4+2
2021
# firebase_core: ^0.4.0+3
2122
# firebase_analytics: ^3.0.2

0 commit comments

Comments
 (0)