Since you didn't include the final result of your expected output, i have add few version of circle that might suit your needs. Few this to take note here:
a) when giving height: size.height
the container widget will take the space of the whole screen. The reason you see that the circle did not fit to the height because it is bounded by the width. This can be overcome with the code from example 2
b) height: size,height/2
means that the container will take half the size of the screen.
- Big red circle in the centre of the screen
import 'package:flutter/material.dart';
void main () {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({ Key? key }) : super(key: key);
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: NewScreen(),
debugShowCheckedModeBanner: false,
);
}
}
class NewScreen extends StatelessWidget {
const NewScreen({ Key? key }) : super(key: key);
@override
Widget build(BuildContext context) {
var size = MediaQuery.of(context).size;
return Scaffold(
body: Container(
height: size.height,
width: size.width,
decoration: BoxDecoration(
color: Colors.red,
shape: BoxShape.circle,
),
),
);
}
}
- Circle with hidden side
import 'package:flutter/material.dart';
void main () {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({ Key? key }) : super(key: key);
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: NewScreen(),
debugShowCheckedModeBanner: false,
);
}
}
class NewScreen extends StatelessWidget {
const NewScreen({ Key? key }) : super(key: key);
@override
Widget build(BuildContext context) {
var size = MediaQuery.of(context).size;
return Scaffold(
body: Stack(
children: [
Positioned(
left: -100,
right: -100,
child: Container(
height: size.height,
width: size.width,
decoration: BoxDecoration(
color: Colors.red,
shape: BoxShape.circle,
),
),
),
],
),
);
}
}
- Circle at the top of the screen
import 'package:flutter/material.dart';
void main () {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({ Key? key }) : super(key: key);
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: NewScreen(),
debugShowCheckedModeBanner: false,
);
}
}
class NewScreen extends StatelessWidget {
const NewScreen({ Key? key }) : super(key: key);
@override
Widget build(BuildContext context) {
var size = MediaQuery.of(context).size;
return Scaffold(
body: Column(
children: [
Container(
height: size.height/2,
width: size.width,
decoration: BoxDecoration(
color: Colors.red,
shape: BoxShape.circle,
),
),
],
),
);
}
}