Skip to content

Instantly share code, notes, and snippets.

@parthdave93
Last active January 14, 2020 09:29
Show Gist options
  • Save parthdave93/47b0a6b51c8ee6d49e8bda5b7a381f39 to your computer and use it in GitHub Desktop.
Save parthdave93/47b0a6b51c8ee6d49e8bda5b7a381f39 to your computer and use it in GitHub Desktop.
Flutter dummy UI for blog (no use of this gist other than blog example)
import 'package:flutter/material.dart';
import 'package:flutter_performance_check/utils.dart';
class PerformanceChartUI extends StatefulWidget {
@override
State<StatefulWidget> createState() {
return _PerformanceChartUIState();
}
}
class _PerformanceChartUIState extends State<PerformanceChartUI> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Title of the page"),
),
body: buildBody(),
);
}
hex(position){
if(position%2 ==0 ){
return HexColor("#0${position%2}b${position%2}c${position%2}");
}
return HexColor('#aabbcc');
}
buildCarousel(){
var carousel = List.generate(
10,
(pos) {
return SizedBox(
width: 200,
height: 200,
child: Card(
color: hex(pos),
child: Image.network(
"weburl",
width: 200,
height: 200,
),
),
);
},
);
var carouselList = Container(
height: 200,
child: ListView(
scrollDirection: Axis.horizontal,
children: carousel,
),
);
return carouselList;
}
buildBody() {
var children = List.generate(
100000,
(pos) {
return Card(
child: Column(
children: <Widget>[
buildCarousel(),
Center(child: Text("Position: $pos")),
],
),
);
},
);
return ListView(
shrinkWrap: true,
children: children,
);
}
}
import 'dart:ui';
class HexColor extends Color {
static int _getColorFromHex(String hexColor) {
hexColor = hexColor.toUpperCase().replaceAll("#", "");
if (hexColor.length == 6) {
hexColor = "FF" + hexColor;
}
return int.parse(hexColor, radix: 16);
}
HexColor(final String hexColor) : super(_getColorFromHex(hexColor));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment