Show Menu
Cheatography

Mobile Application Cheat Sheet (DRAFT) by [deleted]

Cheat Sheet Application

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

Depend­encies

dependencies:            
               flutter:            
               sdk: flutter            
               cupertino_icons: ^0.1.2            
               english_words: ^3.1.5
=> entries can be addded through adding DEPEDENCY_NAME: VERSIoN

Stateful Widget

class BasePage extends StatefulWidget {
  State<StatefulWidget> createState() {
    return _BasePageState();
  }
}

class _BasePageState extends State<BasePage> {
  int _value = 0;
  
  void _increment() {
    setState(() {
      _value++;
    });
  }
}
Statef­ulW­idget are all the widget that interally have a dynamic value that can change during usage.
 

Infinite Scrolling View

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]);
      });
}
After reaching the of the list 10 more word pairings are generated

Adding Intera­ctivity

    onTap: () {
      setState(() {
        if (alreadySaved) {
          _saved.remove(pair);
        } else { 
          _saved.add(pair); 
        } 
      });
    },
onTap is added to the list so it can be interacted with
 

Theme

      theme: ThemeData(
        primaryColor: Colors.white,
      ),
Used to change the theme color

Navigation

Navigator.pushReplacement(
                  context,
                  MaterialPageRoute(
                    builder: (BuildContext context) => Class(
                          param: value,
                        ),
                  )),
Pushed a new page without being able to go back

Navigation

Navigator.push(
                  context,
                  MaterialPageRoute(
                    builder: (BuildContext context) => Class(
                          param: value,
                        ),
                  )),
Pushes a new page but it's still possible to go back