Circles or circular pictures look cool. In fact, like we are accustomed to seeing them almost everywhere, and as I could not find an example to do so, I felt that I could make a really good one.
In this example, I'll just show a basic screen that has a circle and a text at the bottom, and the image is loading from the url, if you're trying to load a property image, just replace NetworkImage with AssetImage, Will talk more.
The code will look something like this.
In main.dart file you just write this code...
import 'package:flutter/material.dart';
import 'circle_image_task-4.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
debugShowCheckedModeBanner: false,
theme: ThemeData(
// This is the theme of your application.
//
// Try running your application with "flutter run". You'll see the
// application has a blue toolbar. Then, without quitting the app, try
// changing the primarySwatch below to Colors.green and then invoke
// "hot reload" (press "r" in the console where you ran "flutter run",
// or simply save your changes to "hot reload" in a Flutter IDE).
// Notice that the counter didn't reset back to zero; the application
// is not restarted.
primarySwatch: Colors.blue,
),
//home: MyHomePage(title: 'Flutter Demo Home Page'),
home: CircleImage(),
);
}
}
Create another dart file name is circleimage.dart and this code.
import 'package:flutter/material.dart';
class CircleImage extends StatelessWidget {
@override
Widget build(BuildContext context) {
Size size = MediaQuery.of(context).size;
return Scaffold(
appBar: AppBar(
centerTitle: true,
title: Text('Circle Image Example'),
),
body: Center(
child: CircleAvatar(
backgroundImage: ExactAssetImage('assets/images/umbrella.jpg'),
minRadius: 90,
maxRadius: 150,
),
),
);
}
}
output of this code
You just download this code from Github
Happy Coding enjoy Flutter with code with android JJ
0 Comments