Created
March 6, 2019 20:00
-
-
Save mehmetf/0bae55d83574e378705174bd9fec012b to your computer and use it in GitHub Desktop.
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 'package:flutter/material.dart'; | |
void main() => runApp(MyApp()); | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
title: 'Flutter Demo', | |
theme: ThemeData( | |
primarySwatch: Colors.blue, | |
), | |
home: MyHomePage(title: 'Flutter Demo Home Page'), | |
); | |
} | |
} | |
class MyHomePage extends StatefulWidget { | |
MyHomePage({Key key, this.title}) : super(key: key); | |
final String title; | |
@override | |
_MyHomePageState createState() => _MyHomePageState(); | |
} | |
class _MyHomePageState extends State<MyHomePage> { | |
int _counter = 0; | |
List<Color> _purples = [ | |
Color(0xFF4A235A), | |
Color(0xFF5B2C6F), | |
Color(0xFF6C3483), | |
Color(0xFF7D3C98), | |
Color(0xFF8E44AD), | |
Color(0xFFA569BD), | |
Color(0xFFBB8FCE), | |
Color(0xFFD2B4DE), | |
Color(0xFFE8DAEF), | |
Color(0xFFF4ECF7), | |
]; | |
List<Color> _yellows = [ | |
Color(0xFF7D6608), | |
Color(0xFF9A7D0A), | |
Color(0xFFB7950B), | |
Color(0xFFD4AC0D), | |
Color(0xFFF1C40F), | |
Color(0xFFF4D03F), | |
Color(0xFFF7DC6F), | |
Color(0xFFF9E79F), | |
Color(0xFFFCF3CF), | |
Color(0xFFFEF9E7), | |
]; | |
void _incrementCounter() { | |
setState(() { | |
_counter++; | |
}); | |
} | |
@override | |
Widget build(BuildContext context) { | |
MediaQueryData mediaQueryData = MediaQuery.of(context); | |
debugPrint('MyApp : build' | |
' : padding=${mediaQueryData.padding}' | |
' : viewInsets=${mediaQueryData.viewInsets}'); | |
return SafeArea( | |
child: Scaffold( | |
appBar: AppBar( | |
// Here we take the value from the MyHomePage object that was created by | |
// the App.build method, and use it to set our appbar title. | |
// We also apply a custom font, ProductSans. | |
title: Text( | |
widget.title, | |
style: TextStyle( | |
fontFamily: 'ProductSans', | |
), | |
), | |
), | |
body: ListView( | |
scrollDirection: Axis.vertical, | |
children: <Widget>[ | |
Container( | |
padding: const EdgeInsets.symmetric( | |
vertical: 20.0, | |
), | |
height: 120.0, | |
child: ListView( | |
scrollDirection: Axis.horizontal, | |
children: _purples.map((Color color) { | |
return Container( | |
color: color, | |
height: 80.0, | |
width: 80.0, | |
); | |
}).toList(), | |
), | |
), | |
Container( | |
padding: const EdgeInsets.symmetric( | |
vertical: 20.0, | |
), | |
height: 120.0, | |
child: ListView( | |
scrollDirection: Axis.horizontal, | |
children: _yellows.map((Color color) { | |
return Container( | |
color: color, | |
height: 80.0, | |
width: 120.0, | |
); | |
}).toList(), | |
), | |
), | |
Container( | |
alignment: Alignment.center, | |
child: Text( | |
'Button tapped $_counter time${_counter == 1 ? '' : 's'}.', | |
// This optional key is used to uniquely identify this widget in | |
// the integration test at: test_driver/tap_test.dart. | |
key: Key('CountText'), | |
), | |
), | |
], | |
), | |
floatingActionButton: FloatingActionButton( | |
onPressed: _incrementCounter, | |
tooltip: 'Increment', | |
child: Icon(Icons.add), | |
), // This trailing comma makes auto-formatting nicer for build methods. | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment