Skip to content

Commit

Permalink
add new dart file
Browse files Browse the repository at this point in the history
  • Loading branch information
crazyandcoder committed Nov 15, 2019
1 parent c499d6f commit df97851
Show file tree
Hide file tree
Showing 7 changed files with 246 additions and 8 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class WidgetButtonRoute extends StatefulWidget {
@override
State<StatefulWidget> createState() {
return new ButtonState();
}
}

class ButtonState extends State<WidgetButtonRoute> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Button Test'),
),
body: Padding(
padding: EdgeInsets.all(20),
child: Column(
children: <Widget>[
RaisedButton.icon(
icon: Icon(Icons.send),
label: Text("发送"),
onPressed: () => print("RaisedButton click"),
),
RaisedButton(
child: Text('RaisedButton-normal'),
onPressed: () => print("RaisedButton click"),
),
FlatButton(
child: Text('FlatButton-normal'),
onPressed: () => print("FlatButton click"),
),
OutlineButton(
child: Text("OutlineButton-normal"),
onPressed: () => print("OutlineButton click"),
),
IconButton(
icon: Icon(Icons.thumb_up),
onPressed: () => print("IconButton click"),
),
RaisedButton.icon(
icon: Icon(Icons.send),
label: Text("发送"),
onPressed: () => print("IconButton click"),
),
OutlineButton.icon(
icon: Icon(Icons.add),
label: Text("添加"),
onPressed: () => print("IconButton click"),
),
FlatButton.icon(
icon: Icon(Icons.info),
label: Text("详情"),
onPressed: () => print("IconButton click"),
),
FlatButton(
color: Colors.blue,
highlightColor: Colors.blue[700],
colorBrightness: Brightness.dark,
splashColor: Colors.grey,
child: Text("Submit"),
shape:RoundedRectangleBorder(borderRadius: BorderRadius.circular(20.0)),
onPressed: () {},
)
],
),
));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class WidgetCheckboxRoute extends StatefulWidget {
@override
State<StatefulWidget> createState() {
// TODO: implement createState
return new CheckboxState();
}
}

class CheckboxState extends State<WidgetCheckboxRoute> {
bool _switchSelected = false; //维护单选开关状态
bool _checkboxSelected = false; //维护复选框状态

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Checkbox test'),
),
body: Column(
children: <Widget>[
Switch(
value: _switchSelected,
onChanged: (value) {
//重新构建页面
setState(() {
_switchSelected = value;
});
},
),
Checkbox(
activeColor: Colors.red, //选中时的颜色
value: _checkboxSelected,
onChanged: (value) {
setState(() {
_checkboxSelected = value;
});
},
)
],
),
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class WidgetImageRoute extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Center(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Icon(
Icons.accessible,
color: Colors.green,
),
Icon(
Icons.error,
color: Colors.green,
),
Icon(
Icons.fingerprint,
color: Colors.green,
),
],
));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class WidgetInputRoute extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('input'),
),
body: Padding(
padding: EdgeInsets.all(10),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
TextField(
autofocus: true,
decoration: InputDecoration(
labelText: "用户名",
hintText: "用户名或邮箱",
prefixIcon: Icon(Icons.person)),
),
TextField(
decoration: InputDecoration(
labelText: "密码",
hintText: "您的登录密码",
prefixIcon: Icon(Icons.lock)),
obscureText: true,
),
],
),
),
);
}
}
71 changes: 66 additions & 5 deletions flutter_demo_counter/flutter_demo_counter/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import 'package:flutter/material.dart';
import 'package:flutter_demo_counter/ArguementRoute.dart';
import 'package:flutter_demo_counter/NewRoute.dart';
import 'package:flutter_demo_counter/TipRoute.dart';
import 'package:flutter_demo_counter/WidgetButtonRoute.dart';
import 'package:flutter_demo_counter/WidgetImageRoute.dart';
import 'package:flutter_demo_counter/WidgetCheckboxRoute.dart';
import 'package:flutter_demo_counter/WidgetInputRoute.dart';

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

Expand All @@ -17,6 +21,10 @@ class MyApp extends StatelessWidget {
"new_route": (context) => NewRoute(),
"tip_route": (context) => TipRoute(),
"arguement_route": (context) => ArguementRoute(),
"button_route": (context) => WidgetButtonRoute(),
"image_route": (context) => WidgetImageRoute(),
"checkbox_route": (context) => WidgetCheckboxRoute(),
"input_route": (context) => WidgetInputRoute(),
},
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
Expand All @@ -38,20 +46,29 @@ class _MyHomePageState extends State<MyHomePage> {
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
body: Padding(
padding: EdgeInsets.all(10),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
FlatButton(
child: Text("open new page"),
child: Text(
"open new page",
textScaleFactor: 1,
style: TextStyle(fontSize: 30),
),
textColor: Colors.blue,
onPressed: () {
Navigator.pushNamed(context, "new_route");
},
),
FlatButton(
textColor: Colors.red,
child: Text('open TipRoute'),
child: Text(
'open TipRoute',
textScaleFactor: 1,
style: TextStyle(fontSize: 30),
),
onPressed: () async {
var result = await Navigator.push(context, MaterialPageRoute(
builder: (context) {
Expand All @@ -65,9 +82,53 @@ class _MyHomePageState extends State<MyHomePage> {
}),
FlatButton(
textColor: Colors.amber,
child: Text('open arguement route'),
child: Text(
'open arguement route',
textScaleFactor: 1,
style: TextStyle(fontSize: 30),
),
onPressed: () => Navigator.pushNamed(context, 'arguement_route',
arguments: 'hello, this is arguement from main.dart'),
),
FlatButton(
textColor: Colors.amber,
child: Text(
'open button route',
textScaleFactor: 1,
style: TextStyle(fontSize: 30),
),
onPressed: () => Navigator.pushNamed(context, 'button_route',
arguments: 'hello, this is arguement from main.dart'),
),
FlatButton(
textColor: Colors.amber,
child: Text(
'open image route',
textScaleFactor: 1,
style: TextStyle(fontSize: 30),
),
onPressed: () => Navigator.pushNamed(context, 'image_route',
arguments: 'hello, this is arguement from main.dart'),
),
FlatButton(
textColor: Colors.amber,
child: Text(
'open checkbox route',
textScaleFactor: 1,
style: TextStyle(fontSize: 30),
),
onPressed: () => Navigator.pushNamed(context, 'checkbox_route',
arguments: 'hello, this is arguement from main.dart'),
),
FlatButton(
textColor: Colors.amber,
child: Text(
'open input route',
textScaleFactor: 1,
style: TextStyle(fontSize: 30),
),
onPressed: () => Navigator.pushNamed(context, 'input_route',
arguments: 'hello, this is arguement from main.dart'),
)
],
),
Expand Down
5 changes: 2 additions & 3 deletions flutter_demo_counter/flutter_demo_counter/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,8 @@ flutter:
uses-material-design: true

# To add assets to your application, add an assets section, like this:
# assets:
# - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg
assets:
- images/flutter.png

# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware.
Expand Down

0 comments on commit df97851

Please sign in to comment.