Skip to content

Instantly share code, notes, and snippets.

@abdulazizahwan
Created November 30, 2019 17:25
Show Gist options
  • Save abdulazizahwan/fe6033949727322f02d9fc21f167fc78 to your computer and use it in GitHub Desktop.
Save abdulazizahwan/fe6033949727322f02d9fc21f167fc78 to your computer and use it in GitHub Desktop.
Main.dart file of Flutter Tutorial - 17 Image Widget | Importing Image from an Assets
import 'package:flutter/material.dart';
var assetImage =AssetImage('assets/dribbble_16.png');
var image = Image(
image: assetImage, fit: BoxFit.cover,
);
void main(){
runApp(MaterialApp(
debugShowCheckedModeBanner: false,
title: "My First Page",
home: FirstPage(),
));
}
class FirstPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Home'),
backgroundColor: Colors.black,
leading: IconButton(icon: Icon(Icons.menu),
onPressed: (){
print("Leading Clicked");
},),
actions: <Widget>[
IconButton(icon: Icon(Icons.notifications_none),
onPressed: (){
print("Notification Clicked");
},),
IconButton(icon: Icon(Icons.search),
onPressed: (){
print("Search Clicked");
},),
],
elevation: 6,
titleSpacing: 12,
),
floatingActionButton: FloatingActionButton(
child: Icon(Icons.add),
onPressed: (){
print("FAB Clicked");
},
shape: RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(16))),
elevation: 5,
highlightElevation: 10,
),
body: Center(child: Container(height: 300,
width: 300,
alignment: Alignment(0.9, -0.98),
decoration: BoxDecoration(borderRadius: BorderRadius.circular(20),image: DecorationImage(
image: AssetImage('assets/dribbble_16.png')))))
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment