#override
Widget build(BuildContext context) {
return Scaffold(
body: ListView(
children: [
HomeHeaderWidget(), // Home Widgets ada di HomeWidget.dart
Container(
height: 150,
width: 240,
alignment: Alignment.center,
margin: EdgeInsets.only(top: 15, bottom: 15),
child: Image?.network(
"http://localhost/php_ecommerce/assets/Produk/alpukat.jpg",
fit: BoxFit.cover,
scale: 1,
),
),
],
),
);
}
I try to load image from Localhost which runs from XAMPP, but i can't load the image file to flutter web project. I use flutter web to make it work, so the image can show up to web interface.
Image runs in Localhost url
Flutter loads the image
Please help me to give solutions for loading the image in flutter web project. The image comes from Localhost which works in XAMPP
Related
I want to disable WebViewX Scroll Effect. Unable to scroll when the cursor is on Webview Area. I want the whole page to scroll on the web. Any other package which can disable the scroll effect is also appreciated. Wanted this HTML in Android, iOS, and WEB
Check Video
Build Method
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: SingleChildScrollView(
child: Column(
children: [
const SizedBox(height: 50),
_buildWebView(),
const SizedBox(
height: 500,
)
],
),
),
);
}
WebView Used
return WebViewX(
initialContent: html,
initialSourceType: SourceType.html,
height: 500,
width: MediaQuery.of(context).size.width,
);
},
After downloading the app through the apk release, in the first time, it works normally. But once you close the app and open it again, the ui elements disappears. It has a very strange behavior, if I restart the device, it works in the first time the app is open (after the restart), and after closing it, it doens't work again.
This only happens in the release version, debugging works as expected.
I am using Getx, I don't see a relation since I have already develop other apps with this structure. This is the code of the first page loaded.
return Container(
constraints: BoxConstraints(minWidth: Get.width, minHeight: Get.height),
decoration: BoxDecoration(
color: Theme.of(context).primaryColor,
image: DecorationImage(
opacity: 0.35,
repeat: ImageRepeat.repeat,
image: AssetImage(AppConstants.assets.background_image),
),
),
child: Scaffold(
backgroundColor: Colors.transparent,
body: Container(
child: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
SizedBox(
width: Get.width,
height: Get.height * 0.45,
child: Center(
child: Padding(
padding: const EdgeInsets.only(top: 80.0),
child: SizedBox(
width: Get.width * 0.8,
height: Get.height * 0.3,
child: Image.asset(AppConstants.assets.logo_image),
),
),
),
),
SizedBox(
height: Get.height * 0.55,
child: TabBarView(
controller: controller.tabController,
physics: NeverScrollableScrollPhysics(),
children: [
TelephoneTab(),
CodeTab(),
],
),
),
],
),
),
),
),
);
I have tried removing the background image by removing the Container before the Scaffold entirely, removing every element in the UI and adding just a small button in the middle. Updating my kotlin.
Tried running with flutter run --release. No logs.
May be the same thing as this.
Flutter doctor is fine.
The problem seems to be something related to the Scaffold and the Container with the background image. Elements outside the Scaffold were drawn as usual.
I changed the first page of the app in order to go directly to the HomePage and it worked fine, even logging out to the LoginPage.
Then I tried creating a SplashPage before the LoginPage, initially, I used the same structure with the Container, BoxDecoration, and Scaffold. The problem was happening again, but this time in the SplashPage, everything inside the Scaffold was invisible with the same behavior as mentioned above.
After that, I simply define the extendBody as true in the Scaffold of the SplashPage and the problem stopped occurring.
I don't exactly understand what this changes. Feel free to add an explanation to this answer.
I'm having difficulties to make the widgets fits bigger screen when I run it in Emulator and physical device. But it fits perfectly and look good in smaller screen both when i run it in emulator and physical device
This is the first time im trying flutter, and i have made the UI from figma then later converted the design to flutter. it worked well but only on small screen, the moment I tried on bigger screen and emulator the texts and all the components stayed the same instead of following the size of the screen
and this is the coding, (this is automatically from flutlab when i want to convert from figma to flutter). im looking for any help either from this code below or even thru figma on how to make the design responsive and it fits into the screen automatically on any devices. thank you so much for all your help
class GeneratedAndroidLarge35Widget extends StatelessWidget {
#override
Widget build(BuildContext context) {
return Material(
child: ClipRRect(
borderRadius: BorderRadius.zero,
child: Container(
width: 360.0,
height: 800.0,
child: Stack(
clipBehavior: Clip.none,
fit: StackFit.expand,
alignment: Alignment.center,
children: [
ClipRRect(
borderRadius: BorderRadius.zero,
child: Container(
color: Color.fromARGB(255, 238, 240, 244),
),
),
Positioned(
left: null,
top: null,
right: null,
bottom: null,
width: 327.0,
height: 662.0,
child: TransformHelper.translate(
x: -0.50, y: 4.00, z: 0, child: GeneratedFrame112Widget()),
)
]),
),
));
}
}
In debugging, it doesn't show any error, but the container didn't come out colored just for the Web, as shown in the following image:
Container coloring bug
There doesn't seem to be anything wrong with the code, can anyone tell me what it could be?
import 'package:flutter/material.dart';
import 'package:jumil_connect_front/utilities/constants/app_constants.dart';
import '../../widgets/dashboard/header.dart';
import '../../widgets/dashboard/top_menu.dart';
class FilesScreen extends StatefulWidget {
static const String route = '/files';
const FilesScreen({super.key});
#override
State<FilesScreen> createState() => _FilesScreenState();
}
class _FilesScreenState extends State<FilesScreen> {
#override
Widget build(BuildContext context) {
Size size = MediaQuery.of(context).size;
return Scaffold(
body: SafeArea(
child: Column(
children: [
// const Header(),
// const SizedBox(
// height: 5,
// width: double.infinity,
// child: Image(
// image: AssetImage('assets/images/color_line.png'),
// fit: BoxFit.fill,
// ),
// ),
// const TopMenu(),
Row(
children: [
Container(
width: 330,
height: size.height,
color: Colors.red
)
],
)
],
),
),
);
}
}
This happened to me being hot restart. When ever I faced this issue, I follow,
rebuild the app again or
flutter clean and rebuild the app again
I used HTML rendering and the bug came up, apparently it's some canvaskit bug. I don't know if the ideal solution is to change the rendering only, but that's what solved it for me.
Using this command:
flutter run -d chrome --web-renderer html
it might be stupid question but I am completely new in flutter, I am playing with desktop app for macOS using Flutter.
I don’t want to follow any design rules and I’m just playing with basic layout.
My question: Is it necessary to start each App with one of the predefined root widget?
MaterialApp()
WidgetApp()
CupertinoApp()
Can our App just start with Container() as my code below?
void main() {
runApp(
new Directionality(textDirection: TextDirection.ltr, child: MyApp())
);
}
// Root of App
class MyApp extends StatelessWidget {
// This widget is the root of your application.
#override
Widget build(BuildContext context) {
var mainGrey = parseColor('#282828');
var dddColor = parseColor('#3e3e3e');
var rootWidget = Container(
decoration: BoxDecoration(gradient:
LinearGradient(begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [mainGrey, dddColor], stops: [0.5, 1.0] )
),
//color: parseColor('#282828'),
//color:Color.fromRGBO(50, 50, 50, 0.5),
child: Column(
children: [
Expanded(child:
Container(child:
Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Flexible(
flex:1,
child: Container(
padding: const EdgeInsets.all(7),
decoration: BoxDecoration( border: Border.all(width: 1.0, color: Colors.blue[100])),
width: 200,
child: _myListMenu(context)
),
),
Expanded(
flex:3,
child: Center(child: MainView() )
),],),
)),
Container(//Bottom bar
height:30,
color:Colors.blue,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children:[Text('App Footer', textAlign: TextAlign.end,), ])
,)
]
),
);
return rootWidget;
}
}
Is it completely bad design? Or can we use flutter like this? Of course I met a few problems. Text directionality was missing and I can't access MediaQuery.
from didierboelens blog
When we are writing an Flutter application, using Dart, we remain at the level of the Flutter Framework (in green).
The Flutter Framework interacts with the Flutter Engine (in blue), via an abstraction layer, called Window. This abstraction layer exposes a series of APIs to communicate, indirectly, with the device.
This is also via this abstraction layer that the Flutter Engine notifies the Flutter Framework when, among others:
an event of interest happens at the device level (orientation change, settings changes, memory issue, application running state…)
some event happens at the glass level (= gesture)
the platform channel sends some data
but also and mainly, when the Flutter Engine is ready to render a new frame