Cannot see the checkbox and the text in the body of the App

Viewed 21

I am a beginner in Dart and Flutter. I followed the Flutter YouTube channel's first video in Flutter, and they created a basic page with a checkbox and a progress indicator.

I followed and I can see the progress indicator in the app, but I can't see any checkboxes or the text adjacent to the checkboxes that I had specified. There seems to be no error too! or there is but I couldn't find it!

The main.dart file


import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter App',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatelessWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Checkbox'),
      ),
      body: Column(
        children: [
          MyProgress(),
        ],
      ),
    );
  }
}

class MyProgress extends StatelessWidget {
  const MyProgress({super.key});

  @override
  Widget build(BuildContext context) {
    return Column(
      children: const [
        Text("Your Progess can be viewed here!"),
        LinearProgressIndicator(value: 0.0),
      ],
    );
  }
}

class TaskItem extends StatelessWidget {
  final String label;
  const TaskItem({Key? key, required this.label}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Row(
      children: [Checkbox(value: false, onChanged: null), Text(label)],
    );
  }
}

class TaskList extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        TaskItem(label: "AI Note"),
        TaskItem(label: "DAA Note"),
        TaskItem(label: "DDM Note"),
        TaskItem(label: "DPCO Note"),
        TaskItem(label: "DM Note"),
      ],
    );
  }
}
1 Answers

I can't see any checkboxes or the text

its because you not call the TaskList in your scren.

Widget build(BuildContext context) {
   return Scaffold(
      appBar: AppBar(
        title: Text('Checkbox'),
      ),
      body: Column(
        children: [
          MyProgress(), // you only show the linear progress
          TaskList(), // all you need to do is, to add this 
        ],
      ),
    );

result

Related