Show Menu
Cheatography

Mobile computing Cheat Sheet (DRAFT) by

Mobile Computing for Networking

This is a draft cheat sheet. It is a work in progress and is not finished yet.

lib/ma­in.dart

import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Welcome to Flutter',
      home: Scaffold(
        appBar: AppBar(
          title: Text('Welcome to Flutter'),
        ),
        body: Center(
          child: Text('Hello World'),
        ),
      ),
    );
  }
}
 

Add English words package

             class MyApp extends StatelessWidget {            
                                   @override            
                                   Widget build(BuildContext context) {            
                    +                final wordPair = WordPair.random();            
                                     return MaterialApp(            
                                       title: 'Welcome to Flutter',            
                                       home: Scaffold(            
        @@ -16,7 +18,7 @@    
                                           title: Text('Welcome to Flutter'),            
                                         ),            
                                         body: Center(            
                    -                      child: Text('Hello World'),            
                    +                      child: Text(wordPair.asPascalCase),            
                                         ),            
                                       ),            
                                     );

add randomword widget

class RandomWords extends StatefulWidget {
  @override
  RandomWordsState createState() => RandomWordsState();
}
 

add Depend­encies

dependencies:
	    flutter:
     sdk: flutter
	    cupertino_icons: ^0.1.2
	+   english_words: ^3.1.5

word suggestion

Widget _buildSuggestions() {
  return ListView.builder(
      padding: const EdgeInsets.all(16.0),
      itemBuilder: /1/ (context, i) {
        if (i.isOdd) return Divider(); /2/

        final index = i ~/ 2; /3/
        if (index >= _suggestions.length) {
          _suggestions.addAll(generateWordPairs().take(10)); /4/
        }
        return _buildRow(_suggestions[index]);
      });
}