Snippets Collections
Widget _signInButton() {




   return OutlineButton(


     splashColor: Colors.grey,


     onPressed: () {},


     shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(40)),


     highlightElevation: 0,


     borderSide: BorderSide(color: Colors.grey),


     child: Padding(


       padding: const EdgeInsets.fromLTRB(0, 10, 0, 10),


       child: Row(


         mainAxisSize: MainAxisSize.min,


         mainAxisAlignment: MainAxisAlignment.center,


         children: <Widget>[


           Image(image: AssetImage("assets/google_logo.png"), height: 35.0),


           Padding(


             padding: const EdgeInsets.only(left: 10),


             child: Text(


               'Sign in with Google',


               style: TextStyle(


                 fontSize: 20,


                 color: Colors.grey,


               ),


             ),


           )


         ],


       ),


     ),


   );


 }


Text('Click \u{2795} to add')
RichText( text: TextSpan( children: [ TextSpan( text: "Click ", ), WidgetSpan( child: Icon(Icons.add, size: 14), ), TextSpan( text: " to add", ), ], ), )
Center(
          child: new Container(
            padding: const EdgeInsets.all(8.0),
            height: 500.0,
            width: 500.0,
            child: new Stack(
              overflow: Overflow.visible,
              children: <Widget>[
                new Icon(Icons.pages, size: 36.0, color: Colors.red),
                new Positioned(
                  left: 20.0,
                  child: new Icon(Icons.pages, size: 36.0, color: Colors.green),
                ),
 
              ],
            ),
          ),
    )
main() {
  List customers = [];
  customers.add(Customer('Jack', 23));
  customers.add(Customer('Adam', 27));
  customers.add(Customer('Katherin', 25));

  customers.sort((a, b) => a.age.compareTo(b.age));
  print('Sort by Age: ' + customers.toString());

  customers.sort((a, b) => a.name.compareTo(b.name));
  print('Sort by Name: ' + customers.toString());
}
//Inside main.dart
return MaterialApp(
 initialRoute: WelcomeScreen.id,
 routes: {
   WelcomeScreen.id: (context) => WelcomeScreen(),
   LoginScreen.id: (context) => LoginScreen(),
   RegistrationScreen.id: (context) => RegistrationScreen(),
   ChatScreen.id: (context) => ChatScreen(),
 },
);

//Inside **** Class:
static const String id = '****';

//Inside onPressed
  onTap: () => Navigator.pushNamed(context, VideoScreen.id, arguments: {
                'chapter_name': 'Chapter $index',
              }),
              
 // In receiving side
 final  Map<String, String> received = ModalRoute.of(context).settings.arguments;
    final chapterName = received['chapter_name'];
 
import 'package:dynamicmathapp/services/auth.dart';
import 'package:firebase_database/firebase_database.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:dynamicmathapp/models/user.dart';
import 'package:cloud_firestore/cloud_firestore.dart';

class Home extends StatelessWidget {
  final AuthService _auth = AuthService();
  final ref = FirebaseDatabase.instance.reference();

  @override
  Widget build(BuildContext context) {
    User user = Provider.of<User>(context);

    return Scaffold(
      backgroundColor: Colors.brown[50],
      appBar: AppBar(
        title: Text('Welcome'),
        backgroundColor: Colors.brown[400],
        elevation: 0.0,
        actions: <Widget>[
          FlatButton.icon(
            icon: Icon(Icons.person),
            label: Text('logout'),
            onPressed: () async {
              await _auth.signOut();
            },
          ),
        ],
      ),
      body: Column(
        children: <Widget>[
          Container(
            child: Text(
              'ID:' + user.uid + 'email:' + user.email,
            ),
          ),
          RaisedButton(
            child: Text('Create Record'),
            onPressed: () {
              createRecord();
            },
          ),
          RaisedButton(
            child: Text('View Record'),
            onPressed: () {
              getData();
            },
          ),
          RaisedButton(
            child: Text('Update Record'),
            onPressed: () {
              updateData();
            },
          ),
          RaisedButton(
            child: Text('Delete Record'),
            onPressed: () {
              deleteData();
            },
          ),
        ],
      ),
    );
  }

  void createRecord() {
    ref
        .child('videos')
        .child('class_10')
        .child('chapter_1')
        .set([
      {"length": "1:3333", "title": "Introduction 1.1"},
      {"length": "2:30", "title": "Introduction 1.2"}
    ]);
  }

  void getData() {
    ref
        .child('videos')
        .child('class_10')
        .child('chapter_1')
        .once()
        .then((DataSnapshot data) {
      print(data..value);
      print(data.key);
    });
  }

  void updateData() {}

  void deleteData() {}
}
final ref = FirebaseDatabase.instance.reference();

 void getData() {
    ref
        .child('videos')
        .child('class_10')
        .child('chapter_1')
        .once()
        .then((DataSnapshot data) {
      print(data.value);
      print(data.key);
    });
  }
  
    void createRecord() {
    ref
        .child('videos')
        .child('class_10')
        .child('chapter_1')
        .set([
      {"length": "1:3333", "title": "Introduction 1.1"},
      {"length": "2:30", "title": "Introduction 1.2"}
    ]);
  }
   final databaseReference = Firestore.instance;

 
 void createRecord() async {
    Map data = {'length': '1:30:20', 'position': '1', 'title': 'Introduction 3.'};
    await databaseReference
        .collection("class_10")
        .document('chapter_4')
        .collection('videos')
        .document()
        .setData(
           data
);

//    await databaseReference.collection("classes")
//        .document('10')
//        .collection('chapter')
//        .document('1')
//    .collection('videos')
//    .document('1')
//        .setData({
//      'title': 'Introduction 1 Sets',
//      'length': '10:20'
//    });
  }

  void getData() {
    databaseReference
        .collection("class_10")
        .document('chapter_1')
        .collection('videos')
        .getDocuments()
        .then((QuerySnapshot snapshot) {
      snapshot.documents.forEach((f) => print('${f.data}}'));
    });
  }

  void updateData() {
    try {
      databaseReference
          .collection('books')
          .document('1')
          .updateData({'description': 'Head First Flutter'});
    } catch (e) {
      print(e.toString());
    }
    databaseReference
        .collection("classes")
        .document('10')
        .collection('chapter')
        .document('1')
        .collection('videos');
  }

  void deleteData() {
    try {
      databaseReference.collection('books').document('1').delete();
    } catch (e) {
      print(e.toString());
    }
  }
bool isAnagram(String str1, String str2) {
  String normalize(String str) => (str
          .toLowerCase()
          .replaceAll(RegExp(r'[^a-z0-9]', caseSensitive: false), '')
          .split('')
            ..sort())
      .join('');
  return normalize(str1) == normalize(str2);
}
Widget build(BuildContext context) {
  return Scaffold(
    appBar: AppBar(title: Text('IntrinsicWidth')),
    body: Center(
      child: IntrinsicHeight(
        child: Row(
          crossAxisAlignment: CrossAxisAlignment.stretch,
          children: <Widget>[
            RaisedButton(
              onPressed: () {},
              child: Text('Short'),
            ),
            RaisedButton(
              onPressed: () {},
              child: Text('A bit Longer'),
            ),
            RaisedButton(
              onPressed: () {},
              child: Text('The Longest text button'),
            ),
          ],
        ),
      ),
    ),
  );
}
Widget build(BuildContext context) {
  return Scaffold(
    appBar: AppBar(title: Text('IntrinsicWidth')),
    body: Center(
      child: IntrinsicWidth(
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.stretch,
          children: <Widget>[
            RaisedButton(
              onPressed: () {},
              child: Text('Short'),
            ),
            RaisedButton(
              onPressed: () {},
              child: Text('A bit Longer'),
            ),
            RaisedButton(
              onPressed: () {},
              child: Text('The Longest text button'),
            ),
          ],
        ),
      ),
    ),
  );
}
import 'package:flutter/material.dart';

void main() {
  runApp(
    new MaterialApp(
      title: 'Hello World App',
      home: new myApp(),
    )
  );
}

class myApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title: new Text('Hello World App'),
      ),
      body: new Center(
        child: new Text(
          'Hello, world!'
        ),
      ),
    );
  }
}
Text("Border test",
    style: TextStyle(
      inherit: true,
      fontSize: 48.0,
      color: Colors.pink,
      shadows: [
        Shadow( // bottomLeft
          offset: Offset(-1.5, -1.5),
          color: Colors.white
        ),
        Shadow( // bottomRight
          offset: Offset(1.5, -1.5),
          color: Colors.white
        ),
        Shadow( // topRight
          offset: Offset(1.5, 1.5),
          color: Colors.white
        ),
        Shadow( // topLeft
          offset: Offset(-1.5, 1.5),
          color: Colors.white
        ),
      ]
    ),
);
String capitalize(String s) {
  if (s == null || s.isEmpty) {
    return s;
  }
  return s.length < 1 ? s.toUpperCase() : s[0].toUpperCase() + s.substring(1);
}
bookmark
dashboard

Mon Jun 15 2020 12:36:30 GMT+0000 (UTC)

#dart
bookmark
dashboard

Mon Jun 15 2020 12:36:06 GMT+0000 (UTC) https://pusher.com/tutorials/flutter-listviews

#dart
bookmark
dashboard

Mon Jun 15 2020 12:35:38 GMT+0000 (UTC)

#dart
bookmark
dashboard

Mon Jun 15 2020 12:34:47 GMT+0000 (UTC) https://pub.dev/packages/flutter_svg#-readme-tab-

#dart
bookmark
dashboard

Mon Jun 15 2020 12:34:17 GMT+0000 (UTC) https://www.freewebmentor.com/questions/does-flutter-support-negative-margin

#dart
bookmark
dashboard

Mon Jun 15 2020 12:33:46 GMT+0000 (UTC) Dart/Flutter List Tutorial with Examples

#dart
bookmark
dashboard

Mon Jun 15 2020 12:33:08 GMT+0000 (UTC)

#dart
bookmark
dashboard

Mon Jun 15 2020 12:31:36 GMT+0000 (UTC)

#dart
bookmark
dashboard

Sun Jun 14 2020 07:37:22 GMT+0000 (UTC)

#dart
bookmark
dashboard

Sun Jun 14 2020 07:08:20 GMT+0000 (UTC) https://petercoding.com/firebase/2020/02/06/get-started-with-firebase-in-flutter/

#dart
bookmark
dashboard

Sun Jun 14 2020 03:21:06 GMT+0000 (UTC)

#dart
bookmark
dashboard

Tue May 12 2020 11:03:36 GMT+0000 (UTC) https://gist.github.com/basselch/51b8a047c5c86355c5859a2e5f198fd0

#dart #flutter
bookmark
dashboard

Tue May 12 2020 11:02:17 GMT+0000 (UTC) https://stackoverflow.com/questions/48893935/how-to-remove-debug-banner-in-flutter-on-android-emulator

#dart #flutter
bookmark
dashboard

Tue Apr 28 2020 19:52:02 GMT+0000 (UTC) https://www.30secondsofcode.org/dart/s/is-anagram/

#dart
bookmark
dashboard

Wed Jan 22 2020 18:43:41 GMT+0000 (UTC) https://medium.com/flutter-community/flutter-layout-cheat-sheet-5363348d037e

#dart #flutter #layouts
bookmark
dashboard

Wed Jan 22 2020 18:35:33 GMT+0000 (UTC) https://medium.com/flutter-community/flutter-layout-cheat-sheet-5363348d037e

#dart #flutter #layout
bookmark
dashboard

Sun Dec 29 2019 19:42:22 GMT+0000 (UTC) https://kodestat.gitbook.io/flutter/flutter-hello-world

#android #dart #flutter #ios #helloworld
bookmark
dashboard

Thu Dec 26 2019 18:27:15 GMT+0000 (UTC) https://stackoverflow.com/questions/52146269/how-to-decorate-text-stroke-in-flutter

#dart #flutter #howto

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension