Johnhong9527 5 years ago
parent
commit
e81816cb0d
5 changed files with 50 additions and 6 deletions
  1. BIN
      app/images/avatar.png
  2. 39 3
      app/lib/main.dart
  3. 7 0
      app/pubspec.lock
  4. 3 3
      app/pubspec.yaml
  5. 1 0
      flutter_in_action_source_code

BIN
app/images/avatar.png


+ 39 - 3
app/lib/main.dart

@@ -1,4 +1,5 @@
 import 'package:flutter/material.dart';
+import 'package:english_words/english_words.dart';
 
 void main() {
   runApp(MyApp());
@@ -135,7 +136,8 @@ class _MyHomePageState extends State<MyHomePage> {
                 //         fullscreenDialog: false));
               },
             ),
-            RouterTestRoute()
+            RouterTestRoute(),
+            RandomWordsWidget()
           ],
         ),
       ),
@@ -154,13 +156,35 @@ class NewRoute extends StatelessWidget {
   Widget build(BuildContext context) {
     //获取路由参数
     var args = ModalRoute.of(context).settings.arguments;
+
     return Scaffold(
       appBar: AppBar(
         title: Text("New route" + args),
       ),
       body: Center(
-        child: Text("This is new route" + args),
-      ),
+          child: Column(
+        children: [
+          Text("This is new route" + args),
+          RandomWordsWidget(),
+          Image(
+            image: AssetImage("images/avatar.png"),
+            width: 100.0,
+            color: Colors.blue,
+            colorBlendMode: BlendMode.difference,
+          ),
+          // Image(
+          //   image: NetworkImage(
+          //       "https://avatars2.githubusercontent.com/u/20411648?s=460&v=4"),
+          //   width: 100.0,
+          //   color: Colors.blue,
+          //   // colorBlendMode: BlendMode.difference,
+          // ),
+          // Image.network(
+          //   "https://avatars2.githubusercontent.com/u/20411648?s=460&v=4",
+          //   width: 100.0,
+          // )
+        ],
+      )),
     );
   }
 }
@@ -222,3 +246,15 @@ class RouterTestRoute extends StatelessWidget {
     );
   }
 }
+
+class RandomWordsWidget extends StatelessWidget {
+  @override
+  Widget build(BuildContext context) {
+    // 生成随机字符串
+    final wordPair = new WordPair.random();
+    return Padding(
+      padding: const EdgeInsets.all(8.0),
+      child: new Text(wordPair.toString()),
+    );
+  }
+}

+ 7 - 0
app/pubspec.lock

@@ -50,6 +50,13 @@ packages:
       url: "https://pub.flutter-io.cn"
     source: hosted
     version: "0.1.3"
+  english_words:
+    dependency: "direct main"
+    description:
+      name: english_words
+      url: "https://pub.flutter-io.cn"
+    source: hosted
+    version: "3.1.5"
   fake_async:
     dependency: transitive
     description:

+ 3 - 3
app/pubspec.yaml

@@ -27,6 +27,7 @@ dependencies:
   # The following adds the Cupertino Icons font to your application.
   # Use with the CupertinoIcons class for iOS style icons.
   cupertino_icons: ^0.1.3
+  english_words: ^3.1.3
 
 dev_dependencies:
   flutter_test:
@@ -42,9 +43,8 @@ flutter:
   # the material Icons class.
   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/avatar.png
   # An image asset can refer to one or more resolution-specific "variants", see
   # https://flutter.dev/assets-and-images/#resolution-aware.
   # For details regarding adding assets from package dependencies, see

+ 1 - 0
flutter_in_action_source_code

@@ -0,0 +1 @@
+Subproject commit e5e54b3082bc344fb9c236a9e24796ac568ac859