Flutter How to add multiple pages on one page - flutter

Hello and thank you in advance..
I am new to flutter and i want to make screen which i shown u...! Just look at the picture..i marked red color in that pic i have circle avater and when i tap on each i need to show there data on same page...no need to navigate to another screen...! Show that data on same page...! Plz help me provide me if there code u have

Something like this will work, you're basically creating your widget tree in a declarative way in flutter, the column will allow you to stack two separate widgets (your list and your grid). I recommend going through a few tutorials (starting here: https://flutter.dev/docs/get-started/codelab)on building an app, flutter comes really easy, then watch all the videos created by the flutter team on the different widgets. Everything is a widget and you will use each kind of widget to build your ui.
#override
Widget build(BuildContext context) {
return Stack(children: [
Positioned(
top: 20,
child: Column(
children: [
ListView(
children: [/*circle images*/],
),
GridView.count(
crossAxisCount: 10,
children: [/*profile images*/],
)
],
))
]);
}

Related

Reducing Jank in Flutter progressive web app

Woah! I've spent several hours refactoring nested ListViews to a parent CustomScrollView & child Slivers. The errors Slivers produced were opaque and frightening, with nothing illuminating in Logcat; sleuthing devoured much of the time.
Anyway, that's solved. I find I still have jank scrolling a 15-item list. OK, each item can involve further numerous widgets {Padding, Alignment, Elevated button, Row, Text, SizedBox, Icon}. So my 15-item list ends up being multiple more Widgets.
I've now swapped out my SliverChildListDelegate for SliverChildBuilderDelegates, so a Builder builds the Widget List lazily. Having done this, it seems quite inefficient because it's increased the Widgets in the Widget tree. Each of the builders' buildItem() calls needs an extra Column Widget to wrap that sub-chunk of the total list.
It may be a lot of Widgets scrolling but it's only a 15 item list. I wish I knew what to optimise. Any thoughts on how to best reduce jank on Lists for mobile web?
The Flutter team says Flutter works best for computational-centred apps rather than text heavy informational apps. In future would it be better just to use webView Widgets? I always thought embedding Webviews would be clunky and slow but Lists of native Flutter Widgets, even as SliverLists, give jank.
Here is the janky list complete with builder:
Widget buildLocationDescriptionWidgets(LocationDetails presentLocation) {
print(LOG + "buildLocationDescriptionWidgets");
if (presentLocation.descriptionLinkUrls.isEmpty)
return SliverToBoxAdapter(child:
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 16),
child: Text(presentLocation.description[0])));
int numDescriptionBlocks = presentLocation.description.length;
double paddingBottom = 16;
if (presentLocation.descriptionLinkUrls.length >= numDescriptionBlocks) {
paddingBottom = 0;
}
return SliverPadding(
padding: EdgeInsets.fromLTRB(16, 16, 16, paddingBottom), sliver:
SliverList(
key: Key("descriptionSliverList"),
delegate: SliverChildBuilderDelegate((context, index) =>
buildDescriptionBlock(context, index),
childCount: presentLocation.description.length
),
));
}
Column buildDescriptionBlock(BuildContext context, int index) {
List<Widget> colChildWidget = [];
colChildWidget.add(Text(
widget.presentLocation.description[index],
textAlign: TextAlign.left,
));
if (index < widget.presentLocation.descriptionLinkUrls.length) {
colChildWidget.add(Padding(
padding: const EdgeInsets.symmetric(vertical: 16),
child: Align(
alignment: Alignment.center,
child: index >=
widget.presentLocation.descriptionButtonIcons.length
? ElevatedButton(
child: Text(
widget.presentLocation.descriptionButtonText[index]),
onPressed: () {
_launchURL(
widget.presentLocation.descriptionLinkUrls[index]);
})
: ElevatedButton(
child:
Row(mainAxisSize: MainAxisSize.min, children: [
Text(
widget.presentLocation.descriptionButtonText[index]),
SizedBox(width: 8),
FaIcon(
buttonIconMap[widget.presentLocation
.descriptionButtonIcons[index]],
size: 16)
]),
onPressed: () {
_launchURL(
widget.presentLocation.descriptionLinkUrls[index]);
}))));
}
return Column(crossAxisAlignment: CrossAxisAlignment.start, children: colChildWidget);
}
Should I regress from a builder to a conventional SliverList?
Other things I've tried: I eliminated jank in my app Drawer list by putting const everywhere possible, lots of Dividers were made Const. But when you style text using Theme.of(context).textTheme.bodyText2 etc. it doesn't allow you to set textboxes to const. If you want to use const you can't style the app globally, you'd have to hard code. Is it worth forsaking abstraction for hard coding Text widget styles?
Here is the web app: Love Edinburgh
For the clearest example of jank
Open the App Drawer
Scroll to WONDER
Tap Arthur's Seat
Open the panel to full screen - slide it up
Scroll down the panel.
It doesn't show on a desktop browser which is compiled using Skia / Webkit. It's a bit fiddly to get scroll working on a desktop browser, you need to click amongst the text, then attempt to scroll. It's meant for mobile use so I'm resigned to that.
Not sure how to help you out. Would rather put this on a comment rather than answer but I don't have the points to do a comment.
Anyway, I wish I could replicate your problem. On my personal experience, for a 15 item list with numerous child widgets, it shouldn't be janky unless it has probably big sized images or really too much extra widgets.
On my case, I made sure to "isolate" / "compute" my heavy computations and showed a loading screen while preparing the list.
You may read on:
Isolates : https://dart.dev/guides/language/concurrency
Compute:
https://api.flutter.dev/flutter/foundation/compute-constant.html
Hope that helped!

How to create a widget that stays alive on all screens? Like spotify's miniplayer

I'm currently building a podcast app and what I want to implement is something similar to miniplayer in Spotify.
When user taps on a podcast and start listening, I want to open a miniplayer and make it alive across on all pages.
First thing come up to my mind is using Overlay widget or using a custom navigator for all of the pages and put that navigator inside a stack. I wonder if anyone implement something like this before or what's the best way to approach this.
Try this package with less effort, miniplayer
Stack(
children: <Widget>[
YourApp(),
Miniplayer(
minHeight: 70,
maxHeight: 370,
builder: (height, percentage) {
return Center(
child: Text('$height, $percentage'),
);
},
),
],
),
I would recommend using this with a Stack. Maybe something like this:
class PodcastApp extends StatelessWidget {
#override
Widget build(BuildContext context) {
return Container(
child: Column(
children: [
Expanded(
child: Stack(
children: [
SizedBox.expand(child: PageView()),
Align(
alignment: Alignment.bottomCenter,
child: YOUR_MINI_PLAYER(),
)
],
),
),
BottomNavigationBar(),
],
),
);
}
}
I did the same thing but not for an audio player, where was that
First, build a BasePage that contains all of these tabs
Secondly, use GetIt to transfer the object from one page to another. The goal is to find out if the user played an audio clip or not.
Third You can store in GetIt the audio track, name, picture, ..etc.
In BasePage, you check if this object has been modified or if it is empty. The goal of viewing in BasePage is for it to be visible in all sections of the tab.
Do not hesitate to ask me if something is not clear.
Check out this persistent_bottom_nav_bar package
Features of this package
Highly customizable persistent bottom navigation bar.
Ability to push new screens with or without the bottom navigation bar.
20 styles for the bottom navigation bar.
Includes functions for pushing screen with or without the bottom
navigation bar i.e. pushNewScreen() and pushNewScreenWithRouteSettings().
Based on flutter's Cupertino(iOS) bottom navigation bar.
Can be translucent for a particular tab.
Custom styling for the navigation bar. Click here for more
information.
Handles hardware/software Android back button.
I hope this is what you are looking for.

Scrolling Widget inside a Constant size Container flutter web

Hi all fellow developers,
I am developing a responsive web page in flutter using the flutter web SDK, but i am stuck at one part of the page where i have a Row inside row I have 2 Containers among which i want the 1st Container to be Scrollable and the Second container to be of constant size(Non scrollable) just like whatsapp web ui where contact list keeps scrolling but the chat side and the rest of the page doesn't.
please Help me,
Thanks in advance...
This should work You need a fixed sized container and make sure a Scroll able widget should be inside it. Now size can be made responsive by using Media Query Parameters and below code you only need to adjust space and sizing and it would work.
Row(
//Your parent Row
children: [
Container(
//static non scrollable container
child: Column(
children: [
//Children you want to add
//this wont be scrollable
//It is also preferred that you give this some height or width too
],
),
),
Container(
//Scrollable container
//Please adjust height and width yourself
//You can use media query parameters to make it responsive
width: 200,
height: 500,
child: SingleChildScrollView(
//You can also change the scroll direction
child: Column(
//Add children you want to be in
//Scrollable column
),
),
)
],
),

Creating an overflow which minimised when there isn't enough room in Flutter

I have been trying to figure out the least impactful way of creating an overflow when there isn't enough room to show otherwise, 3 button icons. Ideally, I could find out a way to know the space between the two widgets on the row and once it is X distance away, it turns into the minimised version.
I have tried 'off methods' like counting how many characters each item in the array has and making a number, but as it expands, it'll turn into the tablet and then desktop layout, therefore will not be dependable to rely on it or MediaQuery.of(context).size.
Hopefully what I am saying makes sense.
Picture to show what I mean:
minimise: true
minimise: false
Thanks for any advice you can give.
class ListCardChipsWithActionBar extends StatelessWidget {
#override
Widget build(BuildContext context) {
//print('categoryList is ${categoriesList.length}');
return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: ListCardCategoryChips(
categories: categoriesList,
),
),
ListCardActionBar(
minimised: true,
),
],
);
}
}

I need to make this layout but I am confused as to what should I use how to place them like in the image I have posted below

Since i want this to be my layout i was trying to implement it with a showModalBottomSheet but the problem is that this widget only works on the button click as it is showing me error when i am trying to call the method as it is in the initState method. So then I started to work with bottomSheet value present in the scaffold but then the background is being displayed only upto the starting of the bottom sheet creating the distance between the model sheet and the background whereas I want it to overlap like in the image..How should I prepare this layout.
There is no such parameter as "bottomSheet" in Scaffold, there is one called bottomAppBar, which is used for making Bottom Bars like the one on the Youtube Android App. So this should help you make the basic structure.
Use a Stack widget to put widgets on top of each other, in first layer, add the image using the NetworkImage widget, then in the second layer, make a Column, like this:
#override
Widget build() => Scaffold(
body: _body(),
);
_body() => Stack(
children: <Widget>[
NetworkImage(your_url_here),
Column(
children: <Widget>[
_basicDetails(),
_guidePanel(),
]
),
]);
Then create 2 new methods after the _body method like this:
_body() => Stack(...);
_basicDetailsPage() => Container();
_guidePanel() => Container();
Create your layout in these 2 methods. Comment if you need more help :)
For additional help, please join the Facebook Group "Let's Flutter With Dart"