Hello guys im new in flutter and i need help with my app, to put a button under an image in my app main menu,
here is my code so far i build based on https://docs.flutter.dev/development/ui/layout/tutorial
import 'package:flutter/material.dart';
import 'package:get/get_core/src/get_main.dart';
import 'package:get/get_navigation/get_navigation.dart';
import 'Reminder/ui/home_reminder.dart';
import 'Reminder/ui/widgets/button.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: Stack(
children: [
Image.asset(
'images/MenuImg.jpg',
width: 600,
height: 200,
fit: BoxFit.cover,
),
],
),
),
);
}
}
what i wanna do is put a button to navigate to a different page.
Here is a little illustration where i want to put my button
4
Answers
you can wrap the image widget with a
Column
, to set widgets ordered vertically, I did it for the Row to show the button with aMainAxisAlignment.spaceBetween
to space themGive it a try this:
You need to use the widget
Column
in the body argument of yourScaffold
widget to have the possibility to add multiple widgets in a column view on your screen.You can find a fully working example at this zaap.run link.
You can also find the code without any preview here:
Just change the
Stack
with Column or ListiwTry the following code: