-
Notifications
You must be signed in to change notification settings - Fork 345
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
device_preview is not working, a blank page is displayed. #231
Comments
Here,you can try these few adjustments in your code. |
Hi,
No these changes do not help:
[image: afbeelding.png]
This is the code:
import 'package:device_preview/device_preview.dart';
import 'package:flutter/material.dart';
void main() {
DevicePreview(
enabled: true, //kReleaseMode,
builder: (context) => const MyApp(), // Wrap your app
);
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@OverRide
Widget build(BuildContext context) {
return MaterialApp(
locale: DevicePreview.locale(context),
builder: DevicePreview.appBuilder,
home: const Material(
child: Center(child: Text('demo')),
));
}
}
…On Thu, Aug 10, 2023 at 7:32 PM Udit Soni ***@***.***> wrote:
Here,you can try these few adjustements in your code.
1)Ensure that the text widget is wrapped in a Center widget so that the
"demo" text is centered on the screen.
2)Use the Key parameter for the MyApp constructor instead of super.key.
Like( const MyApp({Key? key}) : super(key: key); // Use Key instead of
super.key)
3)Or you can try Importing kReleaseMode from flutter/foundation.dart to
properly handle enabling DevicePreview only during development.
—
Reply to this email directly, view it on GitHub
<#231 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAMWA2JE2GWBGJYLRY5YSPLXUULMJANCNFSM6AAAAAA3JXXWJU>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
--
met vriendelijke groeten
Robin Bakkerus
***@***.***
|
Hi,
My bad !
Your package is working, once you startup Flutter correctly.
This was the issue:
void main() {
DevicePreview(
instead of:
void main() {
runApp(DevicePreview(
(runApp was missing!)
gr Robin
On Mon, Aug 14, 2023 at 12:33 PM Robin Bakkerus ***@***.***>
wrote:
… Hi,
No these changes do not help:
[image: afbeelding.png]
This is the code:
import 'package:device_preview/device_preview.dart';
import 'package:flutter/material.dart';
void main() {
DevicePreview(
enabled: true, //kReleaseMode,
builder: (context) => const MyApp(), // Wrap your app
);
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@OverRide
Widget build(BuildContext context) {
return MaterialApp(
locale: DevicePreview.locale(context),
builder: DevicePreview.appBuilder,
home: const Material(
child: Center(child: Text('demo')),
));
}
}
On Thu, Aug 10, 2023 at 7:32 PM Udit Soni ***@***.***>
wrote:
> Here,you can try these few adjustements in your code.
> 1)Ensure that the text widget is wrapped in a Center widget so that the
> "demo" text is centered on the screen.
> 2)Use the Key parameter for the MyApp constructor instead of super.key.
> Like( const MyApp({Key? key}) : super(key: key); // Use Key instead of
> super.key)
> 3)Or you can try Importing kReleaseMode from flutter/foundation.dart to
> properly handle enabling DevicePreview only during development.
>
> —
> Reply to this email directly, view it on GitHub
> <#231 (comment)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AAMWA2JE2GWBGJYLRY5YSPLXUULMJANCNFSM6AAAAAA3JXXWJU>
> .
> You are receiving this because you authored the thread.Message ID:
> ***@***.***>
>
--
met vriendelijke groeten
Robin Bakkerus
***@***.***
--
met vriendelijke groeten
Robin Bakkerus
***@***.***
|
@robinbakkerus im glad that you able to figure it out, keep growing and enjoy your ride with flutter ;) |
This very basic implementation only displays a blank page.
flutter doctor =>
flutter --version =>
And I tested this app with the following commands:
The text was updated successfully, but these errors were encountered: