Last active
October 30, 2021 11:58
-
-
Save nehal076/2d585c8fefcf1503d9a28d0b1b9e1ba2 to your computer and use it in GitHub Desktop.
Profile Image Padding
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
const Color darkBlue = Color.fromARGB(255, 18, 32, 47); | |
void main() { | |
runApp(MyApp()); | |
} | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
theme: ThemeData.dark().copyWith( | |
scaffoldBackgroundColor: darkBlue, | |
), | |
debugShowCheckedModeBanner: false, | |
home: Scaffold( | |
body: Center( | |
child: MyWidget(), | |
), | |
), | |
); | |
} | |
} | |
class MyWidget extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return Stack( | |
children: [ | |
Image.network( | |
'https://i.pinimg.com/564x/59/11/cd/5911cda1f1ae980b26ca367af3197dfd.jpg', | |
fit: BoxFit.fill, | |
height: double.infinity, | |
width: double.infinity, | |
), | |
Scaffold( | |
backgroundColor: Colors.transparent, | |
appBar: AppBar( | |
backgroundColor: Colors.transparent, | |
shadowColor: Colors.transparent, | |
), | |
body: | |
Container( | |
decoration: const BoxDecoration( | |
borderRadius: BorderRadius.vertical(top: Radius.circular(18)), | |
color: Colors.white, | |
), | |
child: Column( | |
children: const [ | |
ProfileView(), | |
Expanded( | |
child: SingleChildScrollView( | |
child: ProfileDetailView(), | |
), | |
), | |
], | |
), | |
), | |
), | |
], | |
); | |
} | |
} | |
class ProfileView extends StatelessWidget { | |
const ProfileView({ | |
Key? key, | |
}) : super(key: key); | |
@override | |
Widget build(BuildContext context) { | |
return Container( | |
padding: const EdgeInsets.all(16), | |
child: Stack( | |
children: [ | |
Row( | |
children: const [ | |
Icon( | |
Icons.check_circle, | |
color: Colors.green, | |
), | |
Text( | |
'KYC Approved', | |
style: TextStyle( | |
color: Colors.green, | |
), | |
), | |
], | |
), | |
const ProfileImage(), | |
], | |
), | |
); | |
} | |
} | |
class ProfileImage extends StatelessWidget { | |
const ProfileImage({Key? key}) : super(key: key); | |
@override | |
Widget build(BuildContext context) { | |
return Center( | |
child: Stack( | |
children: [ | |
MediaQuery.removePadding( | |
context: context, | |
removeTop: true, | |
child: Container( | |
transform: Matrix4.translationValues(0, -70, 0), | |
decoration: BoxDecoration( | |
shape: BoxShape.circle, | |
border: Border.all( | |
color: Colors.white, | |
width: 3.0, | |
), | |
), | |
child: const CircleAvatar( | |
backgroundImage: NetworkImage( | |
'https://pixinvent.com/demo/vuexy-bootstrap-laravel-admin-template/demo-1/images/portrait/small/avatar-s-7.jpg', | |
), | |
radius: 55.0, | |
), | |
), | |
), | |
Positioned( | |
right: 7, | |
top: 6, | |
child: Container( | |
padding: const EdgeInsets.all(4), | |
decoration: const BoxDecoration( | |
color: Colors.black, | |
shape: BoxShape.circle, | |
), | |
child: const Icon( | |
Icons.camera_alt_outlined, | |
color: Colors.white, | |
size: 18, | |
), | |
), | |
), | |
], | |
), | |
); | |
} | |
} | |
class ProfileDetailView extends StatelessWidget { | |
const ProfileDetailView({ | |
Key? key, | |
}) : super(key: key); | |
@override | |
Widget build(BuildContext context) { | |
return Container( | |
padding: const EdgeInsets.all(16), | |
child: Column( | |
children: const [ | |
Text( | |
'Ankit Lastname', | |
style: TextStyle( | |
color: Colors.blue, | |
fontSize: 22, | |
fontFamily: 'OpenSans', | |
fontWeight: FontWeight.w700, | |
), | |
) | |
], | |
), | |
); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment