Skip to content

Instantly share code, notes, and snippets.

@slamdon
slamdon / FocusNode.dart
Created February 12, 2020 06:34
FocusNode
onChanged: (text) {
if (text.length != 0) {
// when input new text, make next TextField get focus
FocusScope.of(context).requestFocus(nextFocusNode);
} else {
// when remove text from TextField, make previous TextField get focus
FocusScope.of(context).requestFocus(previousFocusNode);
}
if (nextFocusNode == null) {
@slamdon
slamdon / indicator.dart
Last active February 13, 2020 13:27
FlutterCustom Indicator
@override
build(BuildContext context) {
return Stack(
children: <Widget>[
// transparent black background
Container(
height: this.getHeight(),
color: Color.fromRGBO(0, 0, 0, 0.6),
),
@slamdon
slamdon / getItems.dart
Created February 13, 2020 13:24
GetItems
Widget _getItems() {
return Container(
child: ListView.builder(
itemCount: this.dotCount,
scrollDirection: Axis.horizontal,
itemBuilder: (context, index) {
return _renderItem(index);
},
),
width: this.getWidth(),
@slamdon
slamdon / indicator.dart
Created February 13, 2020 13:35
indicator
double getWidth() {
return dotSize * dotCount + this.dotPadding * (dotCount + 5);
}
double getHeight() {
return dotSize + dotPadding * 2;
}
@slamdon
slamdon / renderItem.dart
Created February 13, 2020 13:36
renderItem
Widget _renderItem(int index) {
var color =
this.currentIndex == index ? this.dotColor : this.dotSelectedColor;
return GestureDetector(
child: Padding(
padding: EdgeInsets.all(this.dotPadding),
child: Container(
width: this.dotSize,
height: this.dotSize,
decoration: BoxDecoration(
@slamdon
slamdon / Code4Carsouel.dart
Created February 13, 2020 13:43
Code4Carsouel
@override
Widget build(BuildContext context) {
return Container(
child: Stack(
children: <Widget>[
Container(
child: pageView,
),
Positioned(
child: _getIndicator(),
@slamdon
slamdon / Indicator.dart
Created February 13, 2020 13:44
Indicator
Widget _getIndicator() {
return Code4Indicator(
dotCount: this.widget.imagePaths.length,
currentIndex: currentIndex,
dotColor: Color.fromRGBO(255, 255, 255, 1),
dotSelectedColor: Color.fromRGBO(255, 255, 255, 0.3),
dotPadding: 12,
dotSize: 14,
onItemTap: (index) {
pageController.jumpToPage(index);
@slamdon
slamdon / PageView.dart
Created February 13, 2020 13:46
PageView
Widget _getPageView() {
return pageView = PageView.builder(
itemCount: this.widget.imagePaths.length,
itemBuilder: (BuildContext context, int index) {
return Image(
image: AssetImage(this.widget.imagePaths[index]),
fit: BoxFit.cover,
);
},
onPageChanged: (index) {
@slamdon
slamdon / trip_page_item.dart
Last active February 15, 2020 06:14
BuildTextContainer
Widget _buildTextContainer() {
var titleContainer = Text(
this.trip.title,
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
letterSpacing: 1.0,
fontSize: 14,
),
);
@slamdon
slamdon / trip_page_item.dart
Last active February 15, 2020 06:14
ImageOverlayGradient
var imageOverlayGradient = DecoratedBox(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: FractionalOffset.topCenter,
end: FractionalOffset.bottomCenter,
colors: [
Color.fromRGBO(0, 0, 0, 0),
Color.fromRGBO(0, 0, 0, 0.8),
],
),