1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Flutter] Flutter hot reloading is not working to display changes

Discussão em 'Mobile' iniciado por Stack, Outubro 9, 2024 às 12:52.

  1. Stack

    Stack Membro Participativo

    I have two files, main.dart and sections.dart.

    I have defined a few widgets in section.dart and used them in main.dart file, when I run flutter run command changes are displayed on screen, but when I press R to hot reload, nothing changes on screen.

    main.dart:

    import 'package:flutter/material.dart';
    import 'sections.dart';

    void main() {
    runApp(MyApp());
    }
    class MyApp extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
    return MaterialApp(
    debugShowCheckedModeBanner: false,
    title: 'Share IDEASS',
    home: Scaffold(
    appBar: AppBar(
    title: Text('IDEASs'),
    ),
    body: ListView(
    children: [
    labelsSection,
    ],
    ),
    ),
    );
    }
    }


    Sections.dart:

    import 'package:flutter/material.dart';
    class MyApp extends StatelessWidget {

    Widget build(BuildContext context) {
    return MaterialApp(
    title: 'Share IDEAS',

    );
    }
    }

    Column labelSectionMethod(color,IconData icon, String label,String numbers){
    return Column(
    children: <Widget>[
    Icon(icon, color:color),
    Container(
    child: Text(label,
    style: TextStyle(color: color
    ),
    ),
    ),
    Container(
    child:Text(numbers,
    style:TextStyle(color:color
    ),
    ),
    ),
    ],
    );
    }

    Widget labelsSection=Container(
    child: Row(
    mainAxisAlignment: MainAxisAlignment.spaceEvenly,
    children: [
    labelSectionMethod(Colors.red,Icons.supervised_user_circle,"IDEASS","35"),
    labelSectionMethod(Colors.red,Icons.favorite,"LIKE","22"),
    labelSectionMethod(Colors.red,Icons.data_usage,"STREAK","12"),
    ],
    ),
    );


    Maybe because I am repeating:

    return MaterialApp(
    title: 'Share IDEAS',
    );


    in sections.dart, or something to do with main function.


    UPDATE:

    i moved content of sections.dart file in main.dart file still hot reload is not working.

    Continue reading...

Compartilhe esta Página