0

enter image description hereI have to use the clock wizard in flutter which works fine if insert directly inside body but i want to use it inside a column but it shows error. i've tried to use it as another stateful widget and calling inside children of column but still got error. Any help..???

import 'package:analog_clock_example/demo.dart';
import 'package:flutter/material.dart';

import 'package:analog_clock/analog_clock.dart';

void main() => runApp(MyApp());
//void main() => runDemo();

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  Widget build(BuildContext context) => MaterialApp(
          home: Scaffold(
        body: AnalogClock(),
      ));
}
Abhishek S
  • 27
  • 6

1 Answers1

1

I think it would have thrown you an error because you could have not set its constraints.
Try something like this,

import 'package:analog_clock_example/demo.dart';
import 'package:flutter/material.dart';

import 'package:analog_clock/analog_clock.dart';

void main() => runApp(MyApp()); 

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  Widget build(BuildContext context) => MaterialApp(
          home: Scaffold(
          body: Column(
               children: [
                  Container(
                    height: 300.0,       // Missing Constraints
                    width: 300.0,
                    child: AnalogClock(),
                 ),
             ],
          ),
      ),
    );
}

Make sure you stop and run it again and not doing Hot Reload. Hope that works!

Shri Hari L
  • 4,551
  • 2
  • 6
  • 18