mirror of
https://github.com/nisrulz/flutter-examples.git
synced 2025-07-11 07:07:16 +08:00
33 lines
836 B
Dart
33 lines
836 B
Dart
import 'package:flutter/material.dart';
|
|
|
|
void main() {
|
|
runApp(MaterialApp(
|
|
home: MyApp(),
|
|
));
|
|
}
|
|
|
|
class MyApp extends StatelessWidget {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
title: Text("Load local image"),
|
|
),
|
|
body: Container(
|
|
child: Center(
|
|
child: Text(
|
|
"Hello World!",
|
|
style: TextStyle(color: Colors.white),
|
|
),
|
|
),
|
|
// Set the image as the background of the Container
|
|
decoration: BoxDecoration(
|
|
image: DecorationImage(
|
|
// Load image from assets
|
|
image: AssetImage('data_repo/img/bg1.jpg'),
|
|
// Make the image cover the whole area
|
|
fit: BoxFit.cover)),
|
|
));
|
|
}
|
|
}
|