Last active
September 21, 2019 23:15
-
-
Save riskers/ee71c1754117981bf7358359b390ff4e to your computer and use it in GitHub Desktop.
Flutter Widget Code
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) { | |
// TODO: implement build | |
return MaterialApp( | |
title: 'Fultter', | |
home: Scaffold( | |
appBar: new AppBar( | |
title: new Text('Title'), | |
), | |
body: Center( | |
child: Column( | |
crossAxisAlignment: CrossAxisAlignment.center, | |
mainAxisAlignment: MainAxisAlignment.center, | |
children: <Widget>[ | |
Text('aaa'), | |
Text('basdasdbb'), | |
Text('ccc') | |
], | |
) | |
) | |
) | |
); | |
} | |
} |
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( | |
items: new List<String>.generate(1000, (i) => "Item $i") | |
)); | |
class MyApp extends StatelessWidget { | |
final List<String> items; | |
MyApp({Key key, @required this.items}): super(key: key); | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
title: 'Flutter', | |
home: Scaffold( | |
appBar: new AppBar(title: new Text('Title')), | |
body: new ListView.builder( | |
itemCount: items.length, | |
itemBuilder: (context, index){ | |
return new ListTile( | |
title: new Text('${items[index]}') | |
); | |
}, | |
) | |
) | |
); | |
} | |
} |
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', | |
home: Scaffold( | |
appBar: new AppBar(title: new Text('Title')), | |
body: GridView( | |
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( | |
crossAxisCount: 3, | |
mainAxisSpacing: 4, | |
crossAxisSpacing: 4, | |
childAspectRatio: 0.7 | |
), | |
children: <Widget>[ | |
new Image.network('https://images.unsplash.com/photo-1542841791-c3cc44abdbbb?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=934&q=80'), | |
new Image.network('https://images.unsplash.com/photo-1542841366-ddfe55c504a3?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=800&q=60'), | |
new Image.network('https://images.unsplash.com/photo-1510520434124-5bc7e642b61d?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=800&q=60'), | |
new Image.network('https://images.unsplash.com/photo-1502898295-455afaf0f015?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=800&q=60'), | |
new Image.network('https://images.unsplash.com/photo-1509503643053-8fc818177382?ixlib=rb-1.2.1&auto=format&fit=crop&w=800&q=60'), | |
new Image.network('https://images.unsplash.com/photo-1433954558247-ba7696b9af19?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=800&q=60'), | |
new Image.network('https://images.unsplash.com/photo-1512477815698-9ba49ad36d22?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=800&q=60'), | |
new Image.network('https://images.unsplash.com/photo-1440589473619-3cde28941638?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=800&q=60'), | |
new Image.network('https://images.unsplash.com/photo-1494790108377-be9c29b29330?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=800&q=60') | |
], | |
) | |
) | |
); | |
} | |
} |
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) { | |
// TODO: implement build | |
return MaterialApp( | |
title: 'Fultter', | |
home: Scaffold( | |
appBar: new AppBar( | |
title: new Text('Title'), | |
), | |
body: new Row( | |
children: <Widget>[ | |
Expanded( | |
child: new RaisedButton( | |
onPressed: (){}, | |
color: Colors.blue, | |
textColor: Colors.white, | |
child: new Text('1button'), | |
) | |
), | |
Expanded( | |
child: new RaisedButton( | |
onPressed: (){}, | |
color: Colors.blue, | |
textColor: Colors.white, | |
child: new Text('2button'), | |
) | |
), | |
new RaisedButton( | |
onPressed: (){}, | |
color: Colors.blue, | |
textColor: Colors.white, | |
child: new Text('bbbbutton'), | |
) | |
], | |
) | |
) | |
); | |
} | |
} |
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) { | |
// 抽组件 | |
var stack = new Stack( | |
alignment: const FractionalOffset(0.5, 0.5), | |
children: <Widget>[ | |
new CircleAvatar( | |
backgroundImage: new NetworkImage('https://images.unsplash.com/photo-1542841791-c3cc44abdbbb?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=934&q=80'), | |
radius: 100, | |
), | |
new Container( | |
decoration: new BoxDecoration( | |
color: Colors.blue, | |
), | |
padding: EdgeInsets.all(5), | |
child: Text('riskers'), | |
) | |
], | |
); | |
return MaterialApp( | |
title: 'Fultter', | |
home: Scaffold( | |
appBar: new AppBar( | |
title: new Text('Title'), | |
), | |
body: Center( | |
child: stack | |
) | |
) | |
); | |
} | |
} |
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
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
title: 'Flutter', | |
home: Scaffold( | |
appBar: new AppBar(title: new Text('Title')), | |
body: new ListView( | |
children: <Widget>[ | |
new ListTile( | |
leading: new Icon(Icons.access_time), | |
title: new Text('abc'), | |
), | |
new ListTile( | |
leading: new Icon(Icons.access_alarms), | |
title: new Text('abc'), | |
), | |
new ListTile( | |
leading: new Icon(Icons.access_time), | |
title: new Text('abc'), | |
), | |
], | |
) | |
) | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment