Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

autoscale_tabbarview not working properly on release.apk #10

Open
Ultranmus opened this issue Oct 5, 2023 · 1 comment
Open

autoscale_tabbarview not working properly on release.apk #10

Ultranmus opened this issue Oct 5, 2023 · 1 comment

Comments

@Ultranmus
Copy link

The package works as expected on the emulator and in debug mode. However, in release mode (release.apk), it exhibits unexpected behavior.

Debug mode

Release mode

@Ultranmus
Copy link
Author

I tried to find where the problem arise from and i think having a gridview in AutoScaleTabBarView causes the problem. First it was not able to render correct height for the tabview but if we switch to another tab the height of AutoScaleTabBarView renderd is correct. And all this problem in release.apk not in debud mode ,for debug mode it work perfectly fine.

Below is the code which depicts this problem, just add autoscale_tabbarview package in pubsec.yml file and try this code and if there is any solution to resolve, please tell.

import 'package:autoscale_tabbarview/autoscale_tabbarview.dart';
import 'package:flutter/material.dart';

void main() {
runApp(const MyApp());
}

const List<Map<String, String>> imageData = [
{
'name': 'Snowy',
'url':
'https://images.pexels.com/photos/2173872/pexels-photo-2173872.jpeg?auto=compress&cs=tinysrgb&w=600'
},
{
'name': 'Sandy',
'url':
'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcT-S6gVU03fekBnlVWXvncCj6r1kGBqbHyA8Q&usqp=CAU',
},
];

class MyApp extends StatelessWidget {
const MyApp({super.key});

// This widget is the root of your application.
@OverRide
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home:const CustomTabView(),
);
}
}
class CustomTabView extends StatefulWidget {
const CustomTabView({Key? key}) : super(key: key);

@OverRide
State createState() => _CustomTabViewState();
}

class _CustomTabViewState extends State with TickerProviderStateMixin{
@OverRide
Widget build(BuildContext context) {
TabController controller=TabController(length: 3, vsync: this);
final Size size=MediaQuery.sizeOf(context);
return Scaffold(
backgroundColor: Colors.black,
body: SafeArea(
child: Column(
children: [
CustomTabBar(controller: controller),
AutoScaleTabBarView(
controller: controller,
children: List.generate(
3,
(index) => CustomGridView(
data: imageData,
size: size,
),
),
),
],
),
),
);
}
}

class CustomTabBar extends StatelessWidget {
const CustomTabBar({
super.key,
required this.controller,
});

final TabController controller;

@OverRide
Widget build(BuildContext context) {
return TabBar(
padding: const EdgeInsets.symmetric(
horizontal: 20,
),
dividerHeight: 0,
labelColor: Colors.blue,
unselectedLabelColor: Colors.white60,
indicatorColor: Colors.blueAccent,
controller: controller,
tabs: const [
Tab(
child: Text(
' Posts ',
overflow: TextOverflow.ellipsis,
)),
Tab(
child: Text(
'Stamp Book',
overflow: TextOverflow.ellipsis,
)),
Tab(
child: Text(
'Community',
overflow: TextOverflow.ellipsis,
)),
],
);
}
}

class CustomGridView extends StatelessWidget {
final List data;
final Size size;
const CustomGridView({Key? key, required this.data, required this.size})
: super(key: key);

@OverRide
Widget build(BuildContext context) {
return GridView.builder(
physics: const NeverScrollableScrollPhysics(),
padding: const EdgeInsets.only(left: 20, right: 20, bottom: 20),
itemCount: data.length,
shrinkWrap: true,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
mainAxisSpacing: 7,
crossAxisSpacing: 7,
crossAxisCount: size.width > 1000
? 6
: size.width > 500
? 4
: 2,
),
itemBuilder: (context, index) {
return Image.network(
data[index]['url'].toString(),
fit: BoxFit.cover,
);
},
);
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant