Why tranform didn't work properly in release mode

Hi there, the app worked in debug mode, but failed to show the body in release mode after being installed in my mobile phone. Help needed. Thanks.

import 'dart:math' as math;
import 'package:flutter/material.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: 'Earth',
      theme: ThemeData(
          primarySwatch: Colors.blue, scaffoldBackgroundColor: Colors.white),
      home: MyHomePage(title: 'Earth'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);
  final String title;
  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage>
    with SingleTickerProviderStateMixin {
  AnimationController _controller;
  @override
  void initState() {
// Create animation controller.
    _controller =
        AnimationController(duration: const Duration(seconds: 10), vsync: this)
          ..addListener(() {
            setState(() {
// Force build.
            });
          })
          ..addStatusListener((AnimationStatus status) {
            if (status == AnimationStatus.dismissed) {
              _controller.forward();
            } else if (status == AnimationStatus.completed) {
              _controller.reverse();
            }
          });
// Start animation automatically.
    _controller.forward(from: 0.0);
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
          child: Transform.scale(
              scale: 1.6,
              child: Transform.rotate(
                  angle: math.pi * _controller.value, // rotate animation
                  child: Image.network(
                      "https://ak7.picdn.net/shutterstock/videos/3010597/thumb/1.jpg")))),
    );
  }
}

Hi, which device are you using to test?

iOS requires you to create a release build first before creating the archive.

You can use this command to create the release build flutter build ios

Hi, I used Android. I used this command: flutter build apk --split-per-abi
And copied one of the output apk files to the mobile phone to install.

Okay. Is the App crashing upon opening or is it showing an empty Scaffold?

No crashing. You can only see the appbar, the body is blank.

1 Like

Oh I think I understand what went wrong. Have you forgotten to give internet premission in the manifest file? Very common miss :sweat_smile: . I have faced this before too.

Please add this line in your manifest file after your application tag gets over.

<uses-permission android:name="android.permission.INTERNET"/>

Problem solved. Thank you very much.

2 Likes