Hello guys im new in flutter, and wanted to have a homepage with and image as a boxfit.cover and a box decoration right in front of it for my buttons. here is my design for the homepage
HomePage Design
as you guys can see i wanted a square that piled up with an image, so far my homepage only have buttons under an image
here is the code for my homepage so far
import 'package:flutter/material.dart';
import 'package:get/get_navigation/get_navigation.dart';
import 'package:medreminder/NewsArticle/news_home.dart';
import 'package:medreminder/Reminder/ui/theme.dart';
import 'Reminder/home_reminder.dart';
import 'Reminder/ui/widgets/button.dart';
import 'package:medreminder/main.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(
backgroundColor: Color(0XFF0080FE),
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: [
Column(
children: [
IconButton(
icon: Image.asset('images/reminder.png'),
iconSize: 50,
onPressed: () {
Navigator.of(context, rootNavigator: true).push(
MaterialPageRoute(builder: (context) => const ReminderHomePage()),
);
},
),
Text("Reminder")
],
),
Column(
children: [
IconButton(
icon: Image.asset('images/news.png'),
iconSize: 50,
onPressed: () {},
),
Text(" News n& Article")
],
),
Column(
children: [
IconButton(
icon: Image.asset('images/recipe.png'),
iconSize: 50,
onPressed: () {},
),
Text("Healty Food n Recipe")
],
),
],
),
],
),
),
);
}
}
any answers would helped me alot, thankyou guys
2
Answers
You should use the Stack widget if you want to overlap any widget with another. To position the widget, we use the Align and Padding widget. If you want more information about the Stack widget, visit the official flutter site : – https://api.flutter.dev/flutter/widgets/Stack-class.html.
Run the following code to get a better understanding. I have used my local images hence they would give you an error on your system. Replace my image assets with yours.
Full Code : –
Output : –
To overlap any widget on one-another one should use a stack widget.
Nice article on Stack and IndexedStack in Flutter
https://medium.com/flutter-community/a-deep-dive-into-stack-in-flutter-3264619b3a77