Quantcast
Channel: Active questions tagged config - Stack Overflow
Viewing all articles
Browse latest Browse all 5049

Flutter application hangs when calling await rootBundle.loadString(...) from main()

$
0
0

I found this answer about storing global configuration into globals.dart.

How can I load configuration into it from assets/config.json?

I've tried like this:

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'dart:convert';
import 'globals.dart' as globals;

void main() async {
  globals.config = jsonDecode(await rootBundle.loadString('assets/config.json'));
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  ...
}

The application starts with a white screen. Nothings happens, no errors. I guess that await rootBundle.loadString(...) causes the application to hang.


Viewing all articles
Browse latest Browse all 5049

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>