iam new to flutter and i would like to add a text under a button, but i cant seems to do it, so far here’s my result
..
i use two Rows for the button and the text,
as you guys can see the text isnt align really well, i tried using ElevatedButton but the text is beside the button not below it.
this is my code so far:
import 'package:flutter/material.dart';
import 'package:get/get_navigation/get_navigation.dart';
import 'package:medreminder/NewsArticle/news_home.dart';
import 'Reminder/ui/home_reminder.dart';
import 'Reminder/ui/widgets/button.dart';
import 'package:medreminder/main_reminder.dart';
import 'package:medreminder/home_page.dart';
void main() {
// debugPaintSizeEnabled = true;
runApp(const HomePage());
}
class HomePage extends StatelessWidget {
const HomePage({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
appBar: AppBar(
title: const Text('Medicine Reminder App'),
),
body: Column(
children: [
Stack(
children: [
Image.asset(
'images/MenuImg.jpg',
width: 600,
height: 170,
fit: BoxFit.cover,
),
],
),
const SizedBox(height: 10.0),
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
IconButton(
icon: Image.asset('images/reminder.png'),
iconSize: 50,
onPressed: () {
Navigator.of(context, rootNavigator: true).push(
MaterialPageRoute(builder: (context) => const ReminderHomePage()),
);
},
),
IconButton(
icon: Image.asset('images/news.png'),
iconSize: 50,
onPressed: () {},
),
IconButton(
icon: Image.asset('images/recipe.png'),
iconSize: 50,
onPressed: () {},
),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Text("Reminder"),
Text("News"),
Text("Recipe")
],
)
],
),
),
);
}
}
if anyone know how to do it, please help. it will mean so much to me. thank you
4
Answers
try to put each
iconButton
inside aColumn
with itsText
widget, try this code:You can adjust
Layout
by usingRow
andColumn
if u want to change the colour of the text button u can, its just commented out for you
Try below code hope its helpful to you, I have try it two ways Using Column Widget and Gridview.builder(). Just replace my images with your image
1. Using Column Widget
ImageRow Class:
2. Using Gridview.builder()
Declare List on your imageName and imageUrl
GridView Widget:
Result Screen->