This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import "dart:convert"; | |
// Convert Apple devices utsname.machine to Json. See https://gist.github.com/adamawolf/3048717 for the updated list | |
void main() { | |
final splits = sss.split("\n"); | |
final json = Map<String, String>(); | |
splits.forEach((s) { | |
final k = s.split(":"); | |
if (k.length == 2) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Tween<Offset> _offSetTween = Tween( | |
begin: Offset(1, 0), | |
end: Offset.zero, | |
); | |
... | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
handleDismiss(DismissDirection direction, int index) { | |
// Get a reference to the swiped item | |
final swipedEmail = items[index]; | |
// Remove it from the list | |
items.removeAt(index); | |
String action; | |
if (direction == DismissDirection.startToEnd) { | |
deleteItem(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar(), | |
body: ListView.builder( | |
itemCount: items.length, | |
itemBuilder: (context, index) { | |
var item = items[index]; | |
return Dismissible( | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static String validateDate(String value) { | |
if (value.isEmpty) { | |
return Strings.fieldReq; | |
} | |
int year; | |
int month; | |
// The value contains a forward slash if the month and year has been | |
// entered. | |
if (value.contains(new RegExp(r'(\/)'))) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static String validateCardNumWithLuhnAlgorithm(String input) { | |
if (input.isEmpty) { | |
return Strings.fieldReq; | |
} | |
input = getCleanedNumber(input); | |
if (input.length < 8) { // No need to even proceed with the validation if it's less than 8 characters | |
return Strings.numberIsInvalid; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
import 'package:intl/intl.dart'; | |
import 'package:news_aggreator/home_page.dart'; | |
class PostDetails extends StatefulWidget { | |
PostDetails(this.post); | |
final Post post; | |
@override | |
State<StatefulWidget> createState() => new _PostDetailsState(post); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Widget _getPostWidgets(int index) { | |
var post = postList[index]; | |
return new GestureDetector( | |
onTap: () { | |
openDetailsUI(post); | |
}, | |
child: new Container( | |
margin: const EdgeInsets.symmetric(horizontal: 5.0, vertical: 5.0), | |
child: new Card( | |
elevation: 3.0, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class _MyHomePageState extends State<MyHomePage> { | |
bool _isRequestSent = false; | |
List<Post> postList = []; | |
@override | |
Widget build(BuildContext context) { | |
// This method is rerun every time setState is called | |
// | |
// The Flutter framework has been optimized to make rerunning build methods | |
// fast, so that you can just rebuild anything that needs updating rather |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Post { | |
String title; | |
String summary; | |
String thumbUrl; | |
int timeStamp; | |
String url; | |
Post(this.title, this.summary, this.thumbUrl, this.timeStamp, this.url); | |
static Post getPostFrmJSONPost(dynamic jsonObject) { |
NewerOlder