Nested Flatlists inside ScrollViews is not scrolling? - list

FlatList scrolling issue :~
I am facing issue in scrolling of my flatslists inside 2 scrollviews here is my code structure plz any one if know the solution I shall be thank full
Here is my Code:
<ScrollView
nestedScrollEnabled={true}
style={styles.mainContainer}>
<View style={{ height: 10, backgroundColor: '#000' }}>
</View>
<View style={{height: 90, backgroundColor: '#fff', flexDirection: 'row' }}>
</View>
<View style={{ backgroundColor: '#000', height: 50, flexDirection: 'row', justifyContent: 'space-between' }}>
</View>
<View style={styles.MidCards}>
</View>
<View style={styles.TasksDropDown}>
</View>
<View style={styles.TasksView}>
</View>
<View style={styles.ListsAllinone}>
<ScrollView
style={{flex:1}}
horizontal={true}
nestedScrollEnabled={true}
pagingEnabled={true}
showsHorizontalScrollIndicator={false}
legacyImplementation={false}
>
<View nestedScrollEnabled={true} style={styles.List1}>
<View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
</View>
<FlatList
data={DATA}
renderItem={renderItem}
keyExtractor={item => item.id}
nestedScrollEnabled={true}
/>
</View>
<View style={styles.List1}>
<View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
</View>
<FlatList
data={DATA}
renderItem={renderItem}
keyExtractor={item => item.id}
/>
</View>
<View style={styles.List1}>
<FlatList
data={DATA}
renderItem={renderItem}
keyExtractor={item => item.id}
/>
</View>
</ScrollView>
</View>
<View style={styles.footer}>
</View>
</ScrollView >
**Style sheet**
const styles = StyleSheet.create({
mainContainer: {
flex: 1,
backgroundColor: '#ddd'
},
TopAdvertisement: {
flex: .2,
height: 100,
backgroundColor: '#fff'
},
TopBanner: {
marginBottom: 10,
height: 100,
},
footer: {
height: 100,
backgroundColor: '#000',
padding:20
},
MidCards: {
margin: 5,
flexDirection: 'row',
shadowRadius: 20,
shadowOpacity: 5,
borderRadius:5,
},
TasksDropDown: {
margin: 5,
marginHorizontal: 10,
backgroundColor: '#fff',
justifyContent: 'center',
padding: 5,
borderRadius:5,
},
TasksView: {
margin: 5,
marginHorizontal: 10,
backgroundColor: '#fff',
justifyContent: 'center',
padding: 5,
flexDirection: 'row',
borderRadius:5,
},
ListsAllinone: {
margin: 5,
padding: 10,
},
List1: {
flexGrow :1,
//border:1,
width: windowWidth - 30,
backgroundColor: '#fff'
},
});
Discription:
As You can see I used nestedScrollEnabled={true} property also but all the three nested flatlists are not working
How Can I make it scrollable vertically?
I want my whole screen to have scrollable property and also nested scrollView with horizontal scroll property and the most nested flatlists should also scroll
Please can anyone tell me what the problem is here? I have tried alot but failed to solve this
thanks :)

I have fixed Nested Flatlists inside ScrollView not scrolling issue by following steps:
1. Adding a view with fix height outside flatlist
2. Also fixed the height of the outer view same to height of newly added view
3. Add nestedScrollEnabled inside flatlist i.e nestedScrollEnabled={true}
Here is my code Example:
<View nestedScrollEnabled={true} style={styles.List1}>//also fix heigth of this view same to height of inner vie
<View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
</View>
<View style={{height:600}}>//newly added view
<FlatList
data={DATA}
renderItem={renderItem}
keyExtractor={item => item.id}
nestedScrollEnabled
/>
</View>
</View>

Related

Trouble connecting Flutter frontend with Django backend through API

I am working on the frontend project using Flutter, and I am trying to connect it to the Django backend using API, I am completely lost on how to do that, can anyone help me, I would appreciate your help. I am very new to Flutter. We have implemented all the APIs with the Django REST framework.
Here is my front-end code for the register page, this code is using Dart language.
import 'dart:io';
import 'package:flutter/services.dart';
import 'package:flutter/src/foundation/key.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:flutter/material.dart';
import 'package:image_picker/image_picker.dart';
import './register2.dart';
class MyClip extends CustomClipper<Rect> {
Rect getClip(Size size) {
return Rect.fromLTWH(0, 0, 100, 100);
}
bool shouldReclip(oldClipper) {
return false;
}
}
class Avatar extends StatefulWidget {
#override
State<Avatar> createState() => _AvatarState();
}
class _AvatarState extends State<Avatar> {
File? image;
Future pickImage() async {
try {
final image = await ImagePicker().pickImage(source: ImageSource.gallery);
if (image == null) return;
final imageTemp = File(image.path);
setState(() => this.image = imageTemp);
} on PlatformException catch (e) {
print('Failed: $e');
}
}
#override
Widget build(BuildContext context) {
return Container(
child: image != null
? ClipOval(
child: Image.file(
image!,
width: 100,
height: 100,
fit: BoxFit.cover,
),
)
: Image.asset('assets/images/icon_sample.jpeg'),
);
}
}
class Regfirst extends StatelessWidget {
#override
Widget build(BuildContext context) {
var bg = 'assets/images/bg.jpeg';
return Material(
child: Container(
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage(bg),
fit: BoxFit.cover,
),
),
child: Container(
child: Stack(
alignment: Alignment.center,
children: [
Positioned(
top: 0,
height: 400,
width: 330,
child: Avatar(),
),
Positioned(
top: 350,
height: 300,
width: 330,
child: Column(
//mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Expanded(
child: Row(
children: [
Expanded(
flex: 3,
child: TextField(
decoration: InputDecoration(
hintText: "First name",
hintStyle: TextStyle(
color: Colors.white,
fontSize: 25,
),
labelStyle: TextStyle(
fontSize: 24, color: Colors.white),
border: UnderlineInputBorder(),
),
),
),
SizedBox(width: 40),
Expanded(
flex: 3,
child: TextField(
decoration: InputDecoration(
hintText: "Last name",
hintStyle: TextStyle(
color: Colors.white,
fontSize: 25,
),
labelStyle: TextStyle(
fontSize: 24, color: Colors.white),
border: UnderlineInputBorder(),
),
),
),
],
),
),
Expanded(
child: Row(
children: [
Expanded(
flex: 3,
child: TextField(
decoration: InputDecoration(
hintText: "Email",
hintStyle: TextStyle(
color: Colors.white,
fontSize: 25,
),
labelStyle: TextStyle(
fontSize: 24, color: Colors.white),
border: UnderlineInputBorder(),
),
),
),
SizedBox(width: 40),
Expanded(
flex: 3,
child: TextField(
decoration: InputDecoration(
hintText: "Phone number",
hintStyle: TextStyle(
color: Colors.white,
fontSize: 25,
),
labelStyle: TextStyle(
fontSize: 24, color: Colors.white),
border: UnderlineInputBorder(),
),
),
),
],
),
),
Expanded(
child: Row(
children: [
Expanded(
flex: 3,
child: TextField(
decoration: InputDecoration(
hintText: "Password",
hintStyle: TextStyle(
color: Colors.white,
fontSize: 25,
),
labelStyle: TextStyle(
fontSize: 24, color: Colors.white),
border: UnderlineInputBorder(),
),
),
),
],
),
),
Expanded(
child: Row(
children: [
Expanded(
flex: 3,
child: TextField(
decoration: InputDecoration(
hintText: "Confirm Password",
hintStyle: TextStyle(
color: Colors.white,
fontSize: 25,
),
labelStyle: TextStyle(
fontSize: 24, color: Colors.white),
border: UnderlineInputBorder(),
),
),
),
],
),
),
],
),
),
Positioned(
top: 680,
height: 45,
width: 250,
child: ElevatedButton(
// color: Colors.blueAccent,
onPressed: () {
Navigator.push(context,
MaterialPageRoute(builder: (context) => Regsec()));
},
child: Text(
'Next',
style: TextStyle(fontSize: 30),
),
),
),
],
),
),
),
);
}
}

I can't transfer data from a screen to a list, I tried hive, but I was unable to compose the data structure, as it did not generate the g.dart file

family of programmers. I'm new to programming, I'm having a hard time transferring data from a screen to a list, where the user can review the messages sent. Sorry for this one with a silly question like that, but I already tried it in the library, videos and etc. But I did not find the solution, please, could someone help me with this? Thanks! (I've been stuck on this issue for days).
My code:
import 'dart:io';
import 'package:flutter/services.dart';
import 'package:animated_text_kit/animated_text_kit.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:animated_button/animated_button.dart';
import 'package:giffy_dialog/giffy_dialog.dart';
import 'package:mailer/mailer.dart';
import 'package:mailer/smtp_server/gmail.dart';
import 'package:ouvidoria_mvl/main.dart';
// ignore: must_be_immutable
class PaginadeBoasVindasAN extends StatelessWidget {
String _localAn;
String _problemaAn;
File _imagemAn;
File _imagemGaleriaAn;
PaginadeBoasVindasAN(
this._localAn,
this._problemaAn,
this._imagemAn,
this._imagemGaleriaAn,
);
final _formKey = GlobalKey<FormState>();
// Aqui vamos criar o e-mail - smtp
enviarMensagem() async {
String username = '#gmail.com';
String password = '4#';
final smtpServer = gmail(username, password);
// Use the SmtpServer class to configure an SMTP server:
// final smtpServer = SmtpServer('smtp.domain.com');
// See the named arguments of SmtpServer for further configuration
// options.
// Create our message.
final message = Message()
..from = Address('', '')
..recipients.add('#gmail.com')
..ccRecipients.addAll(['destCc1#gmail.com', 'destCc1#gmail.com'])
..bccRecipients.add(Address('destCc1#gmail.com'))
..subject = '$_localAn :: ${DateTime.now()}'
..text = 'LOCAL DA OCORRÊNCIA: $_localAn,n\ OCORRÊNCIA: $_problemaAn';
if ((_imagemAn != null) && (_imagemAn != ""))
message.attachments.add(FileAttachment(_imagemAn,));
if ((_imagemGaleriaAn!= null) && (_imagemGaleriaAn!= ""))
message.attachments.add(FileAttachment(_imagemGaleriaAn,));
try {
final sendReport = await send(message, smtpServer);
print('Mensagem enviada: ' + sendReport.toString());
} on MailerException catch (e) {
print('Mensagem não enviada.');
for (var p in e.problems) {
print('Problema: ${p.code}: ${p.msg}');
}
}
var connection = PersistentConnection(smtpServer);
await connection.send(message);
await connection.close();
}
// HERE THE APP CONFIGURATION IS ENDED
// The Function below blocks the screen rotation, thus allowing the app to stay in vertical mode
void blockgiro() {
SystemChrome.setPreferredOrientations(
[DeviceOrientation.portraitDown, DeviceOrientation.portraitUp]);
}
#override
Widget build(BuildContext context) {
blockgiro();
return Stack(children: <Widget>[
Scaffold(
backgroundColor: Colors.white,
body: SingleChildScrollView(
padding: EdgeInsets.only(bottom: 20),
child: Container(
margin: EdgeInsets.all(10),
color: Colors.transparent,
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Container(
margin: EdgeInsets.only(
left: 1,
bottom: 10,
top: 10,
),
padding: EdgeInsets.all(10),
height: 200,
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
blurRadius: 0,
color: Colors.white,
offset: Offset(0, 0))
],
borderRadius: BorderRadius.circular(13),
color: Colors.white),
child:
Image.asset("Assets/image/enviando-loading.gif")),
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
padding: EdgeInsets.only(
bottom: 30, right: 1, left: 1, top: 20),
),
Container(
margin: EdgeInsets.only(
left: 1,
bottom: 10,
top: 5,
),
padding: EdgeInsets.all(10),
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
blurRadius: 2,
color: Colors.black54,
offset: Offset(1, 1))
],
borderRadius: BorderRadius.circular(13),
color: Colors.white),
child: Align(
alignment: Alignment.topLeft,
child: SizedBox(
width: 250.0,
child: TypewriterAnimatedTextKit(
pause: Duration(minutes: 10),
speed: Duration(milliseconds: 100),
onTap: () {
print("Tap Event");
},
text: ['The location is this: $_localAn'],
textStyle: TextStyle(
color: Colors.black,
fontSize: 20.0,
fontFamily: "Agne"),
textAlign: TextAlign.start,
),
),
),
),
Container(
margin: EdgeInsets.only(
left: 1,
bottom: 10,
top: 10,
),
padding: EdgeInsets.all(10),
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
blurRadius: 4,
color: Colors.black54,
offset: Offset(2, 2))
],
borderRadius: BorderRadius.circular(13),
color: Colors.white),
child: Align(
alignment: Alignment.topLeft,
child: SizedBox(
width: 1000.0,
child: TypewriterAnimatedTextKit(
pause: Duration(minutes: 10),
onTap: () {
print("Tap Event");
},
text: [
'Its occurrence: $_problemaAn',
],
textStyle: TextStyle(
color: Colors.black,
fontSize: 20.0,
fontFamily: "Agne"),
textAlign: TextAlign.justify,
curve: Curves.linear),
),
)),
Container(
margin: EdgeInsets.all(10),
padding: EdgeInsets.all(10),
child: _imagemAn != null
? Image.file(
_imagemAn,
fit: BoxFit.scaleDown,
)
: Center(
child: Text(
'',
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.w400),
),
),
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
blurRadius: 1,
color: Colors.transparent,
offset: Offset(1, 1))
],
borderRadius: BorderRadius.circular(30),
color: Colors.transparent),
),Container(
margin: EdgeInsets.all(10),
padding: EdgeInsets.all(10),
child: _imagemGaleriaAn != null
? Image.file(
_imagemGaleriaAn,
fit: BoxFit.scaleDown,
)
: Center(
child: Text(
'Capture a photo',
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.w400),
),
),
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
blurRadius: 1,
color: Colors.transparent,
offset: Offset(1, 1))
],
borderRadius: BorderRadius.circular(30),
color: Colors.transparent),
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
TypewriterAnimatedTextKit(
pause: Duration(minutes: 10),
onTap: () {
print("Select below");
},
text: [
'Need to edit your message?',
],
textStyle: TextStyle(
fontWeight: FontWeight.w600,
color: Colors.lightBlueAccent,
fontSize: 20.0,
fontFamily: "Agne"),
textAlign: TextAlign.center,
curve: Curves.linear),
],
),
//INICIO DOS BOTOES SIM E NAO
Container(
padding: EdgeInsets.only(bottom: 50),
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Container(
margin: EdgeInsets.only(
bottom: 2, top: 2, right: 55),
alignment: Alignment.centerLeft,
child: AnimatedButton(
shape: BoxShape.rectangle,
child: Text(
'Edit',
style: TextStyle(
fontSize: 15,
color: Colors.white,
fontWeight: FontWeight.w500,
),
),
onPressed: () {
Navigator.pop(context);
},
width: 70,
height: 40,
color: Theme.of(context).primaryColor,
shadowDegree: ShadowDegree.dark,
enabled: true,
),
),
//ACIMA SIM, ABAIXO NÃO
Container(
margin: EdgeInsets.only(
bottom: 2, top: 2, left: 55),
alignment: Alignment.centerRight,
child: AnimatedButton(
child: const Text(
'Send',
style: TextStyle(
fontSize: 19,
color: Colors.white,
fontWeight: FontWeight.w500,
),
),
onPressed: () {
enviarMensagem();
showDialog(
context: context,
builder: (_) => AssetGiffyDialog(
image: Image.asset(
'Assets/image/Correta.gif'),
title: Text(
'Success',
style: TextStyle(
fontSize: 22.0,
fontWeight:
FontWeight.w600),
),
description: Text(
'Hi, we received your message',
style: TextStyle(),
),
entryAnimation:
EntryAnimation.BOTTOM_RIGHT,
onlyCancelButton: false,
onOkButtonPressed: () async {
final result =
await Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
splashScreen()));
},
onlyOkButton: true,
));
},
width: 70,
height: 40,
color: Theme.of(context).primaryColor,
shadowDegree: ShadowDegree.dark,
enabled: true,
),
)
],
),
],
),
Container(
padding: EdgeInsets.only(bottom: 50),
),
]))),
)
]);
}
}

HideOverlappingLabels in ApexCharts for xAxis type category

I have this apexcharts definition and when i've got more than e.g. 300 datasamples for my series things are overlapping on the xAxis like this
i would rather see something like this though
The option "hideOverlapLabels" does not work since it only works with timeseries from what i've read.
I know i can reduce the ticks but i want the chart to be zoomable and have all data in it.
Is there a way how i can prevent the labels to overlap?
var options_apex = {
series: null,
colors: [ '#0054ff', '#FF0000' ,'#FF0000'],
chart: {
height: 450,
type: 'line',
zoom: {
enabled: true
},
animations: {
enabled: false
}
},
stroke: {
width: [3, 3, 3],
curve: 'straight'
},
labels: null,
title: {
text: "Serial Data",
align: 'center',
margin: 10,
offsetX: 0,
offsetY: 0,
floating: false,
style: {
fontSize: '14px',
fontWeight: 'bold',
fontFamily: undefined,
color: '#263238'
},
},
subtitle: {
text: "the reckoning",
align: 'center',
margin: 10,
offsetX: 0,
offsetY: 20,
floating: true,
style: {
fontSize: '12px',
fontWeight: 'normal',
fontFamily: undefined,
color: '#9699a2'
},
},
xaxis: {
type:"category",
labels: {
rotate: -90,
rotateAlways: true,
hideOverlappingLabels: true,
style: {
colors: [],
fontSize: '7px',
fontFamily: 'Roboto',
fontWeight: 100,
cssClass: 'apexcharts-xaxis-label',
}
},
axisTicks: {
show: true,
borderType: 'solid',
color: '#78909C',
height: 6,
offsetX: 0,
offsetY: 0
},
tickAmount: undefined,
title: {
text: "STEP ID",
offsetX: 0,
offsetY: 0,
style: {
color: "#0000ff",
fontSize: '12px',
fontFamily: 'Helvetica, Arial, sans-serif',
fontWeight: 600,
cssClass: 'apexcharts-xaxis-title',
},
}
},
};
i used: tickAmount:15 , and work for my , this show 15 values and hide anothers, also you can try applied formatt and if condicional, to xaxis with:
formatter: function (value) {
if(value && ((value.split(':')[1][1] === '0') || (value.split(':')[1][1] === '5'))){
return (value);
}else{
value='';
return('');
}
}
I think i found the solution
xaxis: {
type:"category",
tooltip: {
enabled: false,
formatter: undefined,
offsetY: 0,
style: {
fontSize: 0,
fontFamily: 0,
},
},
labels: {
rotate: -45,
rotateAlways: true,
hideOverlappingLabels: true,
style: {
colors: [],
fontSize: '6px',
fontFamily: 'Roboto',
fontWeight: 80,
//cssClass: 'apexcharts-xaxis-label',
},
axisTicks: {
show: true,
borderType: 'solid',
color: '#78909C',
height: 6,
offsetX: 0,
offsetY: 0
},
},
With this setup and setting not the Labels but Categories with
options_apex.xaxis.categories = labels;
things seem to work without overlapping.

flutter - How do position the value from the List to up?

I have a List<Address> where in the Address class there are several keys, between:
id, address, city and isPrimary.
I want to work with isPrimary, suppose that when I set isPrimary address from the list to true then that Address value positions to up (primary). how to do it?
The following is the List<Address> that I mean:
[
{ 'id': 1,
'address': '40 Talbot Ambler, PA 19002',
'city': 'New York',
'isPrimary': false
},
{ 'id': 2,
'address': '618 Oak Valley West Deptford, NJ 08096',
'city': 'Sydney',
'isPrimary': true
},
{ 'id': 3,
'address': '8207 Gulf Ringgold, GA 30736',
'city': 'London',
'isPrimary': false
},
{ 'id': 4,
'address': '873 Ridgewood St.Romeoville, IL 60446',
'city': 'Manchester',
'isPrimary': false
},
]
I want Address that is isPrimary = true to be at the top of the List, followed by a list below with isPrimary = false
So that looks like this:
[
{ 'id': 2,
'address': '618 Oak Valley West Deptford, NJ 08096',
'city': 'Sydney',
'isPrimary': true
},
{ 'id': 1,
'address': '40 Talbot Ambler, PA 19002',
'city': 'New York',
'isPrimary': false
},
{ 'id': 3,
'address': '8207 Gulf Ringgold, GA 30736',
'city': 'London',
'isPrimary': false
},
{ 'id': 4,
'address': '873 Ridgewood St.Romeoville, IL 60446',
'city': 'Manchester',
'isPrimary': false
},
]
See my code below:
class UserAddressItemList extends StatelessWidget {
#override
Widget build(BuildContext context) {
return ScopedModelDescendant<MainModel>(
builder: (context, child, model) {
return model.isLoadingUser
? LoadingProgress
: model.addressList == null
? NoProductFound()
: ListView.builder(
physics: ClampingScrollPhysics(),
scrollDirection: Axis.horizontal,
itemCount:
model.addressList == null ? 0 : model.getAddressCount(),
itemBuilder: (context, i) {
var address = model.addressList[i];
return _buildAddressItemList(address, context);
},
);
},
);
}
Widget _buildAddressItemList(Address address, BuildContext context) {
return Container(
padding: EdgeInsets.symmetric(horizontal: 3),
height: 150,
width: 280,
child: Card(
// color: Colors.blueGrey,
elevation: 2.0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(10))),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
SizedBox(height: 15),
Row(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Container(
margin: EdgeInsets.only(left: 20),
// color: Colors.greenAccent,
width: 120,
child: Text(
'${address.address}\n'
'${address.city}',
style: Theme.of(context).textTheme.title.copyWith(
fontSize: 16,
fontWeight: FontWeight.w400,
height: 1.1),
),
),
Container(
padding: EdgeInsets.only(right: 15),
child: Icon(
FontAwesomeIcons.minus,
size: 16,
color: Colors.red,
))
],
),
SizedBox(height: 5),
Container(
height: 20,
// color: Colors.green,
margin: EdgeInsets.symmetric(horizontal: 10),
child: Row(
crossAxisAlignment: CrossAxisAlignment.end,
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
Container(
padding: EdgeInsets.only(bottom: 2),
child: Text(
"Delivery Address",
style: Theme.of(context)
.textTheme
.caption
.copyWith(
fontSize: 12, color: Colors.grey[400]),
)),
SizedBox(width: 10),
Container(
child: Icon(FontAwesomeIcons.solidCheckCircle,
size: 20,
color: address.isPrimary
? Colors.blue[600]
: Colors.grey),
)
],
)),
SizedBox(height: 5),
],
)));
}
}
isPrimary is not used to set the position. You should manually set the position through ScrollController.
example code:
class ListViewPage extends StatefulWidget {
#override
ListViewPageState createState() {
return new ListViewPageState();
}
}
class ListViewPageState extends State<ListViewPage> {
ScrollController _scrollController;
#override
initState() {
_scrollController = ScrollController();
_scrollController.animateTo(
40.0, // insert your ListItem's height.
duration: Duration(
milliseconds: 500,
),
curve: Curves.linear,
);
super.initState();
}
Widget build(context) {
return ListView.builder(
controller: _scrollController,
itemCount: 100,
itemBuilder: (context, int index) {
return Container(
height: 40.0,
width: double.infinity,
child: Text(
index.toString(),
),
);
},
);
}
}

How can I force annotations to always display above columns?

I want the annotations above columns to always BE ABOVE columns. I set annotations.alwaysOutside to true, but whenever a column reaches the roof of the chart, it will position the annotation within the column. If you run the code on JSFiddle you'll see what I mean.
So, how can I force annotations to ALWAYS display above columns?
https://jsfiddle.net/y7ootfoo/
<link href='https://fonts.googleapis.com/css?family=Lato' rel='stylesheet' type='text/css'>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
google.charts.load("current", {
packages: ['corechart']
});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
["Mana Cost", "Cards"],
["0", 1],
["1", 2],
["2", 3],
["3", 4],
["4", 4],
["5", 3],
["6", 2],
["7+", 1],
]);
var view = new google.visualization.DataView(data);
view.setColumns([0, 1, {
calc: "stringify",
sourceColumn: 1,
type: "string",
role: "annotation",
}, ]);
var options = {
title: "Cards/Mana Cost",
width: '750',
height: '375',
backgroundColor: "#FFF",
enableInteractivity: false,
bar: {
groupWidth: "90%"
},
legend: {
position: "none"
},
annotations: {
alwaysOutside: true,
stem: {
color: "transparent"
},
textStyle: {
fontName: 'Lato',
fontSize: 18.75,
bold: true,
italic: false,
auraColor: 'transparent',
color: "#000"
}
},
chartArea: {
backgroundColor: "#FFF"
},
titleTextStyle: {
color: "#000",
fontName: "Lato",
fontSize: 25,
bold: true,
italic: false
},
vAxis: {
gridlines: {
color: 'transparent'
},
textPosition: "none"
},
hAxis: {
textStyle: {
color: "#000",
fontName: "Lato",
fontSize: 18.75,
bold: true,
italic: false
}
}
};
var chart = new google.visualization.ColumnChart(document.getElementById("columnchart_values"));
chart.draw(view, options);
}
</script>
<div id="columnchart_values" style="width: 900px; height: 300px;"></div>
set
var options = {
vAxis: {
viewWindow:{
max: maxV, //maximum value of annotations + 1
},
}}
I also add
chartArea: {
width: '95%',
}
https://jsfiddle.net/damiantt/y7ootfoo/1/
complete code:
<link href='https://fonts.googleapis.com/css?family=Lato' rel='stylesheet' type='text/css'>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
google.charts.load("current", {
packages: ['corechart']
});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
["Mana Cost", "Cards"],
["0", 1],
["1", 2],
["2", 3],
["3", 4],
["4", 4],
["5", 3],
["6", 2],
["7+", 1],
]);
var maxV = 0;
for (var i = 0; i < data.getNumberOfRows(); i++) {
if(data.getValue(i, 1) > maxV) {
maxV = data.getValue(i, 1);
}
}
maxV++;
var view = new google.visualization.DataView(data);
view.setColumns([0, 1, {
calc: "stringify",
sourceColumn: 1,
type: "string",
role: "annotation",
}, ]);
var options = {
title: "Cards/Mana Cost",
width: '750',
height: '375',
backgroundColor: "#FFF",
enableInteractivity: false,
bar: {
groupWidth: "90%"
},
legend: {
position: "none"
},
annotations: {
alwaysOutside: true,
stem: {
color: "transparent"
},
textStyle: {
fontName: 'Lato',
fontSize: 18.75,
bold: true,
italic: false,
auraColor: 'transparent',
color: "#000"
}
},
chartArea: {
width: '95%',
backgroundColor: "#FFF"
},
titleTextStyle: {
color: "#000",
fontName: "Lato",
fontSize: 25,
bold: true,
italic: false
},
vAxis: {
viewWindow:{
max:maxV,
},
gridlines: {
color: 'transparent'
},
textPosition: "none"
},
hAxis: {
textStyle: {
color: "#000",
fontName: "Lato",
fontSize: 18.75,
bold: true,
italic: false
}
}
};
var chart = new google.visualization.ColumnChart(document.getElementById("columnchart_values"));
chart.draw(view, options);
}
</script>
<div id="columnchart_values" style="width: 900px; height: 300px;"></div>