Giter Club home page Giter Club logo

youtube-tutorials's Introduction

Youtube

This repository's purpose is for people to easily navigate to different projects that I have made on my YouTube channel. It can be from creating a Form to implementing the BLoC architecture.

New code will from now on be added here

youtube-tutorials's People

Contributors

robertbrunhage avatar stefanbrunhage avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

youtube-tutorials's Issues

How to use multiple pages with this approach (firestore_crud_bloc)?

I get this error bad state stream has already been listened to when i added bottomNavigationBar to FirestoreCRUDPage. In all other pages i will use the same stream. but when i tap on bottom navigation to go to a new page i get that error, it tries to listen to the same stream again.
is there a way to prevent that?
thanks for the great work

Missing comma

In the project signup_screen_card in the file SignUp.dart add comma after parameter fontSize of the method buildText.

I/flutter ( 7906): Another exception was thrown: 'package:flutter/src/rendering/sliver_multi_box_adaptor.dart': Failed assertion: line 236 pos 16: 'indexOf(child) > index': is not true.

When I added more than 7 items, and I slide down the list and slide up, it shows an error

image

I/flutter ( 7906): Another exception was thrown: 'package:flutter/src/widgets/sliver.dart': Failed assertion: line 1059 pos 14: '_childElements.containsKey(index)': is not true.
I/flutter ( 7906): Another exception was thrown: 'package:flutter/src/rendering/sliver_multi_box_adaptor.dart': Failed assertion: line 470 pos 12: 'child.hasSize': is not true.
I/flutter ( 7906): Another exception was thrown: 'package:flutter/src/widgets/sliver.dart': Failed assertion: line 1059 pos 14: '_childElements.containsKey(index)': is not true.
I/flutter ( 7906): Another exception was thrown: 'package:flutter/src/rendering/sliver_multi_box_adaptor.dart': Failed assertion: line 470 pos 12: 'child.hasSize': is not true.
I/flutter ( 7906): Another exception was thrown: 'package:flutter/src/widgets/sliver.dart': Failed assertion: line 1059 pos 14: '_childElements.containsKey(index)': is not true.
I/flutter ( 7906): Another exception was thrown: 'package:flutter/src/rendering/sliver_multi_box_adaptor.dart': Failed assertion: line 470 pos 12: 'child.hasSize': is not true.
I/flutter ( 7906): Another exception was thrown: 'package:flutter/src/widgets/sliver.dart': Failed assertion: line 1059 pos 14: '_childElements.containsKey(index)': is not true.

I tried to sperate the code to two file, but the formkeyvalidation is not working

`import 'package:flutter/material.dart';
import 'dart:math';
import 'package:cloud_firestore/cloud_firestore.dart';

class FireStoreForm extends StatefulWidget {
@OverRide
FireStoreFormState createState() {
return FireStoreFormState();
}
}

class FireStoreFormState extends State {
final db = Firestore.instance;
final _formKey = GlobalKey();
String age;
String name;
String id;

TextFormField nameField() {
return TextFormField(
decoration: InputDecoration(
// border: InputBorder.none,
hintText: 'name',
// fillColor: Colors.grey[300],
filled: true,
),
validator: (value) {
if (value.isEmpty) {
return 'Please enter some text';
}
},
onSaved: (value) => {name = value, callback(name), print(name)},
);
}

TextFormField ageField() {
return TextFormField(
decoration: InputDecoration(
// border: InputBorder.none,
hintText: 'age',
// fillColor: Colors.grey[300],
filled: true,
),
validator: (value) {
if (value.isEmpty) {
return 'Please enter some text';
}
},
onSaved: (value) => {age = value, callback(age), print(age)},
);
}

@OverRide
Widget build(BuildContext context) {
return Form(
key: _formKey,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
TextFormField(
decoration: InputDecoration(
// border: InputBorder.none,
hintText: 'name',
// fillColor: Colors.grey[300],
filled: true,
),
validator: (value) {
if (value.isEmpty) {
return 'no value';
} else {
return 'value';
}
},
onSaved: (value) => {
name = value
}
),
SizedBox(height: 16.0),
// ageField(),
// SizedBox(height: 16.0),
],
),
);
}

String callback(value) {
return value;
}

createData() async {
if (_formKey.currentState.validate()) {
_formKey.currentState.save();
DocumentReference ref = await db
.collection('CRUD')
.add({'name': '$name ๐Ÿ˜Ž', 'age': '$age', 'todo': randomTodo()});
setState(() => id = ref.documentID);
print(ref.documentID);
}
}

void readData() async {
DocumentSnapshot snapshot = await db.collection('CRUD').document(id).get();
print(snapshot.data);
}

void updateData(DocumentSnapshot doc) async {
await db
.collection('CRUD')
.document(doc.documentID)
.updateData({'todo': randomTodo()});
}

void deleteData(DocumentSnapshot doc) async {
await db.collection('CRUD').document(doc.documentID).delete();
setState(() => id = null);
}

String randomTodo() {
final randomNumber = Random().nextInt(4);
String todo;
switch (randomNumber) {
case 1:
todo = 'Like and subscribe ๐Ÿ’ฉ';
break;
case 2:
todo = 'Twitter @RobertBrunhage ๐Ÿคฃ';
break;
case 3:
todo = 'Patreon in the description ๐Ÿค—';
break;
default:
todo = 'Leave a comment ๐Ÿค“';
break;
}
return todo;
}
}
`

`
import 'package:flutter/material.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'firestore_form.dart';

class FirestoreCRUDPage extends StatefulWidget {
@OverRide
FirestoreCRUDPageState createState() {
return FirestoreCRUDPageState();
}
}

class FirestoreCRUDPageState extends State {

Card buildItem(DocumentSnapshot doc) {
return Card(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'name: ${doc.data['name']}',
style: TextStyle(fontSize: 24),
),
Text(
'name: ${doc.data['age']}',
style: TextStyle(fontSize: 24),
),
Text(
'todo: ${doc.data['todo']}',
style: TextStyle(fontSize: 20),
),
SizedBox(height: 12),
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
FlatButton(
onPressed: () => FireStoreFormState().updateData(doc),
child: Text('Update todo',
style: TextStyle(color: Colors.white)),
color: Colors.green,
),
SizedBox(width: 8),
FlatButton(
onPressed: () => FireStoreFormState().deleteData(doc),
child: Text('Delete'),
),
],
)
],
),
),
);
}

@OverRide
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Firestore CRUD'),
),
body: ListView(
padding: EdgeInsets.all(8),
children: [
FireStoreForm(),
SizedBox(
height: 16.0,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
RaisedButton(
onPressed: FireStoreFormState().createData,
child: Text('Create', style: TextStyle(color: Colors.white)),
color: Colors.green,
),
RaisedButton(
onPressed: FireStoreFormState().id != null ? FireStoreFormState().readData : null,
child: Text('Read', style: TextStyle(color: Colors.white)),
color: Colors.blue,
),
],
),
SizedBox(
height: 16.0,
),
StreamBuilder(
stream: FireStoreFormState().db.collection('CRUD').snapshots(),
builder: (context, snapshot) {
if (snapshot.data.documents.length == 0) {
return Text('No Data');
} else {
return Column(
children: snapshot.data.documents
.map((doc) => buildItem(doc))
.toList());
}
},
)
],
),
);
}
}
`

[VERBOSE-2:ui_dart_state.cc(148)] Unhandled Exception: NoSuchMethodError: The method 'validate' was called on null.
Receiver: nul

I have googled, most of the post said Wrap with Form, and add the global form key, but I have added, still not working...

Thanks very much for your time

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.