This file contains hidden or 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:news_aggreator/home_page.dart' | |
void main() => runApp(new MyApp()); | |
class MyApp extends StatelessWidget { | |
// This widget is the root of your application. | |
@override | |
Widget build(BuildContext context) { | |
return new MaterialApp( |
This file contains hidden or 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'; | |
class MyHomePage extends StatefulWidget { | |
MyHomePage({Key key, this.title}) : super(key: key); | |
// This widget is the home page of your application. It is stateful, meaning | |
// that it has a State object (defined below) that contains fields that affect | |
// how it looks. | |
// This class is the configuration for the state. It holds the values (in this |
This file contains hidden or 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> { | |
@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 | |
// than having to individually change instances of widgets. | |
This file contains hidden or 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) { |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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( | |
... |
OlderNewer