(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
| import 'dart:async'; | |
| import 'package:flutter/material.dart'; | |
| void main() => runApp(MyApp()); | |
| class MyApp extends StatelessWidget { | |
| @override | |
| Widget build(BuildContext context) { | |
| return MaterialApp( |
| // Copyright 2015 The Chromium Authors. All rights reserved. | |
| // Use of this source code is governed by a BSD-style license that can be | |
| // found in the LICENSE file. | |
| import 'package:flutter/material.dart'; | |
| import 'package:flutter/services.dart'; | |
| import 'package:flutter/widgets.dart'; | |
| /// A [FormField] that contains a [BetterTextField]. |
| // Copyright 2015 The Chromium Authors. All rights reserved. | |
| // Use of this source code is governed by a BSD-style license that can be | |
| // found in the LICENSE file. | |
| import 'dart:collection'; | |
| import 'package:flutter/cupertino.dart'; | |
| import 'package:flutter/material.dart'; | |
| import 'package:flutter/rendering.dart'; | |
| import 'package:flutter/services.dart'; |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
| apply plugin: 'com.google.gms.google-services' | |
| class DefaultAttributesPlugin implements Plugin<Project> { | |
| void apply(Project project) { | |
| project.afterEvaluate { | |
| def task = project.task('checkAttributes', type: DefaultAttributes) | |
| project.android.applicationVariants.all { variant -> | |
| project.tasks."dataBindingProcessLayouts${capitalizeFirstLetter(variant.flavorName)}${capitalizeFirstLetter(variant.buildType.name)}".doLast { | |
| task.execute() |
| #if($field.modifierStatic) | |
| static ## | |
| #end | |
| $field.type ## | |
| #set($name = $StringUtil.capitalizeWithJavaBeanConvention($StringUtil.sanitizeJavaIdentifier($helper.getPropertyName($field, $project)))) | |
| #if ($field.boolean && $field.primitive) | |
| #if ($StringUtil.startsWithIgnoreCase($name, 'is')) | |
| #set($name = $StringUtil.decapitalize($name)) | |
| #else | |
| is## |
| <#if applicationPackage??> | |
| import ${applicationPackage}.databinding.${fragmentLayoutName?replace('_', ' ')?capitalize?replace(' ','')}Binding; | |
| </#if> |
| <#if applicationPackage??> | |
| import ${applicationPackage}.databinding.${fragment_layout?replace('_', ' ')?capitalize?replace(' ','')}Binding; | |
| </#if> |
| public class ViewHolder extends RecyclerView.ViewHolder { | |
| ${fragment_layout?replace('_', ' ')?capitalize?replace(' ','')}Binding binding; | |
| public ViewHolder(View view) { | |
| super(view); | |
| binding = DataBindingUtil.bind(view); | |
| } | |
| } |
| @Override | |
| public void onBindViewHolder(final ViewHolder holder, int position) { | |
| holder.binding.setItem(mValues.get(position)); | |
| holder.binding.getRoot().setOnClickListener(new View.OnClickListener() { | |
| @Override | |
| public void onClick(View v) { | |
| if (null != mListener) { | |
| // Notify the active callbacks interface (the activity, if the | |
| // fragment is attached to one) that an item has been selected. |